Skip to content

Commit 5a1ea85

Browse files
committed
Added method, which set empty request for console. Fix for ide-helper work and other packages which work in console, and needed request object
1 parent 1953356 commit 5a1ea85

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

core/src/Console.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use Illuminate\Contracts\Container\Container;
55
use Illuminate\Contracts\Events\Dispatcher;
66
use Illuminate\Console\Events;
7+
use Illuminate\Http\Request;
78
use Symfony\Component\Console\Application as SymfonyApplication;
89

910
class Console extends Artisan
@@ -18,7 +19,7 @@ public function __construct(Container $laravel, Dispatcher $events, $version)
1819
$this->events = $events;
1920
$this->setAutoExit(false);
2021
$this->setCatchExceptions(false);
21-
22+
$this->SetRequestForConsole();
2223
$this->events->dispatch(new Events\ArtisanStarting($this));
2324

2425
$laravel->loadDeferredProviders();
@@ -33,4 +34,24 @@ protected function getDefaultInputDefinition()
3334
{
3435
return SymfonyApplication::getDefaultInputDefinition();
3536
}
37+
38+
private function SetRequestForConsole()
39+
{
40+
$uri = evo()->getConfig('site_url');
41+
42+
$components = parse_url($uri);
43+
44+
$server = $_SERVER;
45+
46+
if (isset($components['path'])) {
47+
$server = array_merge($server, [
48+
'SCRIPT_FILENAME' => $components['path'],
49+
'SCRIPT_NAME' => $components['path'],
50+
]);
51+
}
52+
53+
evo()->instance('request', Request::create(
54+
$uri, 'GET', [], [], [], $server
55+
));
56+
}
3657
}

0 commit comments

Comments
 (0)