Skip to content

Enrikerf/symfonyApiKerf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example of Symfony API REST

using openApi and hexagonal architecture

For didactic reasons it has been the autogenerated openapi bundle inside the project, we should make another repo and install it in this repository with de composer

docker composer take php-fpm, nginx images from my dockerhub if you want to see the implementation goes to the github repository

Set UP

assuming you have docker installed

docker-compose -f dev-docker-compose.yml up

run bash of the php-fpm container and run

composer install

to run Unitary tests

./vendor/phpunit/phpunit/phpunit tests/Unitary --testdox

you could import in Postman the integration test with the postman environment

Code organization

The code organization it has be taken from: Get Your Hands Dirty on Clean Architecture by Tom Hombergs

  • /app

    • src
      • Adapter
      • Application
      • Domain
    • var
      • app.db --> sqlite database will be created in this folder on setup
    • tests
      • Unitary
        • Adapter
        • Application
        • Domain
  • dev-docker-compose.yml

  • docker-compose.yml

  • openapi.yaml

Centering the attention on the hexagonal architecture

  • Adapter
    • in --> in adapters
      • Api
        • Handler --> handler of the controllers of openapi bundle
        • openapi-issue-tracker-bundle --> autogerated from openapi
    • out -->
      • Persistence
      • Serializer
  • Application
    • Model --> generic models of Application layer
    • Port
      • in
        • USE_CASES_FOLDERS
      • out
        • INTERFACES_OF_OUT_ADAPTERS
    • Service --> service available from outside of application to execute Use cases
  • Domain
    • DOMAIN_MODEL_FOLDERS

Architectural decisions

autogenerated bundle for web API adapter

Mapping

  • AdapterIn-Application
    • two way mapping strategy in modifying use cases
      • Web Model autogenerated in openapi
      • command in UseCase interface
      • Transform Command to Domain Model in useCase service implementation
  • Application-Domain
    • two way mapping strategy in modifying use cases
  • Domain-AdapterOut
    • two way mapping strategy in modifying use cases

About

Hexagonal architecture example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published