Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

roeben's avatar

Target [] is not instantiable.

Hi,

I've got some troubles with a package I added with composer. I added https://packagist.org/packages/generationtux/jwt-artisan . On localhost everything seems to work, but on my productionserver I get an error:

production.ERROR: exception 'Illuminate\Contracts\Container\BindingResolutionException' with message 'Target [GenTux\Jwt\Drivers\JwtDriverInterface] is not instantiable.' in /home/ruben/apps/bootstrap/cache/compiled.php:1247

I added the following to my providers array in app.php:

GenTux\Jwt\Support\LaravelServiceProvider::class,

I even tried adding:

GenTux\Jwt\Drivers\JwtDriverInterface::class

But that made no difference. I ran composer update, composer dump-autoload and php artisan clear-compiled.

This is my full stacktrace:

[2015-10-02 10:40:27] production.ERROR: exception 'Illuminate\Contracts\Container\BindingResolutionException' with message 'Target [GenTux\Jwt\Drivers\JwtDriverInterface] is not instantiable.' in /home/ruben/apps/bootstrap/cache/compiled.php:1247
Stack trace:
#0 /home/ruben/apps/bootstrap/cache/compiled.php(1195): Illuminate\Container\Container->build('GenTux\\Jwt\\Driv...', Array)
#1 /home/ruben/apps/bootstrap/cache/compiled.php(1733): Illuminate\Container\Container->make('GenTux\\Jwt\\Driv...', Array)
#2 /home/ruben/apps/bootstrap/cache/compiled.php(1287): Illuminate\Foundation\Application->make('GenTux\\Jwt\\Driv...')
#3 /home/ruben/apps/bootstrap/cache/compiled.php(1271): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))
#4 /home/ruben/apps/bootstrap/cache/compiled.php(1257): Illuminate\Container\Container->getDependencies(Array, Array)
#5 /home/ruben/apps/bootstrap/cache/compiled.php(1195): Illuminate\Container\Container->build('GenTux\\Jwt\\JwtT...', Array)
#6 /home/ruben/apps/bootstrap/cache/compiled.php(1733): Illuminate\Container\Container->make('GenTux\\Jwt\\JwtT...', Array)
#7 /home/ruben/apps/bootstrap/cache/compiled.php(7107): Illuminate\Foundation\Application->make('GenTux\\Jwt\\JwtT...')
#8 /home/ruben/apps/bootstrap/cache/compiled.php(7100): Illuminate\Routing\ControllerDispatcher->resolveMethodDependencies(Array, Object(ReflectionMethod))
#9 /home/ruben/apps/bootstrap/cache/compiled.php(8834): Illuminate\Routing\ControllerDispatcher->resolveClassMethodDependencies(Array, Object(App\Http\Controllers\API\AuthenticateController), 'authenticate')
#10 /home/ruben/apps/bootstrap/cache/compiled.php(8815): Illuminate\Routing\ControllerDispatcher->call(Object(App\Http\Controllers\API\AuthenticateController), Object(Illuminate\Routing\Route), 'authenticate')
#11 [internal function]: Illuminate\Routing\ControllerDispatcher->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#12 /home/ruben/apps/bootstrap/cache/compiled.php(9472): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#13 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#14 /home/ruben/apps/bootstrap/cache/compiled.php(9454): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#15 /home/ruben/apps/bootstrap/cache/compiled.php(8816): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#16 /home/ruben/apps/bootstrap/cache/compiled.php(8801): Illuminate\Routing\ControllerDispatcher->callWithinStack(Object(App\Http\Controllers\API\AuthenticateController), Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'authenticate')
#17 /home/ruben/apps/bootstrap/cache/compiled.php(7755): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'App\\Http\\Contro...', 'authenticate')
#18 /home/ruben/apps/bootstrap/cache/compiled.php(7726): Illuminate\Routing\Route->runWithCustomDispatcher(Object(Illuminate\Http\Request))
#19 /home/ruben/apps/bootstrap/cache/compiled.php(7379): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#20 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#21 /home/ruben/apps/bootstrap/cache/compiled.php(9472): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#22 /home/ruben/apps/app/Http/Middleware/Cors.php(18): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#23 [internal function]: App\Http\Middleware\Cors->handle(Object(Illuminate\Http\Request), Object(Closure))
#24 /home/ruben/apps/bootstrap/cache/compiled.php(9464): call_user_func_array(Array, Array)
#25 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#26 /home/ruben/apps/bootstrap/cache/compiled.php(9454): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#27 /home/ruben/apps/bootstrap/cache/compiled.php(7380): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#28 /home/ruben/apps/bootstrap/cache/compiled.php(7368): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#29 /home/ruben/apps/bootstrap/cache/compiled.php(7353): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#30 /home/ruben/apps/bootstrap/cache/compiled.php(2262): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#31 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#32 /home/ruben/apps/bootstrap/cache/compiled.php(9472): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#33 /home/ruben/apps/bootstrap/cache/compiled.php(2886): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#34 [internal function]: Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#35 /home/ruben/apps/bootstrap/cache/compiled.php(9464): call_user_func_array(Array, Array)
#36 /home/ruben/apps/bootstrap/cache/compiled.php(12789): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#37 [internal function]: Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#38 /home/ruben/apps/bootstrap/cache/compiled.php(9464): call_user_func_array(Array, Array)
#39 /home/ruben/apps/bootstrap/cache/compiled.php(11412): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#40 [internal function]: Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#41 /home/ruben/apps/bootstrap/cache/compiled.php(9464): call_user_func_array(Array, Array)
#42 /home/ruben/apps/bootstrap/cache/compiled.php(12530): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#43 [internal function]: Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#44 /home/ruben/apps/bootstrap/cache/compiled.php(9464): call_user_func_array(Array, Array)
#45 /home/ruben/apps/bootstrap/cache/compiled.php(12469): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#46 [internal function]: Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#47 /home/ruben/apps/bootstrap/cache/compiled.php(9464): call_user_func_array(Array, Array)
#48 /home/ruben/apps/bootstrap/cache/compiled.php(2936): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#49 [internal function]: Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#50 /home/ruben/apps/bootstrap/cache/compiled.php(9464): call_user_func_array(Array, Array)
#51 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#52 /home/ruben/apps/bootstrap/cache/compiled.php(9454): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#53 /home/ruben/apps/bootstrap/cache/compiled.php(2209): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#54 /home/ruben/apps/bootstrap/cache/compiled.php(2192): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#55 /home/ruben/apps/public/index.php(54): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#56 {main}
0 likes
2 replies
StormShadow's avatar

@roeben Yes I recently had a problem similar to this that happened on production but not locally. You definitely don't want the interface, you'll get an error. You want the service provider. What I think may happen is if you add a new service provider, Laravel had already cached your services in bootstrap/cache, so depending on your app, you would get an error in your app because it's not picking up your new service provider. So you think just run artisan clear-compiled and all should be good, right. No because artisan boots your app to call itself! Were you getting this error when you ran artisan commands as well? If so, perhaps the solution would be to manually delete (not using artisan) the contents of bootstrap/cache. Let me know if this works for you.

Others have spoken on this see https://github.com/laravel/framework/issues/8520

Hope this helps.

EDIT: Taylor said he may address this in 5.2 :)

jimtaylor's avatar

This may be because you have set your constructor function to private or protected. That was my issue.

Please or to participate in this conversation.