Skip to content

Fix: Replace APP_DEBUG with environment-based gating #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 14, 2025

Conversation

eduardocruz
Copy link
Contributor

Summary

Fixes an issue where Laravel Boost commands (like boost:install) are unavailable when APP_DEBUG=false, even though this is a dev package that should work in staging environments.

Problem

The current implementation uses config('app.debug') as a blanket gate for all Laravel Boost functionality in BoostServiceProvider::boot(). This causes several issues:

  • boost:install command unavailable when debug=false
  • ✗ MCP server unavailable in staging environments
  • ✗ Confusing behavior - developers don't expect debug mode to control dev tool availability
  • ✗ Inconsistent with other Laravel dev packages (Telescope, Debugbar)

Solution

Replace the APP_DEBUG check with environment-based gating using app()->environment(['local', 'testing']).

Changes

  • File: src/BoostServiceProvider.php
  • Change: Line 58 - Replace config('app.debug', false) !== true with ! app()->environment(['local', 'testing'])

Benefits

  • boost:install works in staging with debug=false
  • ✅ MCP server available for AI development in appropriate environments
  • ✅ More intuitive behavior aligned with environment-based expectations
  • ✅ Consistent with Laravel ecosystem patterns
  • ✅ Maintains security (only enables in development environments)

Testing

  • All existing tests pass (186 passed, 2 warnings, 13 skipped)
  • Code style clean (Pint + PHPStan)
  • Existing test infrastructure already expects this behavior (TestCase.php sets environment to 'local')

🤖 Generated with Claude Code

Replace the APP_DEBUG check with environment-based gating to fix issue
where boost:install command is unavailable when debug=false.

The package now only enables in 'local' and 'testing' environments,
which is more appropriate for a dev package and aligns with how other
Laravel dev tools handle environment gating.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@NickSdot
Copy link

See #64

@eduardocruz
Copy link
Contributor Author

@NickSdot Thanks. I created the PR because I had debug=false and took me a moment to realize that the debug was disabled and therefore that was the reason I couldnt run "php artisan boost:install".

I can think in two options:
1 - Run in anything that is not production

2 - Something like Telescope - TELESCOPE_ENABLED=true

@andrew-miller-rakuten
Copy link

Wouldn't adding a new config key, such as boost.enabled be the best option here and be able to control it via it's own environment variable?

@NickSdot
Copy link

NickSdot commented Aug 14, 2025

@NickSdot Thanks. I created the PR because I had debug=false and took me a moment to realize that the debug was disabled and therefore that was the reason I couldnt run "php artisan boost:install".

I can think in two options:

1 - Run in anything that is not production

2 - Something like Telescope - TELESCOPE_ENABLED=true

Before #64 I would have said option 2 is enough. Not sure about now after it was already merged.

Perhaps the sweet spot is false === config('boost.enabled') || (!app()->environment(['local', 'testing']) && !config('app.debug')) now?

@ashleyhindle ashleyhindle self-requested a review August 14, 2025 17:17
@ashleyhindle ashleyhindle merged commit 3d11215 into laravel:main Aug 14, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants