A simple skeleton to build api's based on the chubbyphp-framework.
- php: ^8.1
- chubbyphp/chubbyphp-clean-directories: ^1.3.1
- chubbyphp/chubbyphp-cors: ^1.5
- chubbyphp/chubbyphp-decode-encode: ^1.1
- chubbyphp/chubbyphp-framework: ^5.1.1
- chubbyphp/chubbyphp-framework-router-fastroute: ^2.1
- chubbyphp/chubbyphp-http-exception: ^1.1
- chubbyphp/chubbyphp-laminas-config: ^1.4
- chubbyphp/chubbyphp-laminas-config-doctrine: ^2.2
- chubbyphp/chubbyphp-laminas-config-factory: ^1.3
- chubbyphp/chubbyphp-negotiation: ^2.0
- chubbyphp/chubbyphp-parsing: ^1.1.1
- doctrine/orm: ^2.17.2
- monolog/monolog: ^3.5
- ramsey/uuid: ^4.7.5
- slim/psr7: ^1.6.1
- symfony/console: ^6.4.2
Add the following environment variable to your system, for example within ~/.bash_aliases
:
export USER_ID=$(id -u)
export GROUP_ID=$(id -g)
docker-compose up -d
docker-compose exec php bash
composer install
composer setup:dev
- GET https://localhost/api/pets?sort[name]=asc
- POST https://localhost/api/pets
- GET https://localhost/api/pets/8ba9661b-ba7f-436b-bd25-c0606f911f7d
- PUT https://localhost/api/pets/8ba9661b-ba7f-436b-bd25-c0606f911f7d
- DELETE https://localhost/api/pets/8ba9661b-ba7f-436b-bd25-c0606f911f7d
- jdbc:postgresql://localhost:5432/petstore?user=root&password=root
Collections are sortable, filterable paginated lists of models.
A DTO, or Data Transfer Object, is a simple object used to transport data between software application components.
Middleware functions can execute code, make changes to the request and response objects. Middleware can generally be added globally or on a per-route basis.
Models, entities, documents what ever fits your purpose the best.
ORM Mapping definitions.
Parses and validates data against predefined schemas, ensuring that incoming data conforms to expected structures and criteria.
Repositories get data from storages like databases, elasticsearch, redis or whereever your models are stored or cached.
RequestHandler alias Controller, or Controller actions to be more precise. There is a directory with generic crud controllers. If you like the idea adapt them for your generic use case, if not drop them. I highly recommend to not extend them.
Service factories are the glue code of the dependeny injection container.
2024 Dominik Zogg