Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to php8.1 symfony 6.4 #141

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
dad3a20
change branch name
xh3n1 Mar 5, 2019
9e4e996
Disable REST API by default
xh3n1 Mar 6, 2019
7d2145f
Change path
xh3n1 Mar 26, 2019
81fd339
Remove prefix
xh3n1 Apr 4, 2019
30fde0d
[FEATURE] Get the number of subscribers of list and added tests (#116)
xh3n1 May 31, 2019
8fca0ef
[BUGFIX] Fix the expected number in an integration test (#119)
xh3n1 May 31, 2019
4364ded
[CLEANUP] Fix a warning with newer PHPMD versions (#125)
Dec 5, 2019
26ea3c8
update php dependencies
michield Oct 4, 2022
110b25d
update to pass building
michield Feb 9, 2023
c07cee1
ISSUE-337: update package versions
tatevikg1 Nov 24, 2024
b687537
ISSUE-337: use local
tatevikg1 Nov 24, 2024
85ab9ce
ISSUE-337: symfony 6.4
tatevikg1 Nov 30, 2024
f09b1f9
ISSUE-337: test fix
tatevikg1 Dec 5, 2024
bf004d0
ISSUE-337: fix the rest of tests
tatevikg1 Dec 10, 2024
86b26f6
GitHub actions (#132)
nfebe Feb 11, 2021
a35a7d5
ISSUE-337: add pipeline
tatevikg1 Dec 11, 2024
276d397
ISSUE-337: fix phpstan
tatevikg1 Dec 11, 2024
acec73c
ISSUE-337: fix phpstmd
tatevikg1 Dec 11, 2024
3453581
ISSUE-337: openapi docs
tatevikg1 Dec 12, 2024
1986e45
merge main
tatevikg1 Dec 12, 2024
2e8300a
ISSUE-337: move to bundle file
tatevikg1 Dec 12, 2024
b483207
ISSUE-337: changelog
tatevikg1 Dec 14, 2024
884fb1e
ISSUE-337: update core
tatevikg1 Dec 15, 2024
8ad8004
ISSUE-337: fix phpstan
tatevikg1 Dec 15, 2024
7502393
ISSUE-337: fix phpcs
tatevikg1 Dec 15, 2024
1e4294c
ISSUE-337: force push
tatevikg1 Dec 15, 2024
2ce9ae1
ISSUE-337: name fix
tatevikg1 Dec 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['7.2', '7.3', '7.4', '8.0']
# dependencies: ['latest', 'oldest'] # Only latest/upwards dependencies supported currently.
php-versions: ['8.1']
dependencies: ['latest', 'oldest']
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -48,18 +48,15 @@ jobs:
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
# - name: Install the lowest dependencies
# run: composer update --with-dependencies --prefer-stable --prefer-dist --prefer-lowest
# if: ${{ matrix.dependencies }} == "latest"
- name: Install dependencies
run: composer update --with-dependencies --prefer-stable --prefer-dist
if: ${{ matrix.dependencies }} == "latest"
- name: Install current dependencies from composer.lock
run: composer install
continue-on-error: ${{matrix.php-versions == '8.0' }} # Temporal until full support for php8 === [temp-php8]
- name: Set up database schema
run: mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -u${{ env.DB_USERNAME }} -p${{ env.DB_PASSWORD }} ${{ env.DB_DATABASE }} < vendor/phplist/core/resources/Database/Schema.sql
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
- name: Validating composer.json
run: composer validate --no-check-all --no-check-lock --strict;
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
- name: Linting all php files
run: find src/ tests/ public/ -name ''*.php'' -print0 | xargs -0 -n 1 -P 4 php -l; php -l;
- name: Running unit tests
Expand All @@ -76,10 +73,7 @@ jobs:
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
- name: Running static analysis
run: vendor/bin/phpstan analyse -l 5 src/ tests/;
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
- name: Running PHPMD
run: vendor/bin/phpmd src/ text vendor/phplist/core/config/PHPMD/rules.xml;
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
- name: Running PHP_CodeSniffer
run: vendor/bin/phpcs --standard=vendor/phplist/core/config/PhpCodeSniffer/ src/ tests/;
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
131 changes: 75 additions & 56 deletions .github/workflows/restapi-docs.yml
Original file line number Diff line number Diff line change
@@ -1,73 +1,92 @@
name: Publish REST API Docs
on: [push, pull_request]
name: Publish REST API Docs
on:
push:
branches:
- main
pull_request:

jobs:
make-restapi-docs:
name: Checkout phpList rest-api and generate docs specification (OpenAPI latest-restapi.json)
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
- name: Checkout Repository
uses: actions/checkout@v3

- name: Setup PHP with Composer and Extensions
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.1
extensions: mbstring, dom, fileinfo, mysql
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v2

- name: Cache Composer Dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
path: ~/.composer/cache
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install current dependencies from composer.lock
run: composer install
- name: Generate OpenAPI Specification JSON for REST API
restore-keys: |
${{ runner.os }}-composer-

- name: Install Composer Dependencies
run: composer install --no-interaction --prefer-dist

- name: Generate OpenAPI Specification JSON
run: vendor/bin/openapi -o docs/latest-restapi.json --format json src
- name: Upload REST API(latest-restapi.json) Spec
uses: actions/upload-artifact@v2

- name: Upload REST API Specification
uses: actions/upload-artifact@v3
with:
name: restapi-json
path: docs/latest-restapi.json

deploy-docs:
name: Deploy REST API specification.
name: Deploy REST API Specification
runs-on: ubuntu-20.04
needs: make-restapi-docs
steps:
- name: Install node
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install openapi-checker
run: npm install -g openapi-checker
- name: Checkout phplist/restapi-docs
uses: actions/checkout@v2
with:
repository: phpList/restapi-docs
fetch-depth: 0
token: ${{ secrets.PUSH_REST_API_DOCS }}
- name: Restore REST API Spec
uses: actions/download-artifact@v2
with:
name: restapi-json
- name: Validate latest-restapi.json
run: openapi-checker latest-restapi.json
- name: Get difference between latest-restapi.json and restapi.json
# `|| true` to supress exit code 1 [git diff exits with 1 when there is a difference between the two files and 0 for the reverse.
run: git diff --no-index --output=restapi-diff.txt latest-restapi.json restapi.json || true
- name: Verify difference latest-restapi.json and restapi.json
id: allow-deploy
run: |
if [ -s restapi-diff.txt ]; then echo "Updates made to restapi.json deployment proceeding."; echo '::set-output name=DEPLOY::true'; else echo "No updates made to restapi.json deployment would be skipped."; echo '::set-output name=DEPLOY::false'; fi
- name: Commit and changes and deply
if: ${{ steps.allow-deploy.outputs.DEPLOY == 'true' }}
run: |
mv latest-restapi.json restapi.json
git config user.name "github-actions"
git config user.email "[email protected]"
git add restapi.json
git commit -s -m "phplist/rest-api docs deployment `date`"
git push
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 14

- name: Install openapi-checker
run: npm install -g openapi-checker

- name: Checkout REST API Docs Repository
uses: actions/checkout@v3
with:
repository: phpList/restapi-docs
fetch-depth: 0
token: ${{ secrets.PUSH_REST_API_DOCS }}

- name: Download Generated REST API Specification
uses: actions/download-artifact@v3
with:
name: restapi-json

- name: Validate OpenAPI Specification
run: openapi-checker docs/latest-restapi.json

- name: Compare Specifications
run: git diff --no-index --output=restapi-diff.txt docs/latest-restapi.json restapi.json || true

- name: Check Differences and Decide Deployment
id: allow-deploy
run: |
if [ -s restapi-diff.txt ]; then
echo "Updates detected in the REST API specification. Proceeding with deployment.";
echo 'DEPLOY=true' >> $GITHUB_ENV;
else
echo "No changes detected in the REST API specification. Skipping deployment.";
echo 'DEPLOY=false' >> $GITHUB_ENV;
fi

- name: Commit and Deploy Updates
if: env.DEPLOY == 'true'
run: |
mv docs/latest-restapi.json docs/restapi.json
git config user.name "github-actions"
git config user.email "[email protected]"
git add docs/restapi.json
git commit -m "Update REST API documentation `date`"
git push
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
/public/
/var/
/vendor/
.phpunit.result.cache
76 changes: 25 additions & 51 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@
"source": "https://github.com/phpList/rest-api"
},
"require": {
"php": "^7.2|^8.0",
"phplist/core": "^v4.0.0-alpha5",
"friendsofsymfony/rest-bundle": "^2.8.6",
"sensio/framework-extra-bundle": "5.1.0",
"zircote/swagger-php": "^3.1"
"php": "^8.1",
"phplist/core": "dev-ISSUE-337",
"friendsofsymfony/rest-bundle": "*",
"symfony/test-pack": "^1.0",
"symfony/process": "^6.4",
"zircote/swagger-php": "^4.11"
},
"require-dev": {
"phpunit/phpunit": "^6.5.14",
"phpunit/phpunit-mock-objects": "^5.0.6",
"phpunit/dbunit": "^3.0.3",
"guzzlehttp/guzzle": "^6.5.5",
"squizlabs/php_codesniffer": "^3.5.8",
"phpstan/phpstan": "^0.7.0",
"nette/caching": "^3.1.0",
"nikic/php-parser": "^3.1.0",
"phpmd/phpmd": "^2.9.1"
"phpunit/phpunit": "^10.0",
"guzzlehttp/guzzle": "^6.3.0",
"squizlabs/php_codesniffer": "^3.2.0",
"phpstan/phpstan": "^1.10",
"nette/caching": "^3.0.0",
"nikic/php-parser": "^4.19.1",
"phpmd/phpmd": "^2.6.0",
"doctrine/instantiator": "^2.0."
},
"autoload": {
"psr-4": {
Expand All @@ -57,6 +57,15 @@
"PhpList\\RestBundle\\Tests\\": "tests/"
}
},
"repositories": [
{
TatevikGr marked this conversation as resolved.
Show resolved Hide resolved
"type": "path",
"url": "../core",
"options": {
"symlink": true
}
}
],
"scripts": {
"list-modules": [
"PhpList\\Core\\Composer\\ScriptHandler::listModules"
Expand Down Expand Up @@ -86,7 +95,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "4.0.x-dev"
"dev-master": "5.0.x-dev"
},
"symfony-app-dir": "bin",
"symfony-bin-dir": "bin",
Expand All @@ -101,44 +110,9 @@
"routes": {
"rest-api": {
"resource": "@PhpListRestBundle/Controller/",
"type": "rest",
"type": "attribute",
"prefix": "/api/v2"
}
},
"configuration": {
"fos_rest": {
"routing_loader": {
"include_format": false
},
"format_listener": {
"enabled": true,
"rules": [
{
"path": "^/api/v2/",
"fallback_format": "json"
},
{
"path": "^/",
"fallback_format": "html"
}
]
},
"view": {
"view_response_listener": {
"enabled": true
}

},
"exception": {
"enabled": true,
"messages": {
"Symfony\\Component\\HttpKernel\\Exception\\BadRequestHttpException": true
}
},
"service": {
"view_handler": "my.secure_view_handler"
}
}
}
}
}
Expand Down
31 changes: 27 additions & 4 deletions config/services.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
services:
Psr\Container\ContainerInterface:
alias: 'service_container'

PhpList\RestBundle\Controller\:
resource: '../src/Controller'
public: true
autowire: true
tags: ['controller.service_arguments']

# Symfony\Component\Serializer\SerializerInterface:
# autowire: true
# autoconfigure: true

my.secure_handler:
class: \PhpList\RestBundle\ViewHandler\SecuredViewHandler
class: \PhpList\RestBundle\ViewHandler\SecuredViewHandler

my.secure_view_handler:
parent: fos_rest.view_handler.default
calls:
- ['registerHandler', [ 'json', ['@my.secure_handler', 'createResponse'] ] ]
parent: fos_rest.view_handler.default
calls:
- ['registerHandler', [ 'json', ['@my.secure_handler', 'createResponse'] ] ]

PhpList\Core\Security\Authentication:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Repository\Messaging\SubscriberListRepository:
autowire: true
autoconfigure: true

PhpList\RestBundle\EventListener\ExceptionListener:
tags:
- { name: kernel.event_listener, event: kernel.exception }

PhpList\RestBundle\EventListener\ResponseListener:
tags:
- { name: kernel.event_listener, event: kernel.response }
Loading
Loading