I'm trying to create an authentication package (module) using jwt-auth
that can be reused across all of my applications. But I receive errors.
Framework Laravel
Framework version 8.46.0
jwt-auth version ^1.0.0-beta.3@dev
PHP version 7.4.20
Steps to reproduce
- Create a fresh laravel project
- Create a fresh package inside it
- Add
"tymon/jwt-auth": "^1.0.0-beta.3@dev"
, as requirement to thecomposer.json
of the package - Implement
JWTSubject
in your User model - Try to run any artisan command.
I receive this error:
Error
Call to undefined method Vendor\Package\Auth::extend()
at vendor/tymon/jwt-auth/src/Providers/AbstractServiceProvider.php:98
94▕ * @return void
95▕ */
96▕ protected function extendAuthGuard()
97▕ {
➜ 98▕ $this->app['auth']->extend('jwt', function ($app, $name, array $config) {
99▕ $guard = new JWTGuard(
100▕ $app['tymon.jwt'],
101▕ $app['auth']->createUserProvider($config['provider']),
102▕ $app['request']
+8 vendor frames
9 [internal]:0
Illuminate\Foundation\Application::Illuminate\Foundation\{closure}()
+5 vendor frames
15 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
My package name is also Auth
. I'm stuck at solving this problem. Any help?