Today all methods created using Slim are within index.php, however, this makes it very large and difficult to manage.
Is it possible to separate the methods in other files and call them within the main structure?
Like the example below:
<?php
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;
require __DIR__ . '/../vendor/autoload.php';
$app = AppFactory::create();
$app->get('/hello/{name}', function (Request $request, Response $response, array $args) {
$name = $args['name'];
$response->getBody()->write("Hello, $name");
return $response;
});
require_once './customers/methods.php';
require_once './sales/methods.php';
require_once './city/methods.php';
$app->run();