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

Hard coupling of Console (and indirectly Eloquent) on the framework #44849

Closed
wouterj opened this issue Nov 5, 2022 · 2 comments
Closed

Hard coupling of Console (and indirectly Eloquent) on the framework #44849

wouterj opened this issue Nov 5, 2022 · 2 comments

Comments

@wouterj
Copy link
Contributor

wouterj commented Nov 5, 2022

  • Laravel Version: 9.21.0+
  • PHP Version: n/a (but for the sake of completness: 8.1.12)
  • Database Driver & Version: n/a

Description:

As you might know, I'm maintaining (on low pace) an Eloquent bundle for Symfony. The recent releases (Laravel 7/8/9) have been an incredibly smooth ride, thanks for your hard work!
However, the console output restyling (#43065) introduced the use of the resolve() function in the Console component, creating a hard dependency between the component and the framework.

This hard dependency has been identified before, as it also broke Lumen. Since #43312 , it uses the app() function. While no longer having a hard dependency on the full framework, this still makes it impossible to use the Console component (and indirectly Eloquent's Migrator class) outside of the framework.

Relevant code:

protected function mutate($data, $mutators)
{
foreach ($mutators as $mutator) {
if (is_iterable($data)) {
foreach ($data as $key => $value) {
$data[$key] = app($mutator)->__invoke($value);
}
} else {
$data = app($mutator)->__invoke($data);
}
}
return $data;
}

My bundle already has some plumbing to work around Seeder::resolve(). I'm not too happy about it, but it is acceptable given creating decoupled components isn't your top priority (and I'm probably one of a few weirdo's attempting this). However, this newly used function makes it a lot harder to work around. I currently believe the best solution is to fully reimplement all illuminate/console's components to make this work: wouterj/WouterJEloquentBundle@b2276e9 This is very fragile, given it breaks whenever you introduce a new cool component.

Is this coupling expected (and should I perhaps reconsider my bundle)? Or can there be something done in the console package to make it possible to work around this (without the need to reimplement critical components like Task)?
I don't know much about Laravel's internals, but I'm happy to work together with you to make sure Eloquent remains usable outside the Laravel framework if you wish.

@henzeb
Copy link
Contributor

henzeb commented Nov 5, 2022

I hook in on this as I have a package that may get affected by this if anything gets rewritten as I have some plumbing in there as well.
https://packagist.org/packages/henzeb/laravel-console-facade

@driesvints
Copy link
Member

Thanks @wouterj. I've sent in a PR to remove these app calls since they're not necessary. Let us know how that looks: #44864

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

No branches or pull requests

3 participants