Move autoloading to index to make it the same as Laravel 6.

Implements work done in https://github.com/octobercms/october/pull/4280.

Credit to @Samuell1
This commit is contained in:
Ben Thomson 2020-01-20 14:33:14 +08:00
parent 9ecad139c4
commit e099b7bdee
5 changed files with 66 additions and 73 deletions

28
artisan
View File

@ -1,6 +1,28 @@
#!/usr/bin/env php
<?php
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register Core Helpers
|--------------------------------------------------------------------------
|
| We cannot rely on Composer's load order when calculating the weight of
| each package. This line ensures that the core global helpers are
| always given priority one status.
|
*/
$helperPath = __DIR__.'/vendor/october/rain/src/Support/helpers.php';
if (!file_exists($helperPath)) {
echo 'Missing vendor files, try running "composer install" or use the Wizard installer.'.PHP_EOL;
exit(1);
}
require $helperPath;
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
@ -13,7 +35,7 @@
|
*/
require __DIR__.'/bootstrap/autoload.php';
require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
@ -28,7 +50,7 @@ $app = require_once __DIR__.'/bootstrap/app.php';
|
*/
$kernel = $app->make('Illuminate\Contracts\Console\Kernel');
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$status = $kernel->handle(
$input = new Symfony\Component\Console\Input\ArgvInput,
@ -48,4 +70,4 @@ $status = $kernel->handle(
$kernel->terminate($input, $status);
exit($status);
exit($status);

View File

@ -1,54 +0,0 @@
<?php
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register Core Helpers
|--------------------------------------------------------------------------
|
| We cannot rely on Composer's load order when calculating the weight of
| each package. This line ensures that the core global helpers are
| always given priority one status.
|
*/
$helperPath = __DIR__.'/../vendor/october/rain/src/Support/helpers.php';
if (!file_exists($helperPath)) {
echo 'Missing vendor files, try running "composer install" or use the Wizard installer.'.PHP_EOL;
exit(1);
}
require $helperPath;
/*
|--------------------------------------------------------------------------
| Register The Composer Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/
require __DIR__.'/../vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Include The Compiled Class File
|--------------------------------------------------------------------------
|
| To dramatically increase your application's performance, you may use a
| compiled class file which contains all of the classes commonly used
| by a request. The Artisan "optimize" is used to create this file.
|
*/
$compiledPath = __DIR__.'/../storage/framework/compiled.php';
if (file_exists($compiledPath)) {
require $compiledPath;
}

View File

@ -6,23 +6,51 @@
* @author Alexey Bobkov, Samuel Georges
*/
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register composer
| Register Core Helpers
|--------------------------------------------------------------------------
|
| Composer provides a generated class loader for the application.
| We cannot rely on Composer's load order when calculating the weight of
| each package. This line ensures that the core global helpers are
| always given priority one status.
|
*/
require __DIR__.'/bootstrap/autoload.php';
$helperPath = __DIR__.'/vendor/october/rain/src/Support/helpers.php';
if (!file_exists($helperPath)) {
echo 'Missing vendor files, try running "composer install" or use the Wizard installer.'.PHP_EOL;
exit(1);
}
require $helperPath;
/*
|--------------------------------------------------------------------------
| Load framework
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| This bootstraps the framework and loads up this application.
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/
require __DIR__.'/vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
@ -30,14 +58,17 @@ $app = require_once __DIR__.'/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Process request
| Run The Application
|--------------------------------------------------------------------------
|
| Execute the request and send the response back to the client.
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make('Illuminate\Contracts\Http\Kernel');
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()

View File

@ -1,10 +1,4 @@
<?php
/*
* October autoloader
*/
require __DIR__ . '/../bootstrap/autoload.php';
/*
* Fallback autoloader
*/

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="../../bootstrap/autoload.php"
bootstrap="../../vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
@ -15,4 +15,4 @@
<directory>./</directory>
</testsuite>
</testsuites>
</phpunit>
</phpunit>