A skeleton to start new high-quality PHP projects without worrying about bootstrapping everything from scratch.
The skeleton includes a PHP project properly configured with:
- 🛠 Docker and docker-compose - because nobody wants (or should) to install project dependencies directly into their machines.
- 🎉 PHP 7.4
- 🕵 Xdebug - to stop wasting time printing values and start debugging PHP applications like a boss️.
- currently we provide install instructions for PHPStorm - but it also work with other editors/IDEs.
- 🚦PHPUnit - to write and run unit tests and also generate code coverage.
- 🏎 PHP Parallel Lint - to check syntax of PHP files.
- 📋 phpcs - to ensure good coding standards.
- currently check against Doctrine standard.
- 👻 phpstan - to find errors in the code before running it.
- 🚀 Continuous Integration - to ensure the previous tools runs for every contribution to your repository.
- currently works out-of-box with GitHub Actions.
Stop wasting time! 🏝🍹
- Docker CE - see the install guide.
- Docker Compose - it is already included in Docker Desktop for Mac and Windows). If necessary, see the install guide.
- nektos/act - (optional dependency) used to run GitHub Actions locally. See the install guide.
- Make sure you have the requirements described above.
- Clone this repository:
git clone git@github.com:xthiago/php-skeleton.git - Run
docker-compose run php composer installto install the PHP dependencies. - If you are using Linux, go to the next step. If you are using
Docker for Mac or Windows, create a.envfile (I suggest you copy from distribution version withcp .env.dist .env) and addXDEBUG_REMOTE_HOST=host.docker.internal). It is needed in order to allow Xdebug to connect back to the IDE in these OS. - (optional) You can configure the Xdebug in your editor/IDE in order to debug this application using it. See the guide.
- That's all 😜.
In order to start the web application, you must create and start the PHP service:
docker-compose up -d
Then you can open https://localhost:8000 in your browser. It will open web/index.php file.
For troubleshooting, you can watch the logs to see what's going on:
docker-compose logs -f
See docker-compose --help to get more
instructions.
You can access the terminal of PHP container with:
docker-compose exec php ash
You can also execute any command in PHP container from outside it typing and running:
docker-compose run php [command-name]
# Example: docker-compose run php
--help
You can run any available commands inside the PHP container:
parallel-lint --exclude vendor .to check the PHP syntax.phpcs- to check the codebase against code standards- the configuration is automatically inherited from phpcs.xml.
phpstan analyseto run a static analyse in the codebase- the configuration is automatically inherited from phpstan.neon.
phpunitto run the unit tests- the configuration is automatically inherited from phpunit.xml
composer testto run all commands above.phpunit --coverage-html reports/to generate code coverage of tests- the configuration is automatically inherited from phpunit.xml