Context that caused this eror
When working with laravel 5, have you ever ask yourself that how Laravel IOC work, how Laravel IOC can handle concrete class binding instead of defining in somewhere (for laravel in Service providers).
Basically, if you inject a concrete class to another class, it will automatically bind to that class by laravel Container
Overview of Laravel Container (make, build, getDependencies, resolveClass (or nonClass))
By default, If you inject a concrete class to another class, its will automatically bind and resolve by Laravel container.
but, in case in the constructor of some class you inject to a string or non-class parameter, how laravel 5 handle this https://github.com/laravel/framework/blob/5.2/src/Illuminate/Container/Container.php#L793
Its not acceptable that throw an error if a non-class cannot resolveable, but its not make sense to make a function name resolveNonClass just only throw an error (imo, should handle this 😉
$dependencies = $this->resolveNonClass($parameter);
There is many ways to deal with this is that writing an service provider to inject a string to another class like this (basically, a service provider abstract class contains $app instance, just bind a dependency manually into it). This is one way
class FooProvider extends ServiceProvider
public function register()
return new FooService('a','b');
then register above service provider to config/app.php
'provider' => [
its works!!!, other way to bypass this, is use Str provider class instead of built in string primitive php type.
By the way, need to update Laravel Container class to deal with primitive type ??? in this function resolveNonClass https://github.com/laravel/framework/blob/5.2/src/Illuminate/Container/Container.php#L823