Download the PHP package mrhdolek/slim4-boirlerplate without Composer
On this page you can find all versions of the php package mrhdolek/slim4-boirlerplate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mrhdolek/slim4-boirlerplate
More information about mrhdolek/slim4-boirlerplate
Files in mrhdolek/slim4-boirlerplate
Package slim4-boirlerplate
Short Description An Slim 4 Framework skeleton using AMQP,DDD,Doctrine
License MIT
Homepage https://github.com/MrHDOLEK/slim4-boirlerplat
Informations about the package slim4-boirlerplate
Slim 4 Framework skeleton
An Slim 4 Framework skeleton using AMQP and DDD
I was inspired to create this skeleton from: robiningelbrecht.
Project setup
Development
If you have problems with permissions please add sudo before make example:
sudo make install
-
sudo make start
Run env for Mac/Linux
make install
make start
make db-create
Run env for Windows
Please install packages makefile for Windows
make install
make start
make db-create
Address where the environment is available
http://localhost
Documentation for a Rest Api
http://localhost/docs/v1
RabbitMq dashboard
-
http://localhost:15672
All commands
make help
Some examples
Registering a new route
Head over to config/routes.php
and add a route for your RequestHandler:
Console commands
The console application uses the Symfony console component to leverage CLI functionality.
Scheduling Commands
To schedule a command, we use the GO\Scheduler class. This class allows us to define the timing and frequency of command execution. Here's an example of how to schedule a command to run daily:
In this example, the app:user:create command is scheduled to run every day.
Running the Scheduler
The scheduler should be triggered by a system cron job to ensure it runs at regular intervals. Typically, you would set up a cron job to execute a PHP script that initializes and runs the scheduler.
For instance, a cron job running every minute might look like this:
This setup ensures that your scheduled commands are executed reliably and on time.
Domain event and event handlers
The framework implements the amqp protocol with handlers that allow events to be easily pushed onto the queue. Each event must have a handler implemented that consumes the event.
Creating a new event
Creating the corresponding event handler
Eventing
Create a new event
Async processing of commands with RabbitMQ
The chosen AMQP implementation for this project is RabbitMQ, but it can be easily switched to for example Amazon's AMQP solution.
Registering new queues
Queueing events
Consuming your queue
Create new entity
If you have created a new entity and want to map it to a database you must create a xml in src/Infrastructure/Persistence/Doctrine/Mapping . It must be named so as to indicate where exactly the entity to be mapped is located.
Binding of interfaces/Registry global objects
To register a dependency or create a single configured global instance, you need to go to config/container.php
Mapping database data to custom objects
To map data from a database to a custom object you need to extend something from Doctrine/DBAL/Types .
After extending, you need to add a note in the xml that you are mapping a field to an object.
Finally, you must add the new type in config/container.php where doctrine is configured
Database migrations
To manage database migrations, the doctrine/migrations package is used.
The mapping is done using a yaml which maps your entities from the domain to a structure in the database . If you change something in yaml, you can use the commands below to generate a migration based on the difference.
Swoole
To use swoole, just set DOCKER_TARGET_APP=swoole
in .env and rebuild the application container.
Documentations
Learn more at these links:
All versions of slim4-boirlerplate with dependencies
ext-json Version *
ext-pcntl Version *
ext-sockets Version *
awurth/slim-validation Version ^5.0
doctrine/data-fixtures Version ^1.6
doctrine/migrations Version ^3.6
doctrine/orm Version ^2.15
fakerphp/faker Version ^1.23
laminas/laminas-diactoros Version ^3.3
lcobucci/clock Version ^3.1
monolog/monolog Version ^2.8
peppeocchi/php-cron-scheduler Version ^4.0
php-amqplib/php-amqplib Version ^3.2
php-di/php-di Version ^7.0
php-di/slim-bridge Version ^3.4
predis/predis Version ^2.2
ramsey/uuid Version ^4.7
slim/psr7 Version ^1.5
slim/slim Version ^4.10
slim/twig-view Version ^3.3
swoole/ide-helper Version ^5.1
symfony/cache Version ^6.3
symfony/console Version ^6.3
symfony/doctrine-bridge Version ^6.3
symfony/finder Version ^6.3
symfony/yaml Version ^6.2
thecodingmachine/safe Version ^2.5
vlucas/phpdotenv Version ^5.5
zircote/swagger-php Version ^4.7