Create a Docker environment for a Symfony project with integrated code quality tools.
- PHP >= 8.2
- Docker & Docker Compose
- Git
git clone https://github.com/jschwind/phpcli-symfony.git
cd phpcli-symfony
chmod +x createSFProject.sh updateSFProject.shAdd the scripts to your PATH or create symlinks, e.g., on Linux:
sudo ln -s $(pwd)/createSFProject.sh /usr/local/bin/createSFProject
sudo ln -s $(pwd)/updateSFProject.sh /usr/local/bin/updateSFProjectYou can run the script in Interactive Mode (recommended) or with Command Line Options.
Simply run the command without any arguments:
createSFProjectThe script will guide you through the setup, asking for:
- Project Name (default: current directory name)
- Git Username (default: from git config)
- Git Email (default: from git config)
- PHP Version (default:
8.3) - Symfony Version (default:
7.*) - Database Type (
postgres,mariadb,mysql,firebird, default:postgres) - Code Quality Tools (
ecs,rector,phpstan,phpunit) - Output Directory (default: current directory)
createSFProject [OPTIONS]-project-name: Name of the project.-git-username: Git username.-git-email: Git email.-php-version: PHP version (default:8.3).-symfony-version: Symfony version (default:7.*).-db-type: Database type (postgres,mariadb,mysql,firebird) (default:postgres).-mariadb-version: MariaDB version (default:11.5).-postgres-version: PostgreSQL version (default:17.0).-mysql-version: MySQL version (default:9.1).-firebird-version: Firebird version (default:5.0).-code-quality: Enable code quality tools (true/false).-tools: Comma-separated list of tools (ecs,rector,phpstan,phpunit).-output-dir: Target directory for project generation.
If you have an existing project and only want to add or update the code quality tools, use updateSFProject.
updateSFProjectThe script will ask for:
- Project Directory (defaults to current directory)
- PHP Version (automatically detected from
composer.jsonif available) - Symfony Version (automatically detected from
composer.jsonif available) - Tools to add
updateSFProject -php-version=8.4 -symfony-version=7.2 -tools=ecs,rector -output-dir=.After running createSFProject, you will find a docker/ directory in your project containing:
bash.sh/bash.bat: Enter the PHP container as theapplicationuser.root.sh/root.bat: Enter the PHP container as therootuser.docker-compose.yml: Docker configuration.web/Dockerfile: PHP environment configuration.
If enabled, the tool sets up a modern development environment using bamarni/composer-bin-plugin:
- ECS (Easy Coding Standard): Coding style checks.
- Rector: Automated code upgrades and refactoring.
- PHPStan: Static analysis.
- PHPUnit: Unit and functional testing.
All tools are installed in the vendor-bin/ directory to avoid dependency conflicts with your main project. Composer scripts like composer ci, composer test, and composer bin-rector are automatically added and configured.
Interactive setup:
createSFProjectNon-interactive with specific tools:
createSFProject -project-name=my-app -php-version=8.4 -db-type=mariadb -code-quality=true -tools=ecs,phpstan,phpunit