Jwt-auth: Error after installing in version 5.4

Created on 25 Jan 2017  路  8Comments  路  Source: tymondesigns/jwt-auth

I am getting this error after composer update....
I am using laravel version 5.4.*

Call to undefined method Illuminate\Foundation\Application::share()

My providers array

`'providers' => [App\Providers\EventServiceProvider::class,
        App\Providers\RouteServiceProvider::class,
         'Tymon\JWTAuth\Providers\JWTAuthServiceProvider'

    ],`

My alias array

 'aliases' => ['View' => Illuminate\Support\Facades\View::class,
        'JWTAuth' => 'Tymon\JWTAuth\Facades\JWTAuth',
        'JWTFactory' => 'Tymon\JWTAuth\Facades\JWTFactory'


    ],

My composer.json
,
"tymon/jwt-auth": "0.5.*"

The error is

C:\wamp\www\myproject\app>php artisan vendor:publish --provider="Tymon\JW
TAuth\Providers\JWTAuthServiceProvider"
PHP Fatal error:  Call to undefined method Illuminate\Foundation\Application::sh
are() in C:\wamp\www\myproject\app\vendor\tymon\jwt-auth\src\Providers\JW
TAuthServiceProvider.php on line 122

Most helpful comment

+1. It would be great If you could tag the develop branch that seems to have the fix for 5.4 =) Thanks youuu!!!

All 8 comments

I get the same error when updating to Laravel 5.4. I will delay upgrading to the latest version for now and thank everyone in advance for any work getting a fix for this ;-)

 1/1 FatalThrowableError in JWTAuthServiceProvider.php line 122: Call to undefined method Illuminate\Foundation\Application::share()

    in JWTAuthServiceProvider.php line 122
    at JWTAuthServiceProvider->registerUserProvider() in JWTAuthServiceProvider.php line 100
    at JWTAuthServiceProvider->register() in Application.php line 568
    at Application->register(object(JWTAuthServiceProvider)) in ProviderRepository.php line 74
    at ProviderRepository->load(array('Illuminate\\Auth\\AuthServiceProvider', 'Illuminate\\Broadcasting\\BroadcastServiceProvider', 'Illuminate\\Bus\\BusServiceProvider', 'Illuminate\\Cache\\CacheServiceProvider', 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', 'Illuminate\\Cookie\\CookieServiceProvider', 'Illuminate\\Database\\DatabaseServiceProvider', 'Illuminate\\Encryption\\EncryptionServiceProvider', 'Illuminate\\Filesystem\\FilesystemServiceProvider', 'Illuminate\\Foundation\\Providers\\FoundationServiceProvider', 'Illuminate\\Hashing\\HashServiceProvider', 'Illuminate\\Mail\\MailServiceProvider', 'Illuminate\\Notifications\\NotificationServiceProvider', 'Illuminate\\Pagination\\PaginationServiceProvider', 'Illuminate\\Pipeline\\PipelineServiceProvider', 'Illuminate\\Queue\\QueueServiceProvider', 'Illuminate\\Redis\\RedisServiceProvider', 'Illuminate\\Auth\\Passwords\\PasswordResetServiceProvider', 'Illuminate\\Session\\SessionServiceProvider', 'Laravel\\Tinker\\TinkerServiceProvider', 'Illuminate\\Translation\\TranslationServiceProvider', 'Illuminate\\Validation\\ValidationServiceProvider', 'Illuminate\\View\\ViewServiceProvider', 'App\\Providers\\AppServiceProvider', 'App\\Providers\\AuthServiceProvider', 'App\\Providers\\BroadcastServiceProvider', 'App\\Providers\\EventServiceProvider', 'App\\Providers\\RouteServiceProvider', 'Tymon\\JWTAuth\\Providers\\JWTAuthServiceProvider', 'Mpociot\\ApiDoc\\ApiDocGeneratorServiceProvider')) in Application.php line 543
    at Application->registerConfiguredProviders() in RegisterProviders.php line 17
    at RegisterProviders->bootstrap(object(Application)) in Application.php line 208
    at Application->bootstrapWith(array('Illuminate\\Foundation\\Bootstrap\\LoadEnvironmentVariables', 'Illuminate\\Foundation\\Bootstrap\\LoadConfiguration', 'Illuminate\\Foundation\\Bootstrap\\HandleExceptions', 'Illuminate\\Foundation\\Bootstrap\\RegisterFacades', 'Illuminate\\Foundation\\Bootstrap\\RegisterProviders', 'Illuminate\\Foundation\\Bootstrap\\BootProviders')) in Kernel.php line 160
    at Kernel->bootstrap() in Kernel.php line 144
    at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
    at Kernel->handle(object(Request)) in index.php line 53

Same here.

jwt it's not 100% compatible with laravel 5.4 yet see https://github.com/tymondesigns/jwt-auth/pull/969

+1. It would be great If you could tag the develop branch that seems to have the fix for 5.4 =) Thanks youuu!!!

Looking at another project relying on the share method https://github.com/mpociot/laravel-apidoc-generator/pull/150/files this may be the approach:

// Change this in JWTAuthServiceProvider.php line 122:
$this->app['tymon.jwt.provider.user'] = $this->app->share(function ($app) {

// To this?
$this->app->singleton('tymon.jwt.provider.user', function ($app) {

There are further uses of share in this Class which would likely need updating too.

@spirant You should actually use singleton. It's part of the upgrade guides.

https://laravel.com/docs/5.4/upgrade search for share on there.

If not known yet. On release 1.0.0-beta.2 This doesn't seem to do anything, yet:
php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\JWTAuthServiceProvider"

Installing "dev-master" solved the issue for me, since it was solved here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lbottoni picture lbottoni  路  3Comments

Rasoul-Karimi picture Rasoul-Karimi  路  3Comments

aofdev picture aofdev  路  3Comments

kofi1995 picture kofi1995  路  3Comments

johncloud200 picture johncloud200  路  3Comments