boson-php/globals-provider
Laravel package that exposes PHP superglobals and environment values through a service provider, offering a consistent way to access and share request/runtime globals across your app, with simple configuration and container bindings for easier testing.
Modularity & Decoupling: The package appears to be a subtree split of boson-php/boson, suggesting it provides a global state/dependency provider pattern (likely for Laravel). This aligns well with Laravel’s service container and dependency injection paradigms, but may introduce global state anti-patterns if misused.
Laravel-Specific Synergies:
register()/boot()).GlobalProvider::macro()) if the package supports it.Core Dependencies:
Illuminate/Container or similar interfaces for service resolution.Key Integration Points:
$this->app->singleton(GlobalProvider::class, fn() => new GlobalProvider());
GlobalProvider::get('config.key'); // Hypothetical API
AppServiceProvider or custom middleware for initialization.Testing Complexity:
MockApplication or dependency injection overrides.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Global State Leaks | High | Restrict usage to non-critical paths; audit dependencies. |
| Container Collisions | Medium | Prefix bindings (e.g., globals::config). |
| Laravel Version Lock | Medium | Test against target Laravel version early. |
| Performance Overhead | Low | Benchmark if used in high-throughput routes. |
| License Compliance | Low | MIT license is permissive; no issues expected. |
config(), app()->make(), or packages like spatie/laravel-config-array)?GlobalProvider API documented? Are there breaking changes in boson-php/boson?config(), app()) transition to this provider?Container abstractions).config(), app(), static classes).AuthProvider).// app/Providers/GlobalProviderServiceProvider.php
public function register()
{
$this->app->singleton('globals', fn() => new \Boson\GlobalsProvider());
$this->app->alias('globals', GlobalProvider::class);
}
config('key') with GlobalProvider::get('config.key') in phases.if (class_exists(\Boson\GlobalsProvider::class)) {
config()->macro('globals', fn($key) => \Boson\GlobalsProvider::get($key));
}
deprecated() helper or middleware.Boson\GlobalsProvider vs. custom GlobalsProvider)."scripts": {
"post-autoload-dump": "php artisan vendor:publish --tag=boson-config --ansi"
}
config/app.php.config() calls in services/repositories.boson-php/boson for changes.GlobalProvider usage (e.g., via static analysis).GlobalProvider::has('unused.key')).# phpstan.neon
parameters:
level: 7
rules:
Boson\GlobalsProvider\Rules\NoDirectGlobals: true
GlobalProvider::reset() in tests; avoid in queue workers.GlobalProvider → Service → GlobalProvider).| Issue Type | Owner | Resolution Time |
|---|---|---|
| Global state corruption | Backend Team | 1–4 hours |
| Provider registration | DevOps | <1 hour |
| Performance degradation | PM/Engineering | 2–5 days |
GlobalProvider::useCache()).GlobalProvider::lazyLoad() for expensive globals.| Failure Scenario | Impact | Detection Method | Recovery Plan |
|---|---|---|---|
| Global provider crash | Partial outage | Sentry/Monolog errors | Fallback to config() cache |
How can I help you explore Laravel packages today?