Created
January 13, 2020 15:51
-
-
Save thepsion5/2a622dc88836854e68f9f63d6ee578bc to your computer and use it in GitHub Desktop.
Example of Autoloading In a Legacy PHP Application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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