formers / former

A powerful form builder, for Laravel and other frameworks (stand-alone too)
https://formers.github.io/former/
1.34k stars 204 forks source link

How to use as a standalone PHP #611

Closed anjalitechn closed 1 year ago

anjalitechn commented 1 year ago

When using as standalone application without laravel It is giving error Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Routing\RouteCollectionInterface] is not instantiable while building [Illuminate\Routing\UrlGenerator]

anjalitechn commented 1 year ago

hi @claar can you please help.

claar commented 1 year ago

Hi @anjalitechn - I'm sorry, but I'm not able to offer general tech support for this package at this time. If you're able to get to the root of the problem, I'd be happy to review any Pull Request you'd like to create to solve this issue for the community.

aleemb commented 5 months ago

@claar 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.