Skip to content

Commit e312f36

Browse files
axlontaylorotwell
andauthored
[11.x] Allow for bootstrapping without loading routes (#1564)
* Allow for bootstrapping without loading routes * Update Passport.php Co-authored-by: Taylor Otwell <[email protected]>
1 parent 5629f1a commit e312f36

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

src/Passport.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,13 @@ class Passport
161161
*/
162162
public static $authorizationServerResponseType;
163163

164+
/**
165+
* Indicates if Passport routes will be registered.
166+
*
167+
* @var bool
168+
*/
169+
public static $registersRoutes = true;
170+
164171
/**
165172
* Enable the implicit grant type.
166173
*
@@ -630,6 +637,18 @@ public static function tokenEncryptionKey(Encrypter $encrypter)
630637
$encrypter->getKey();
631638
}
632639

640+
/**
641+
* Configure Passport to not register its routes.
642+
*
643+
* @return static
644+
*/
645+
public static function ignoreRoutes()
646+
{
647+
static::$registersRoutes = false;
648+
649+
return new static;
650+
}
651+
633652
/**
634653
* Configure Passport to not register its migrations.
635654
*

src/PassportServiceProvider.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,15 @@ public function boot()
5050
*/
5151
protected function registerRoutes()
5252
{
53-
Route::group([
54-
'as' => 'passport.',
55-
'prefix' => config('passport.path', 'oauth'),
56-
'namespace' => 'Laravel\Passport\Http\Controllers',
57-
], function () {
58-
$this->loadRoutesFrom(__DIR__.'/../routes/web.php');
59-
});
53+
if (Passport::$registersRoutes) {
54+
Route::group([
55+
'as' => 'passport.',
56+
'prefix' => config('passport.path', 'oauth'),
57+
'namespace' => 'Laravel\Passport\Http\Controllers',
58+
], function () {
59+
$this->loadRoutesFrom(__DIR__.'/../routes/web.php');
60+
});
61+
}
6062
}
6163

6264
/**

0 commit comments

Comments
 (0)