This is a repository template based on Slim 4 Framework.
Several features are already supported inside this repository template such as:
- Validation using cakephp/validation combined with selective/validation to construct a nice exception middleware, thanks a lot to Daniel Opitz a.k.a odan.
- ORM using cycle/orm with a simple database seeder provided. To make use the repository just simply get repository based on the entity for example
$orm->getRepository(UserEntity::class)
. - Logger using monolog/monolog with supports for file and console logger.
- Environment variables using vlucas/phpdotenv. The current settings support an overridden environment, simply make another env file for example
.env.staging
and add your staging environment to the default.env
. The settings under the same environment key would be automatically replaced. - Unit Test using phpunit/phpunit with mocked database. If the tests getting bigger and more complex and furthermore it runs slower than before, preferably shifting to the mocked repositores and transactions approach. The service
UserService
is already testable, you can runcomposer test
to see all the test case scenarios and all the output. - Beautiful swagger docs loaded with slim/php-view.
Basically, you want to set up your environment variables inside the .env
file and then simply run a php command:
php -S localhost:<your_lovely_port_here> -t public/
If you want to run the database seeder, make sure that you've set up the initial data inside the resources\setup
folder with the initialdata.json
name to your appropriate database structur (according to your table(s) and column(s) name) and then run the following command:
php src/Supports/Seeder.php
If the seeding process is done, the success message would appear in your whatever runs the command in.
The slim-api-template is open-sourced template repository licensed based on Slim 4 Framework, under the MIT license.