Skip to content

Commit e099b7b

Browse files
author
Ben Thomson
committed
Move autoloading to index to make it the same as Laravel 6.
Implements work done in octobercms/october#4280. Credit to @Samuell1
1 parent 9ecad13 commit e099b7b

5 files changed

Lines changed: 66 additions & 73 deletions

File tree

artisan

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
#!/usr/bin/env php
22
<?php
33

4+
define('LARAVEL_START', microtime(true));
5+
6+
/*
7+
|--------------------------------------------------------------------------
8+
| Register Core Helpers
9+
|--------------------------------------------------------------------------
10+
|
11+
| We cannot rely on Composer's load order when calculating the weight of
12+
| each package. This line ensures that the core global helpers are
13+
| always given priority one status.
14+
|
15+
*/
16+
17+
$helperPath = __DIR__.'/vendor/october/rain/src/Support/helpers.php';
18+
19+
if (!file_exists($helperPath)) {
20+
echo 'Missing vendor files, try running "composer install" or use the Wizard installer.'.PHP_EOL;
21+
exit(1);
22+
}
23+
24+
require $helperPath;
25+
426
/*
527
|--------------------------------------------------------------------------
628
| Register The Auto Loader
@@ -13,7 +35,7 @@
1335
|
1436
*/
1537

16-
require __DIR__.'/bootstrap/autoload.php';
38+
require __DIR__.'/vendor/autoload.php';
1739

1840
$app = require_once __DIR__.'/bootstrap/app.php';
1941

@@ -28,7 +50,7 @@ $app = require_once __DIR__.'/bootstrap/app.php';
2850
|
2951
*/
3052

31-
$kernel = $app->make('Illuminate\Contracts\Console\Kernel');
53+
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
3254

3355
$status = $kernel->handle(
3456
$input = new Symfony\Component\Console\Input\ArgvInput,
@@ -48,4 +70,4 @@ $status = $kernel->handle(
4870

4971
$kernel->terminate($input, $status);
5072

51-
exit($status);
73+
exit($status);

bootstrap/autoload.php

Lines changed: 0 additions & 54 deletions
This file was deleted.

index.php

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,69 @@
66
* @author Alexey Bobkov, Samuel Georges
77
*/
88

9+
define('LARAVEL_START', microtime(true));
10+
11+
/*
12+
|--------------------------------------------------------------------------
13+
| Register Core Helpers
14+
|--------------------------------------------------------------------------
15+
|
16+
| We cannot rely on Composer's load order when calculating the weight of
17+
| each package. This line ensures that the core global helpers are
18+
| always given priority one status.
19+
|
20+
*/
21+
22+
$helperPath = __DIR__.'/vendor/october/rain/src/Support/helpers.php';
23+
24+
if (!file_exists($helperPath)) {
25+
echo 'Missing vendor files, try running "composer install" or use the Wizard installer.'.PHP_EOL;
26+
exit(1);
27+
}
28+
29+
require $helperPath;
30+
931
/*
1032
|--------------------------------------------------------------------------
11-
| Register composer
33+
| Register The Auto Loader
1234
|--------------------------------------------------------------------------
1335
|
14-
| Composer provides a generated class loader for the application.
36+
| Composer provides a convenient, automatically generated class loader for
37+
| our application. We just need to utilize it! We'll simply require it
38+
| into the script here so that we don't have to worry about manual
39+
| loading any of our classes later on. It feels great to relax.
1540
|
1641
*/
1742

18-
require __DIR__.'/bootstrap/autoload.php';
43+
require __DIR__.'/vendor/autoload.php';
1944

2045
/*
2146
|--------------------------------------------------------------------------
22-
| Load framework
47+
| Turn On The Lights
2348
|--------------------------------------------------------------------------
2449
|
25-
| This bootstraps the framework and loads up this application.
50+
| We need to illuminate PHP development, so let us turn on the lights.
51+
| This bootstraps the framework and gets it ready for use, then it
52+
| will load up this application so that we can run it and send
53+
| the responses back to the browser and delight our users.
2654
|
2755
*/
2856

2957
$app = require_once __DIR__.'/bootstrap/app.php';
3058

3159
/*
3260
|--------------------------------------------------------------------------
33-
| Process request
61+
| Run The Application
3462
|--------------------------------------------------------------------------
3563
|
36-
| Execute the request and send the response back to the client.
64+
| Once we have the application, we can handle the incoming request
65+
| through the kernel, and send the associated response back to
66+
| the client's browser allowing them to enjoy the creative
67+
| and wonderful application we have prepared for them.
3768
|
3869
*/
3970

40-
$kernel = $app->make('Illuminate\Contracts\Http\Kernel');
71+
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
4172

4273
$response = $kernel->handle(
4374
$request = Illuminate\Http\Request::capture()

tests/bootstrap.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
<?php
2-
3-
/*
4-
* October autoloader
5-
*/
6-
require __DIR__ . '/../bootstrap/autoload.php';
7-
82
/*
93
* Fallback autoloader
104
*/

tests/functional/phpunit.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit backupGlobals="false"
33
backupStaticAttributes="false"
4-
bootstrap="../../bootstrap/autoload.php"
4+
bootstrap="../../vendor/autoload.php"
55
colors="true"
66
convertErrorsToExceptions="true"
77
convertNoticesToExceptions="true"
@@ -15,4 +15,4 @@
1515
<directory>./</directory>
1616
</testsuite>
1717
</testsuites>
18-
</phpunit>
18+
</phpunit>

0 commit comments

Comments
 (0)