From 6a4fdeebb325f2283966f1b735e361e48e0aab0d Mon Sep 17 00:00:00 2001 From: Massimiliano Arione Date: Sat, 20 Dec 2025 15:37:16 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=80=20various=20improvements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .php-cs-fixer.php | 13 +++-- .stylelintrc.json | 4 +- Makefile | 2 +- bin/console | 27 +++------- composer.json | 57 ++++++++++++---------- config/docker/nginx/Dockerfile | 2 +- config/docker/nginx/nginx.conf | 13 +---- config/docker/php-fpm/Dockerfile | 12 +++-- config/packages/cache.yaml | 2 +- config/packages/doctrine.yaml | 5 -- config/packages/routing.yaml | 5 ++ config/routes/dev/framework.yaml | 2 +- config/routes/dev/web_profiler.yaml | 4 +- deploy.php | 1 + docker-compose.yaml | 2 +- package.json | 22 ++++----- phpunit.xml.dist | 4 +- public/index.php | 23 ++------- templates/layout.html.twig | 2 +- tests/Controller/DefaultControllerTest.php | 1 - tests/bootstrap.php | 8 --- webpack.config.js | 5 +- 22 files changed, 91 insertions(+), 125 deletions(-) delete mode 100644 tests/bootstrap.php diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 0258719..dd25be4 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -1,21 +1,24 @@ in([__DIR__.'/src', __DIR__.'/tests']) ; -return (new PhpCsFixer\Config()) +return new PhpCsFixer\Config() + ->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect()) ->setRiskyAllowed(true) ->setRules([ '@Symfony' => true, '@Symfony:risky' => true, - '@PHP82Migration' => true, - '@PHPUnit100Migration:risky' => true, + '@PHP8x5Migration' => true, + '@PHP8x5Migration:risky' => true, + '@PHPUnit11x0Migration:risky' => true, 'declare_strict_types' => false, - 'native_function_invocation' => ['include' => ['@all']], + 'native_function_invocation' => ['include' => ['@internal']], 'method_chaining_indentation' => true, 'fopen_flags' => ['b_mode' => true], + 'php_unit_test_case_static_method_calls' => ['call_type' => 'self'], 'trailing_comma_in_multiline' => ['elements' => ['arguments', 'arrays', 'match', 'parameters']], ]) ->setFinder($finder) diff --git a/.stylelintrc.json b/.stylelintrc.json index ae97f4a..df408b0 100644 --- a/.stylelintrc.json +++ b/.stylelintrc.json @@ -5,8 +5,6 @@ "scss/double-slash-comment-empty-line-before": null, "scss/no-global-function-names": null, "at-rule-no-unknown": null, - "indentation": 4, - "no-descending-specificity": null, - "selector-list-comma-newline-after": "never-multi-line" + "no-descending-specificity": null } } diff --git a/Makefile b/Makefile index e4565b6..89288ff 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ cs: ## execute fix coding standard (requires php-cs-fixer locally installed) ${EXEC} -e XDEBUG_MODE=off php bin/php-cs-fixer fix -v twigcs: ## execute fix twig coding standard - ${EXEC} -e XDEBUG_MODE=off php bin/twig-cs-fixer lint templates + ${EXEC} -e XDEBUG_MODE=off php bin/twig-cs-fixer lint templates --fix stan: ## execute static analysis (requires phpstan locally installed) ${EXEC} -e XDEBUG_MODE=off php bin/phpstan analyse -v diff --git a/bin/console b/bin/console index 02971a6..b29a12e 100755 --- a/bin/console +++ b/bin/console @@ -1,26 +1,13 @@ #!/usr/bin/env php getParameterOption(['--env', '-e'], null, true)) { - putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env); -} +return static function (array $context): Application { + $kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); -if ($input->hasParameterOption('--no-debug', true)) { - putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0'); -} - -if ($_SERVER['APP_DEBUG']) { - umask(0000); - if (class_exists(Symfony\Component\ErrorHandler\Debug::class)) { - Symfony\Component\ErrorHandler\Debug::enable(); - } -} - -$kernel = new Infrastructure\Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); -$application = new Symfony\Bundle\FrameworkBundle\Console\Application($kernel); -$application->run($input); + return new Application($kernel); +}; diff --git a/composer.json b/composer.json index ceb1fe3..1ab1c48 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,8 @@ { "name": "beelab/symfony-beelab", - "type": "project", "description": "Adapt this file with your actual project content", "license": "MIT", + "type": "project", "authors": [ { "name": "Massimiliano Arione", @@ -14,30 +14,31 @@ } ], "require": { - "php": "^8.3", + "php": "^8.4", "ext-ctype": "*", "ext-iconv": "*", "ext-intl": "*", "ext-mbstring": "*", - "symfony/flex": "^2.5" + "symfony/flex": "^2.10" }, "flex-require": { - "doctrine/doctrine-bundle": "^2.14", - "doctrine/orm": "^3.3", + "doctrine/doctrine-bundle": "^3.1", + "doctrine/orm": "^3.5", "ramsey/uuid-doctrine": "^2.1", - "symfony/asset": "^6.4", - "symfony/console": "^6.4", - "symfony/form": "^6.4", - "symfony/framework-bundle": "^6.4", - "symfony/mailer": "^6.4", - "symfony/messenger": "^6.4", - "symfony/monolog-bundle": "^3.10", - "symfony/security-bundle": "^6.4", - "symfony/translation": "^6.4", - "symfony/twig-bundle": "^6.4", - "symfony/validator": "^6.4", - "symfony/web-link": "^6.4", - "symfony/yaml": "^6.4" + "symfony/asset": "^7.4", + "symfony/console": "^7.4", + "symfony/form": "^7.4", + "symfony/framework-bundle": "^7.4", + "symfony/mailer": "^7.4", + "symfony/messenger": "^7.4", + "symfony/monolog-bundle": "^4.0", + "symfony/runtime": "^7.4", + "symfony/security-bundle": "^7.4", + "symfony/translation": "^7.4", + "symfony/twig-bundle": "^7.4", + "symfony/validator": "^7.4", + "symfony/web-link": "^7.4", + "symfony/yaml": "^7.4" }, "replace": { "symfony/polyfill-ctype": "*", @@ -51,18 +52,19 @@ "symfony/polyfill-php80": "*", "symfony/polyfill-php81": "*", "symfony/polyfill-php82": "*", - "symfony/polyfill-php83": "*" + "symfony/polyfill-php83": "*", + "symfony/polyfill-php84": "*" }, "flex-require-dev": { - "beelab/test-bundle": "^7.0", - "dama/doctrine-test-bundle": "^8.3", + "beelab/test-bundle": "^7.2", + "dama/doctrine-test-bundle": "^8.4", "deployer/deployer": "^7.5", - "doctrine/doctrine-fixtures-bundle": "^4.1", - "phpunit/phpunit": "^12.1", + "doctrine/doctrine-fixtures-bundle": "^4.3", + "phpunit/phpunit": "^12.5", "symfony/debug-bundle": "^6.4", - "symfony/phpunit-bridge": "^7.2", + "symfony/phpunit-bridge": "^7.4", "symfony/profiler-pack": "^1.0", - "vincentlanglet/twig-cs-fixer": "^3.6" + "vincentlanglet/twig-cs-fixer": "^3.11" }, "config": { "allow-plugins": { @@ -73,9 +75,12 @@ "sort-packages": true }, "extra": { + "runtime": { + "disable_dotenv": true + }, "symfony": { "allow-contrib": true, - "require": "^6.4" + "require": "^7.4" } }, "autoload": { diff --git a/config/docker/nginx/Dockerfile b/config/docker/nginx/Dockerfile index ff3c598..77a713f 100644 --- a/config/docker/nginx/Dockerfile +++ b/config/docker/nginx/Dockerfile @@ -1,4 +1,4 @@ -FROM nginx:1.25 +FROM nginx:1 RUN apt update && apt install -y --no-install-recommends curl diff --git a/config/docker/nginx/nginx.conf b/config/docker/nginx/nginx.conf index 1787591..18c90c9 100644 --- a/config/docker/nginx/nginx.conf +++ b/config/docker/nginx/nginx.conf @@ -1,5 +1,5 @@ server { - server_name customize.local *.ngrok.io; + server_name customize.local *.ngrok-free.app; root /user/customize/public; client_max_body_size 300M; @@ -32,17 +32,8 @@ server { fastcgi_pass php:9000; fastcgi_split_path_info ^(.+\.php)(/.*)$; include fastcgi_params; - # When you are using symlinks to link the document root to the - # current version of your application, you should pass the real - # application path instead of the path to the symlink to PHP FPM. - # Otherwise, PHP's OPcache may not properly detect changes to your - # PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 - # for more information). fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; fastcgi_param DOCUMENT_ROOT $realpath_root; - # Prevents URIs that include the front controller. This will 404: - # http://symfony3.dev/index.php/some-path - # Remove the internal directive to allow URIs like this - #internal; + internal; } } diff --git a/config/docker/php-fpm/Dockerfile b/config/docker/php-fpm/Dockerfile index 31baa90..7034d1f 100644 --- a/config/docker/php-fpm/Dockerfile +++ b/config/docker/php-fpm/Dockerfile @@ -1,5 +1,5 @@ -FROM composer:2.8 AS composer -FROM php:8.3-fpm +FROM composer:2.9 AS composer +FROM php:8.5-fpm ARG HOST_UID @@ -13,9 +13,13 @@ RUN rm /etc/localtime && ln -s /usr/share/zoneinfo/Europe/Rome /etc/localtime RUN apt update && apt install -y --no-install-recommends zlib1g-dev libicu-dev g++ vim default-mysql-client libxslt1-dev libxrender1 libxext6 libfontconfig libjpeg-dev libonig-dev nodejs npm RUN docker-php-ext-install pdo pdo_mysql intl mysqli iconv xsl +# Install PIE +RUN curl --output /usr/bin/pie --location https://github.com/php/pie/releases/download/1.3.1/pie.phar \ + && chmod +x /usr/bin/pie + # Install xdebug -RUN pecl install xdebug-3.4.2 && docker-php-ext-enable xdebug -RUN { \ +RUN pie install xdebug/xdebug && docker-php-ext-enable xdebug \ + && { \ echo 'error_reporting = E_ALL'; \ echo 'display_startup_errors = On'; \ echo 'display_errors = On'; \ diff --git a/config/packages/cache.yaml b/config/packages/cache.yaml index 9feb900..009d815 100644 --- a/config/packages/cache.yaml +++ b/config/packages/cache.yaml @@ -1,7 +1,7 @@ framework: cache: # Unique name of your app: used to compute stable namespaces for cache keys. - #prefix_seed: your_vendor_name/app_name + prefix_seed: beelab/customize # The "app" cache stores to the filesystem by default. # The data in this cache should persist between deploys. diff --git a/config/packages/doctrine.yaml b/config/packages/doctrine.yaml index 8fcbc42..f9decd7 100644 --- a/config/packages/doctrine.yaml +++ b/config/packages/doctrine.yaml @@ -3,13 +3,9 @@ doctrine: url: '%env(resolve:APP_DATABASE_URL)%' server_version: '8.0.31' orm: - auto_generate_proxy_classes: '%kernel.debug%' naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware auto_mapping: false validate_xml_mapping: true - enable_lazy_ghost_objects: true - controller_resolver: - auto_mapping: false # uncomment after having added at least one entity and/or VO # mappings: # entity: @@ -33,7 +29,6 @@ when@test: dbal: dbname_suffix: '_test' logging: false - use_savepoints: true when@prod: doctrine: diff --git a/config/packages/routing.yaml b/config/packages/routing.yaml index 796ba11..529145b 100644 --- a/config/packages/routing.yaml +++ b/config/packages/routing.yaml @@ -5,3 +5,8 @@ framework: # Configure how to generate URLs in non-HTTP contexts, such as CLI commands. # See https://symfony.com/doc/current/routing.html#generating-urls-in-commands #default_uri: http://localhost + +when@dev: + framework: + router: + default_uri: 'http://customize.local:8080/' diff --git a/config/routes/dev/framework.yaml b/config/routes/dev/framework.yaml index bcbbf13..26ac9c6 100644 --- a/config/routes/dev/framework.yaml +++ b/config/routes/dev/framework.yaml @@ -1,3 +1,3 @@ _errors: - resource: '@FrameworkBundle/Resources/config/routing/errors.xml' + resource: '@FrameworkBundle/Resources/config/routing/errors.php' prefix: /_error diff --git a/config/routes/dev/web_profiler.yaml b/config/routes/dev/web_profiler.yaml index 79b52d0..8346e93 100644 --- a/config/routes/dev/web_profiler.yaml +++ b/config/routes/dev/web_profiler.yaml @@ -1,7 +1,7 @@ _profiler: - resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml' + resource: '@WebProfilerBundle/Resources/config/routing/profiler.php' prefix: /_profiler _wdt: - resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml' + resource: '@WebProfilerBundle/Resources/config/routing/wdt.php' prefix: /_wdt diff --git a/deploy.php b/deploy.php index 485603e..d41983d 100644 --- a/deploy.php +++ b/deploy.php @@ -12,6 +12,7 @@ set('shared_dirs', ['var/log']); set('writable_dirs', ['var', 'var/log']); set('release_name', static fn (): string => \date('ymdHi')); +set('composer_options', '--no-progress --no-interaction --no-dev --classmap-authoritative --apcu-autoloader'); desc('Update database'); task('deploy:db:update', static function (): void { diff --git a/docker-compose.yaml b/docker-compose.yaml index 2b0f008..e8682ea 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,6 +1,6 @@ services: database: - image: mysql:8.0 + image: mysql:8.4 environment: - MYSQL_ROOT_PASSWORD=root php: diff --git a/package.json b/package.json index 178d074..1da5b13 100644 --- a/package.json +++ b/package.json @@ -9,20 +9,20 @@ "stylelint": "stylelint -f verbose ./assets/scss/*.scss" }, "dependencies": { - "@fortawesome/fontawesome-free": "^6.7.2", + "@fortawesome/fontawesome-free": "^7.1.0", "@popperjs/core": "^2.11.8", - "bootstrap": "^5.3.5" + "bootstrap": "^5.3.8" }, "devDependencies": { - "@babel/core": "^7.27.1", - "@babel/preset-env": "^7.27.1", - "@symfony/webpack-encore": "^5.1.0", - "eslint": "^9.25.0", - "sass": "^1.86.3", - "sass-loader": "^16.0.5", - "stylelint": "^16.19.1", - "stylelint-config-standard": "^38.0.0", - "stylelint-config-standard-scss": "^14.0.0" + "@babel/core": "^7.28.5", + "@babel/preset-env": "^7.28.5", + "@symfony/webpack-encore": "^5.3.1", + "eslint": "^9.39.1", + "sass": "^1.96.0", + "sass-loader": "^16.0.6", + "stylelint": "^16.26.1", + "stylelint-config-standard": "^39.0.1", + "stylelint-config-standard-scss": "^16.0.0" }, "author": "Massimiliano Arione", "homepage": "https://github.com/bee-lab" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index fbff7c0..88e178b 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,9 +1,9 @@ - + diff --git a/public/index.php b/public/index.php index 0b7111c..e3539b2 100644 --- a/public/index.php +++ b/public/index.php @@ -1,24 +1,7 @@ handle($request); -$response->send(); -$kernel->terminate($request, $response); +return static fn (array $context): Kernel => new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); diff --git a/templates/layout.html.twig b/templates/layout.html.twig index c62f161..26c81e9 100644 --- a/templates/layout.html.twig +++ b/templates/layout.html.twig @@ -39,7 +39,7 @@ diff --git a/tests/Controller/DefaultControllerTest.php b/tests/Controller/DefaultControllerTest.php index 00c0b93..532e413 100644 --- a/tests/Controller/DefaultControllerTest.php +++ b/tests/Controller/DefaultControllerTest.php @@ -6,7 +6,6 @@ use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\Test; - #[Group('functional')] final class DefaultControllerTest extends WebTestCase { diff --git a/tests/bootstrap.php b/tests/bootstrap.php deleted file mode 100644 index 902d386..0000000 --- a/tests/bootstrap.php +++ /dev/null @@ -1,8 +0,0 @@ -