petstore
Description
A simple skeleton to build api's based on the chubbyphp-framework.
Requirements
- php: ^8.0
- chubbyphp/chubbyphp-api-http: ^5.0.1
- chubbyphp/chubbyphp-clean-directories: ^1.2
- chubbyphp/chubbyphp-cors: ^1.4
- chubbyphp/chubbyphp-decode-encode: ^1.0.1
- chubbyphp/chubbyphp-deserialization: ^3.5.1
- chubbyphp/chubbyphp-framework: ^5.0.1
- chubbyphp/chubbyphp-framework-router-fastroute: ^2.0
- chubbyphp/chubbyphp-http-exception: ^1.0.1
- chubbyphp/chubbyphp-laminas-config: ^1.3
- chubbyphp/chubbyphp-laminas-config-doctrine: ^2.0
- chubbyphp/chubbyphp-laminas-config-factory: ^1.2
- chubbyphp/chubbyphp-negotiation: ^1.9
- chubbyphp/chubbyphp-serialization: ^3.3.1
- chubbyphp/chubbyphp-validation: ^3.12.3
- doctrine/orm: ^2.13.1
- monolog/monolog: ^2.3.5
- ramsey/uuid: ^4.2.3
- slim/psr7: ^1.5
- symfony/console: ^5.4.11|^6.1.3
Environment
Add the following environment variable to your system, for example within ~/.bash_aliases
:
export USER_ID=$(id -u)
export GROUP_ID=$(id -g)
Docker
docker-compose up -d
docker-compose exec php bash
Urls
Pet
- 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
DBs
- jdbc:postgresql://localhost:5432/petstore?user=root&password=root
Installation
Through Composer as chubbyphp/petstore.
composer create-project chubbyphp/petstore myproject "dev-chubbyphp"
Setup
composer setup:dev
Structure
Collection
Collections are sortable, filterable paginated lists of models.
Factory
Factories to create collections, model or whatever you need to be created.
Mapping
Mappings are used for deserialization, orm, serialization and validation defintions. They are all done in PHP.
Model
Models, entities, documents what ever fits your purpose the best.
Repository
Repositories get data from storages like databases, elasticsearch, redis or whereever your models are stored or cached.
RequestHandler
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.
ServiceFactory
Service factories are the glue code of the dependeny injection container.
Copyright
Dominik Zogg 2022