Skip to content

Commit 57d36bb

Browse files
Merge pull request dingo#1630 from specialtactics/chore/route-caching
Revert changes to not getting a fresh app based on feedback in PR dingo#1629
2 parents 323c7c8 + 398b461 commit 57d36bb

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

src/Console/Command/Cache.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,15 @@ public function handle()
7171
{
7272
$this->callSilent('route:clear');
7373

74+
$app = $this->getFreshApplication();
75+
7476
$this->call('route:cache');
7577

76-
$routes = $this->router->getAdapterRoutes();
78+
$routes = $app['api.router']->getAdapterRoutes();
7779

7880
foreach ($routes as $collection) {
7981
foreach ($collection as $route) {
80-
$this->adapter->prepareRouteForSerialization($route);
82+
$app['api.router.adapter']->prepareRouteForSerialization($route);
8183
}
8284
}
8385

@@ -93,4 +95,22 @@ public function handle()
9395
str_replace('{{routes}}', base64_encode(serialize($routes)), $stub)
9496
);
9597
}
98+
99+
/**
100+
* Get a fresh application instance.
101+
*
102+
* @return \Illuminate\Contracts\Container\Container
103+
*/
104+
protected function getFreshApplication()
105+
{
106+
if (method_exists($this->laravel, 'bootstrapPath')) {
107+
$app = require $this->laravel->bootstrapPath().'/app.php';
108+
} else {
109+
$app = require $this->laravel->basePath().'/bootstrap/app.php';
110+
}
111+
112+
$app->make(Kernel::class)->bootstrap();
113+
114+
return $app;
115+
}
96116
}

0 commit comments

Comments
 (0)