Skip to content
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.8] Use application instead of container in console #27588

Closed
wants to merge 1 commit into from
Closed

[5.8] Use application instead of container in console #27588

wants to merge 1 commit into from

Conversation

seriquynh
Copy link
Contributor

#25241

Inside \Illuminate\Console\Application class:

  • The $laravel property is commented as a Laravel application and we currently use more functions than just a container.
  • The getLaravel method is also commented \Illuminate\Contracts\Foundation\Application as the return type.
  • The \Illuminate\Tests\Console\ConsoleApplicationTest uses console mock by injecting a Laravel application instead of container instance.

So, I just change a bit at \Illuminate\Console\Application constructor by injecting application instead of container. It will be more clearly for someone who wants to extend this class. For example, building a package.

@crynobone
Copy link
Member

This limit the usage to just Laravel Framework, when you use console with Lumen or without a framework this would break. 👎

@seriquynh
Copy link
Contributor Author

@crynobone Because it is a breaking change, I send to the branch 5.8. This version is unreleased.

@crynobone
Copy link
Member

So explain to me again how do Lumen use Illuminate\Console\Application starting from 5.8?

@seriquynh
Copy link
Contributor Author

seriquynh commented Feb 20, 2019

  • 5.8 is a major version. Such as all other breaking changes, a maintainer has to update his/her package for the next major version.
  • If this is accepted and there is a conflict with Lumen, Taylor Otwell or other Laravel members will apply this to Lumen and Lumen will be release v5.8 too.

Anyway, both in core framework and Lumen, the console application is also created by the same way.

// $this->app is \Illuminate\Contracts\Foundation\Application implementation.
if (is_null($this->artisan)) {
    return $this->artisan = (new Artisan($this->app, $this->app->make('events'), $this->app->version()))
                        ->resolveCommands($this->getCommands());
}

Sorry! I don't really understand your expectation.

@X-Coder264
Copy link
Contributor

@XuanQuynh

// $this->app is \Illuminate\Contracts\Foundation\Application implementation.

This isn't true. In Lumen $this->app is an instance of Laravel\Lumen\Application which as you can see here doesn't (and shouldn't) implement Illuminate\Contracts\Foundation\Application.

Besides, the Illuminate\Contracts\Foundation\Application interface (and its implementation) is too specific for the Laravel framework so it should be separated into smaller interfaces as discussed in #26477 and after some deprecation period be removed which means that all other services should rely only on the Container interface.

@seriquynh seriquynh closed this Feb 20, 2019
@seriquynh seriquynh deleted the change_console_application_constructor branch February 20, 2019 10:38
@seriquynh
Copy link
Contributor Author

@crynobone @X-Coder264 Thanks for correcting me with the helpful information!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants