-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.0] Illuminate\Foundation\Artisan is no longer needed in after the HTTP Kernel refactors. #6178
[5.0] Illuminate\Foundation\Artisan is no longer needed in after the HTTP Kernel refactors. #6178
Conversation
👍 Nice. :) |
I'm not sure if this is the right solution because calling
from inside a controller now returns
|
@bart I would argue that using Artisan command from within a controller is a hack and (personally feel) at some point should be stopped. You should actually using the Why is the code failing? because MigrationServiceProvider is deferred, and only inside console environment does all deferred service provider is preloaded. |
@crynobone Thanks a lot for your explanation. I already figured out that the ServiceProvider doesn't load the migrate command. So using |
@bart the trick with |
And that means calling Artisan::call() from inside a controller wouldn't be possible anymore for non-default (registered) Artisan command, right? It's no problem as long as you can call things directloy by class methods. But it was a fancy simple way which will be lost. Not a big thing but a fact people, who are switching to L5, should know. What do you think? |
Could you please give an example how to call a command (migrate --seed) from a controller now? Didn't really get it :( |
$app = app();
$app->make('DatabaseSeeder')->setContainer($app)->run(); |
Hmm I think I will wait for a comment of @taylorotwell. Maybe he won't kick the Sorry for these questions. I know it's not a support forum but really want to know how to do it now and in future. |
What is so hard with: $app = app();
$migrator = $app->make('migrator'); // Illuminate\Database\Migrations\Migrator
$migrator->run($app->databasePath().'/migrations'); Or go with the hackish way (should work in theory): App::loadDeferredProviders();
Artisan::call('migrate', ['--seed' => true]); |
Nothing. It simply is more than First sentence of Laravel Philosophy: Laravel is a web application framework with expressive, elegant syntax. Maybe this elegant syntax will be lost in some parts with L5 which would be a real pity. |
505d03f
to
db577cd
Compare
When I'm calling
|
|
@bart Please continue this on the forums. |
For sure I will and just for your information @crynobone: It's still not working:
My current solution is running the migrate command using Symfonys Process class. |
@@ -41,6 +41,8 @@ public function __construct(LaravelApplication $laravel, Dispatcher $events) | |||
$this->laravel = $laravel; | |||
$this->setAutoExit(false); | |||
|
|||
$this->laravel->loadDeferredProviders(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Latest commit show that @taylorotwell explicitly load deferred providers from within Illuminate\Foundation\Console\Kernel
, so I'm not sure if this still relevant (only useful if Laravel still want to support calling "artisan" from non-console environment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After discussion with @taylorotwell on irc, he said to removed this line. Latest commit contain rebased on solve a merge conflict in console kernel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which means that the hacky way using Artisan:call() won't be supported in L5 anymore. Nice to know. Thanks sir!
bc5b04c
to
bd75489
Compare
…HTTP Kernel refactors. Signed-off-by: crynobone <[email protected]>
bd75489
to
ce19636
Compare
@taylorotwell Without this patch, my test suites are broken for some of my laravel 5 branches: https://travis-ci.org/GrahamCampbell/Laravel-Core/jobs/39004380. |
@taylorotwell has made the change upstream. Now just need to remove the dead code in ArtisanServiceProvider. |
Signed-off-by: crynobone [email protected]