Advertisement
Foxxything

bootstrap.php

Jan 27th, 2023
866
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.39 KB | None | 0 0
  1. <?php
  2.   // Path: config\bootstrap.php
  3.  
  4.   use DI\ContainerBuilder;
  5.   use Slim\App;
  6.  
  7.   require_once __DIR__ . '/../vendor/autoload.php';
  8.  
  9.   /**
  10.    * @var ContainerBuilder $containerBuilder - The application container builder
  11.    */
  12.   $containerBuilder = new ContainerBuilder();
  13.  
  14.   // Add DI container definitions
  15.   $containerBuilder->addDefinitions(__DIR__ . '/container.php');
  16.  
  17.   // Create DI container instance
  18.   $container = $containerBuilder->build();
  19.  
  20.   // Create Slim App instance
  21.   $app = $container->get(App::class);
  22.  
  23.   if (!$container->get('settings')['debug']) {
  24.     /**
  25.      * To generate the route cache data, you need to set the file to one that does not exist in a writable directory.
  26.      * After the file is generated on first run, only read permissions for the file are required.
  27.      *
  28.      * You may need to generate this file in a development environment and comitting it to your project before deploying
  29.      * if you don't have write permissions for the directory where the cache file resides on the server it is being deployed to
  30.      */
  31.     $routeCollector = $app->getRouteCollector();
  32.     $routeCollector->setCacheFile(__DIR__ . '/Cache/RoauteCaching.php');
  33.   }
  34.  
  35.  
  36.   // Register routes
  37.   (require __DIR__ . '/routes.php')($app);
  38.  
  39.   // Register middleware
  40.   (require __DIR__ . '/middleware.php')($app);
  41.  
  42.   // Start PHP session
  43.   session_start();
  44.  
  45.   return $app;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement