Is your feature request related to a problem? Please describe.
Since StacheServiceProvider is marked as deferred, it's impossible to use Stache in an addon's boot method for its service provider, thus preventing one from using any content in the system.
Describe the solution you'd like
From the Laravel docs described here, you should only mark a service provider as deferred if it only registers bindings.
Service providers marked incorrectly as deferred:
AuthServiceProvider
StacheServiceProvider
Describe alternatives you've considered
I patched core to comment out the deferred flag for StacheServiceProvider.
Additional context
Consider also moving StacheServiceProvider up before RouteServiceProvider in config/app.php, so one can use Statamic\Events\RoutesMapping event for custom routes with access to content.
Would you be willing to sponsor this feature?
diff --git a/statamic/config/app.php b/statamic/config/app.php
index 783d843..4def364 100644
--- a/statamic/config/app.php
+++ b/statamic/config/app.php
@@ -148,8 +148,8 @@ return [
'Statamic\Providers\DataServiceProvider',
'Statamic\Providers\FilesystemServiceProvider',
'Statamic\Providers\EventServiceProvider',
- 'Statamic\Providers\RouteServiceProvider',
'Statamic\Providers\StacheServiceProvider',
+ 'Statamic\Providers\RouteServiceProvider',
'Statamic\Providers\GlideServiceProvider',
'Statamic\Providers\AuthServiceProvider',
'Statamic\Providers\BladeServiceProvider',
diff --git a/statamic/core/Providers/AuthServiceProvider.php b/statamic/core/Providers/AuthServiceProvider.php
index 3944529..24871f3 100644
--- a/statamic/core/Providers/AuthServiceProvider.php
+++ b/statamic/core/Providers/AuthServiceProvider.php
@@ -11,7 +11,6 @@ use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvid
class AuthServiceProvider extends ServiceProvider
{
- protected $defer = true;
protected $policies = [];
public function register()
diff --git a/statamic/core/Providers/StacheServiceProvider.php b/statamic/core/Providers/StacheServiceProvider.php
index 716ce83..f2bb9c3 100644
--- a/statamic/core/Providers/StacheServiceProvider.php
+++ b/statamic/core/Providers/StacheServiceProvider.php
@@ -25,13 +25,6 @@ use Symfony\Component\Lock\Store\RetryTillSaveStore;
class StacheServiceProvider extends ServiceProvider
{
- /**
- * Indicates if loading of the provider is deferred.
- *
- * @var bool
- */
- protected $defer = true;
-
/**
* @var Stache
*/
Is your feature request related to a problem? Please describe. Since
StacheServiceProvider
is marked as deferred, it's impossible to useStache
in an addon'sboot
method for its service provider, thus preventing one from using any content in the system.Describe the solution you'd like From the Laravel docs described here, you should only mark a service provider as deferred if it only registers bindings. Service providers marked incorrectly as deferred:
AuthServiceProvider
StacheServiceProvider
Describe alternatives you've considered I patched core to comment out the deferred flag for
StacheServiceProvider
.Additional context Consider also moving
StacheServiceProvider
up beforeRouteServiceProvider
inconfig/app.php
, so one can useStatamic\Events\RoutesMapping
event for custom routes with access to content.Would you be willing to sponsor this feature?