Improving my bootstrap class (MVC) I need feedback on my Bootstrap for the MVC architecture that I follow.
I load the routes via yaml. Here is an example:

feed:
    path: /{controller}/{action}{slash}
    requirements:
        id: "[1-9][0-9]*"
        slash: "[/]{0,1}"
    methods: [GET,POST]

#Explore Controller
explore:
    path: /{controller}{slash}
    requirements:
        id: "[1-9][0-9]*"
        slash: "[/]{0,1}"
    methods: [GET,POST]


And here is my Bootstrap class:

class Bootstrap
{

    public function __construct()
    {
        $request = Request::createFromGlobals();
        $locator = new FileLocator(__DIR__ . '/../../../config');

        // DI container
        $container = new DependencyInjection\ContainerBuilder;

        $loader = new DependencyInjection\Loader\YamlFileLoader($container, $locator);
        $loader-&gt;load('config-development.yml');

        $container-&gt;compile();

        // routing
        $loader = new Routing\Loader\YamlFileLoader($locator);
        $context = new Routing\RequestContext();
        $context-&gt;fromRequest($request);
        $matcher = new Routing\Matcher\UrlMatcher(
            $loader-&gt;load('routing.yml'),
            $context
        );

        try{
            $parameters = $matcher-&gt;match($request-&gt;getPathInfo());

            foreach ($parameters as $key =&gt; $value) {
                $request-&gt;attributes-&gt;set($key, $value);
            }

            $command = $request-&gt;getMethod() . $request-&gt;get('action');
            $resource = "controller.{$request-&gt;get('controller')}";

            $controller = $container-&gt;get($resource);
            $data = $controller-&gt;{$command}($request);

        }catch(\Error $e){
            $data = [
                'status'=&gt;404,
                'message'=&gt;'Not found',
                'info'=&gt;$e-&gt;getMessage()
            ];
        }catch(\Symfony\Component\Routing\Exception\MethodNotAllowedException $e){
            $data = [
                'status'=&gt;404,
                'message'=&gt;'Not found',
                'info'=&gt;$e-&gt;getMessage()
            ];
        }catch(ResourceNotFoundException $e){
            $data = [
                'status'=&gt;404,
                'message'=&gt;'Not found',
                'info'=&gt;$e-&gt;getMessage()
            ];
        }


        if(is_array($data)){
            $response = new JsonResponse($data);
        }else{
            $response = new Response($data);
        }

        //Set cors headers
        $response-&gt;headers-&gt;set('Access-Control-Allow-Origin', '*');
        $response-&gt;headers-&gt;set('Access-Control-Allow-Methods', 'GET,HEAD,OPTIONS,POST,PUT,DELETE');
        $response-&gt;headers-&gt;set('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization');
        $response-&gt;headers-&gt;set('Access-Control-Allow-Credentials', 'true');

        $response-&gt;send();
    }


I load the controllers and services via yaml. I'm interested if you would change anything and if you see any possible issues that this kind of structure might have.

I'm seeking for improvements in my code.
Disclaimer: I haven't really used YAMLFileLoader but the advice should apply for the sake of improving PHP code.
Catching Exceptions
I would consolidate the exception catching, since apparently the value of $data is always the same (other than the fact that the info value is assigned the exception message). Unless the goal is to only catch \Symfony\Component\Routing\Exception\MethodNotAllowedException and ResourceNotFoundException instances, why not just catch all Exception instances? Something like this:
catch(\Throwable $e){
    $data = [
        'status'=&gt;404,
        'message'=&gt;'Not found',
        'info'=&gt;$e-&gt;getMessage()
    ];
}

And for the sake of D.R.Y. code, you could abstract setting $data in those exception handling blocks to a separate method that returns that array. Something like:
function GetFallbackDataForException(Throwable $e) {
    return [
        'status'=&gt;404,
        'message'=&gt;'Not found',
        'info'=&gt;$e-&gt;getMessage()
    ];
}

I hadn't learned until testing out this code but an Error can be thrown and caught - I thought that was only possible with instances of Exception but both implement Throwable...ergo...
Method length
The method is quite long - especially considering it is a constructor. It would be advisable to break up the pieces into separate methods - e.g. one to create the request, one to take the return value from the request and send the response, etc. That way the constructor can be shorter as it calls those methods, plus those methods would hopefully lend themselves to unit testing each component of the process.
I considered suggesting that the foreach to set attributes be replaced with a call to array_walk() but that might require flipping the array keys and values, making a Callable out of the method, etc. all to save 1-2 lines...