Skip to content

Instantly share code, notes, and snippets.

@thepsion5
Created January 13, 2020 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thepsion5/2a622dc88836854e68f9f63d6ee578bc to your computer and use it in GitHub Desktop.
Save thepsion5/2a622dc88836854e68f9f63d6ee578bc to your computer and use it in GitHub Desktop.
Example of Autoloading In a Legacy PHP Application
<?php
//FILE LOCATION: project-directory/config/bootstrap.php
declare(strict_types=1);
//Composer autoloader file
require_once __DIR__ . '/../vendor/autoload.php';
error_reporting(E_ALL | E_NOTICE);
//Load the files required for configuration
$configuration = require __DIR__ . '/settings.php';
$countyList = require __DIR__ . '/../vendor/some-other-package/list-of-tennessee-counties.php';
$app = \App\Application::createFromConfig($config, $counties);
unset($configuration, $counties);
return $app;
<?php
//FILE LOCATION: project-directory/public/index.php
declare(strict_types=1);
$app = require_once __DIR__ . '/../config/bootstrap.php';
/* route handling code here */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment