I am making an application based on Slim Framework. I am following PSR 4 pattern. This application is basically dealing with RESTful services. To make it more flexible for future we have adopted to use a different approach than conventional slim coding. My Directory structure looks like below,
│ autoload.php
│ composer.json
│ index.php
│ README.md
│
└───src
└───Service
├───Component
│ ├───Router
│ │ Route.php
│ │ RouterInterface.php
│ │
│ └───YamlLoader
│ YamlLoader.php
│ YamlLoaderInterface.php
│
├───Core
│ Bootstrap.php
│ Settings.php
│
├───Framework
│ ├───Controller
│ │ HomeController.php
│ │
│ ├───Model
│ └───View
└───Routing
course.routing.yml
home.routing.yml
In the "Routing" directory I will store some yaml files with the menu links. Those will be parsed in the Router Component to generate proper callable path to controllers and it's methods.
However, the problem I am facing is to determine which will be a good way to do so? How can I assign each router items from the .yml files and use them as
$app->map('/about', '\Service\Framework\Controller\HomeController:about')->via('GET', 'POST');
For further references, one of the yaml file looks like,
service.about:
path: '/about'
handler:
_controller: '\Service\Framework\Controller\HomeController::about',
http_method: GET
service.authenticate:
path: '/auth'
handler:
_controller: 'Service\Framework\HomeController::auth',
http_method: GET
What will be a good and efficient way? Please suggest.