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

Doesn't work on PHP8+ for standalone (non-laravel) apps #614

Open
aleemb opened this issue Mar 22, 2024 · 2 comments
Open

Doesn't work on PHP8+ for standalone (non-laravel) apps #614

aleemb opened this issue Mar 22, 2024 · 2 comments
Labels

Comments

@aleemb
Copy link

aleemb commented Mar 22, 2024

(new issue since #611 is stale)

Former is broken on PHP8+ standalone installs and throws the error:

Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Routing\RouteCollectionInterface] is not instantiable while building [Illuminate\Routing\UrlGenerator]

I found the quick fix is as follows, however, I am not familiar with the framework to do this proper. The fix that works for me is inside FormerServicesProvider.php I add the following in bindCoreClasses under the Core Classes comment:

	$app->bindIf(
		\Illuminate\Routing\RouteCollectionInterface::class,
		\Illuminate\Routing\RouteCollection::class
	);

Trying $app->bindIf('routing', \Illuminate\Routing\RouteCollection::class); didn't work, however.

Hope this can be fixed in the repo so Former can once again be used outside of Laravel (when using PHP8+). This is the only thing preventing that use-case right now for anyone using it outside of Laravel, myself included.

@stayallive
Copy link
Contributor

You mention outside Laravel but it looks like you are still using Illuminate components.

Can you share bit more of the stacktrace so we know what Former code specifically catches this?

I doubt this has anything to do with the PHP version though, would assume this behaves the same on every PHP version and if this works on other versions it's because other dependency versions have changes.

@stayallive stayallive added the Bug label Mar 22, 2024
@ehsanquddusi
Copy link

ehsanquddusi commented Oct 15, 2024

Facing same issue while using this library outside Laravel with CodeIgniter. I am also using some Illuminate libraries including illuminate/database, illuminate/view on v11. Here is the error I am getting.

This error is generated on both 4.* & 5.* versions of Former library. Works fine on PHP 7.4 but generates this error on PHP 8.2

image

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

No branches or pull requests

3 participants