This is a small project to catch Pokémons in the wild!
The idea is to get into Symfony framework and create a simple application using some good coding practices. In this application I used Pokémon TGC SDK as a service to communicate with the Pokémon TGC API pokemontcg.io.
This a Docker based project for Symfony framework with PHP 8.3
-
If not already done, install Docker Compose (v2.10+)
-
Clone repository
git clone https://github.com/renatoamado/pokemon-symfony.gitand go to the directory -
Inside the terminal
- Run
docker compose build --no-cacheto build fresh images - Run
docker compose up -d --waitto set up and start a fresh Symfony project
- Run
-
Access the application container
docker exec -it php bash -
Copy the local and test local env files
cp .env.local.example .env.localcp .env.test.local.example .env.test.local- in these files are configurations like DATABASE_URL and API_KEY. The first one is something that maybe I did something unnecessary in some point but now this variable is necessary :). And the api key is not required, but it will limit the amount of requests you can make to the Pokémon API. If you need one, just create an account at Pokémon TGC and when you confirm your email, the apikey will be available once you log in again :)
-
Install composer dependencies
composer install -
Open
https://localhost/pokemonin your favorite web browser and wait a little bit (yes, the first fetch is slow) -
There's a test suite configured in
composer.jsonfile you can use it inside the container as followscomposer refactoto run rector process. It will validate and refactor your code based on your current PHP versioncomposer lintto run php-cs-fixer fix. It will apply the phpcs to your code base and fix your code based on the config file in the project root foldercomposer test:lintto run php-cs-fixer fix --diff --verbose --dry-run. It will run phpcs fixer, but it will only show the suggestions. It will not change the codecomposer test:typesto run phpstan analyse --ansi --memory-limit=2G. It will run phpstan on your code to check for wrong variable typescomposer test:unitto run phpunit --coverage-text. It will run all your tests inside the tests folder and show the code coverage %composer test:refactoto run rector process --dry-run. It will run rector, but it will just show the suggested changescomposer testto run the complete test suite above
- When you run the phpcs tests, either
composer test:lintorcomposer test, phpcs fixer might show some "errors" which are really nothing. If that happens, just runcomposer lintand it will fix all of them and you can run the complete test suite again