Skip to content

CI: Fix MongoDB version + Makefile and PHPStan for local/CI dev experience#503

Merged
bartmcleod merged 10 commits intolexik:masterfrom
HecFranco:master
Mar 10, 2026
Merged

CI: Fix MongoDB version + Makefile and PHPStan for local/CI dev experience#503
bartmcleod merged 10 commits intolexik:masterfrom
HecFranco:master

Conversation

@HecFranco
Copy link
Contributor

@HecFranco HecFranco commented Mar 10, 2026

Summary

  • Fix MongoDB compatibility in GitHub Actions so ODM tests pass.
  • Add a Makefile for common dev commands (up, down, build, test, rector, cs-fix, phpstan, ensure-up, install, update, cache-clear, help).
  • Add PHPStan (^2.0) and PHP-CS-Fixer (^3.64) as dev dependencies with config and Makefile targets.
  • Upgrade Rector to ^2.0 with Rector 2 config style.
  • Add Docker-based dev workflow (PHP 8.3) and documented .gitignore.

Changes

CI (.github/workflows/php.yml)

  • MongoDB service: upgrade image from mongo:4.0 to mongo:4.4 so the server reports wire version ≥ 8, required by the current ext-mongodb / libmongoc (avoids "wire version 7, but this version of libmongoc requires at least 8").
  • MongoDB health check: add options with health-cmd so the job waits for MongoDB to be ready before running tests.

Makefile

  • Targets: up, down, build, test, rector, cs-fix, phpstan, ensure-up, cache-clear, install, update, help.
  • Default goal: help (running make shows available commands).
  • ensure-up: runs docker compose up -d and composer install so services and dependencies are ready; used as dependency for test, rector, cs-fix, phpstan, install, update, cache-clear.
  • All PHP commands run inside the lexik_translation container via docker compose run --rm lexik_translation.
  • Help texts are in English.

PHPStan

  • composer.json: add phpstan/phpstan: ^2.0 in require-dev.
  • phpstan.neon.dist: config with level: 5, paths aligned with Rector (bundle code), excluding vendor and Tests.
  • Makefile: make phpstan runs vendor/bin/phpstan analyse --memory-limit=512M in the container.

PHP-CS-Fixer

  • composer.json: add friendsofphp/php-cs-fixer: ^3.64 in require-dev.
  • .php-cs-fixer.dist.php: new config (PSR-12 and common rules); replaces legacy .php_cs (API 1.x).
  • Makefile: make cs-fix runs vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php in the container.

Rector

  • composer.json: upgrade rector/rector from ^0.14.8|^0.15 to ^2.0; remove rector/jack.
  • rector.php: switch to Rector 2 config style (RectorConfig::configure()->withPaths()->withSets()); keep LevelSetList::UP_TO_PHP_81.
  • Makefile: make rector runs vendor/bin/rector process in the container.

Docker

  • Dockerfile: use php:8.3-cli-bullseye so Rector and PHPStan run without PHP 8.4 deprecations/fatal in vendor.

Other

  • .gitignore: add Spanish comments explaining each ignored path.
  • composer.lock: updated for new dev dependencies and versions.

How to test

  • CI: Push and confirm GitHub Actions pass (MongoDB tests should no longer fail with wire version error).
  • Local:
    • make ensure-up
    • Then: make test, make phpstan, make cs-fix, make rector, make help.

- Upgraded MongoDB image from version 4.0 to 4.4 for improved features and security.
- Enhanced health check options for the MongoDB service to ensure better reliability during CI runs.
- Introduced PHPStan as a development dependency for static code analysis.
- Updated composer.json to include PHPStan version 2.0 in the require-dev section.
- Created phpstan.neon.dist configuration file with specified analysis parameters and paths.
- Introduced a Makefile to streamline Docker commands for the LexikTranslationBundle.
- Added commands for starting/stopping services, building images, running tests, and managing dependencies.
- Enhanced developer experience by providing a centralized help command for available operations.
- Enhanced .gitignore to include additional directories for Composer dependencies, IDE configurations, and cache files.
- Removed deprecated .php_cs configuration file and replaced it with .php-cs-fixer.dist.php for PHP-CS-Fixer setup.
- Updated composer.json to include friendsofphp/php-cs-fixer as a development dependency and adjusted other dependencies.
- Modified Makefile to use the new PHP-CS-Fixer configuration file.
- Updated Dockerfile to use PHP 8.3 instead of 8.4 for compatibility.
- Refactored LexikTranslationBundle.php to reorder use statements for better organization.
- Set PHP platform version to 8.2.0 in composer.json for compatibility.
- Updated composer.lock to reflect changes in package versions, including downgrading doctrine/instantiator to 2.0.0 and symfony packages to 7.4.x versions.
- Adjusted PHP requirements for several packages to ensure compatibility with the new PHP version.
- Added ext-mongodb version 2.1.4 to composer.json and platform-overrides in composer.lock for compatibility.
- Downgraded mongodb/mongodb package version to 2.1.2 and updated related references in composer.lock.
- Adjusted rector/rector version to 2.1.4 and updated vimeo/psalm version to 6.5.* in composer.lock.
Copy link
Collaborator

@bartmcleod bartmcleod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also remove the .php-cs-fixer.cache and add it to .gitignore

.gitignore Outdated
@@ -1,9 +1,20 @@
# Dependencias de Composer (instaladas con composer install)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please translate to English. There is no added value to having them in Spanish. Did AI do this for you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use a prompt to generate and review a development environment that checks the code generated by the Makefile. By the way, I ran CS Fixer and Rector and they suggested some changes, but I haven’t wanted to add them yet. Take a look at them and validate them if you can.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean. I meant to translate the Spanish comments to English. Why would they need to be in Spanish?

help:
@echo "LexikTranslationBundle - Available commands:"
@echo ""
@echo " make up Start services in the background"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix white space please

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
return RectorConfig::configure()
->withPaths([
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we have path definitions in two places now?

@bartmcleod
Copy link
Collaborator

@HecFranco Thank you for the extensive PR. I am not sure about the makefile, because it will require make to be installed. I had a few minor comments in my review, otherwise looking good! If you can remove the cache file and clarify how make would work cross-platform, we are good to go with this one.

- Commented out the .php-cs-fixer.cache entry in .gitignore to prevent tracking of the cache file.
- Deleted the .php-cs-fixer.cache file to clean up the project and avoid unnecessary cache tracking.
- Restored the .php-cs-fixer.cache entry in .gitignore to ensure the cache file is ignored during version control, preventing unnecessary tracking.
@HecFranco
Copy link
Contributor Author

@HecFranco Thank you for the extensive PR. I am not sure about the makefile, because it will require make to be installed. I had a few minor comments in my review, otherwise looking good! If you can remove the cache file and clarify how make would work cross-platform, we are good to go with this one.

Thanks for the review and for the comments.

Good point about the Makefile. I added it as a convenience layer for common development commands, not as a hard requirement. I’ve clarified in the PR that the underlying commands can still be run directly without make.

I’ve also removed the cache file from the PR.

For cross-platform support, I’ve added a note with the alternatives for environments where make is not available by default.

Thanks again.

- Translated comments in .gitignore to English for better understanding.
- Ensured consistency in formatting and terminology across all entries.
- Updated README.md to include a new section on development setup, detailing the use of the Makefile for common tasks.
- Created docs/development.md to provide comprehensive instructions for running development tooling, including cross-platform usage with Docker Compose.
- Included commands for testing, static analysis, and code style management to enhance developer experience.
parameters:
level: 5
paths:
- Command
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You did not reply to my comment about having the paths in two places. Can we use just one?

@bartmcleod bartmcleod merged commit 6f5b9e7 into lexik:master Mar 10, 2026
3 checks passed
@@ -1,4 +1,4 @@
FROM php:8.4-cli-bullseye
FROM php:8.3-cli-bullseye
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The one downside I see here is that we will not see deprecation errors when testing/running the code on local. Personally, I'm not affected by this, because I have a separate php 8.5 docker running for it, but still...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants