Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

refactor: use afterResolving instead of Blade facade #97

Merged
merged 3 commits into from
Aug 27, 2021

Conversation

rinodrummer
Copy link
Contributor

I tried the package with Lumen and after configuring everything, I got this error:

Target class [blade.compiler] does not exist.

By googling, I found a link to this PR on laravel/framework and looking to the last commit and tried to include the $this-app->afterResolving() approach, that worked.

By the same googling session, I found a lot of suggestions about the use of ServiceProvider::boot() instead of ServiceProvider::register() when declaring singletons and Blade directives, so I moved replaced the registeringPackage() method with bootingPackage().

…gister the directives after resolving `blade.compiler`
@innocenzi
Copy link
Owner

I'm kind of conflicted with that PR.

First, the tests don't pass (but I think it's just a typing issue). I also have zero experience with Lumen, and I'm pretty sure it is slowly dying, so I don't really want to support it.

It seems that you would be able to make it work with Lumen by replacing the @vite directive with {{ vite_tags() }}. Is it correct?

That being said, the changes are not that much, so I think it's okay to merge if you fix the code so the tests pass.

@rinodrummer
Copy link
Contributor Author

Hi @innocenzi, I know that Lumen is dying, but I think that installing Laravel just for an API is a bit over-power.

Octane is amazing, but it seems like it doesn't work with Apache, so it cuts out a lot of applications made with it.

Yeah, {{ vite_tags() }} works too!

I think that it may bring even some optimizations for Laravel, so I'm glad that my PR will be accepted!

@rinodrummer rinodrummer reopened this Aug 26, 2021
if (! $entryName) {
return '<?php echo vite_tags() ?>';
}
$this->app->afterResolving('blade.compiler', function ($compiler) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you type-hint $compiler? You removed it in abd0100 but all was needed was to import it.

@innocenzi innocenzi changed the title Improved Lumen compatibility by registering Blade directives after resolving its compiler refactor: use afterResolving instead of Blade facade Aug 27, 2021
@innocenzi innocenzi merged commit 19468b7 into innocenzi:main Aug 27, 2021
@rinodrummer rinodrummer deleted the rinodrummer-patch-1 branch August 28, 2021 10:50
@callmez
Copy link

callmez commented Aug 28, 2021

afterResolving can't register in bootingPackages. related issue

innocenzi added a commit that referenced this pull request Aug 29, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants