Using the "jasny/sso" package, I get the following error:
IlluminateContractsContainerBindingResolutionException Unresolvable dependency resolving [Parameter #0 [ <required> callable $getBrokerInfo ]] in class JasnySSOServerServer
JasnySSOServerServer.php Internal:
/** * Class constructor. * * @phpstan-param callable(string):?array{secret:string,domains:string[]} $getBrokerInfo * @phpstan-param CacheInterface $cache */ public function __construct(callable $getBrokerInfo, CacheInterface $cache) { $this->getBrokerInfo = Closure::fromCallable($getBrokerInfo); $this->cache = $cache; $this->logger = new NullLogger(); $this->session = new GlobalSession(); }
I also tried:
php artisan route:clear composer dump-autoload php artisan optimize:clear
Can anyone point out the problem here?
Since jasny/sso is not a Laravel package, it should not be registered with the container without a specific set of instructions on how to instantiate it based on its constructor.
Add the following code in the
register()
method ofAppServiceProvider
:From there you can do the following from anywhere in the application:
It will automatically populate the constructor with the callable and CacheInterface we set in the binding (if you only need a single instance, you can also use
$app->singleton()
instead of the binding ) This class exists throughout the execution of the script).Generally anything you register into the container will be affected by Laravel's dependency injection, so you can't use unknown types in the constructor because Laravel has no way of knowing what the
callable
is and that will happen This error occurs when this is the case.Typically, if you have control over this, you can remove the callable function from the constructor and use a setter on the class.