Download the PHP package offload-project/laravel-toggle without Composer
On this page you can find all versions of the php package offload-project/laravel-toggle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download offload-project/laravel-toggle
More information about offload-project/laravel-toggle
Files in offload-project/laravel-toggle
Package laravel-toggle
Short Description A simple and flexible feature toggle (feature flag) package for Laravel
License MIT
Homepage https://github.com/offload-project/laravel-toggle
Informations about the package laravel-toggle
Laravel Toggle
A simple and flexible feature toggle (feature flag) package for Laravel. Control feature rollouts with config-based flags, database-driven toggles, or both.
Features
- Two storage drivers - Config (environment variables) or Database (runtime toggleable)
- Per-flag driver routing - Mix config and database flags in the same app via
database_flags - Layered approach - Database driver falls back to config, allowing gradual migration
- Built-in caching - Configurable cache store and TTL for performance
- Blade directives -
@toggle,@elsetoggle,@endtogglefor clean templates - Enum support - Use backed enums for type-safe toggle names
- Artisan commands - Scaffold new toggles and manage cache
- Inertia integration - Share all flags with the frontend via middleware
- Configurable defaults - Return false, true, or throw exceptions for undefined toggles
Table of Contents
- Why Laravel Toggle?
- Requirements
- Installation
- Quick Start
- Define a toggle in config
- Check toggles in code
- Use Blade directives
- Configuration
- Driver
- Per-flag driver routing
- Default behavior for undefined toggles
- Caching
- Usage
- Facade methods
- Using enums
- Eloquent model
- Inertia
- Artisan Commands
- AI Coding Assistant Skill
- Testing
- Contributing
- Security
- License
Why Laravel Toggle?
Laravel's first-party Pennant package is designed for user-segmented rollouts and A/B testing. Laravel Toggle is simpler — it's for global on/off switches controlled by environment variables or database records, with no user resolution or driver complexity.
Requirements
- PHP 8.3+
- Laravel 11/12/13
Installation
If using the database driver, publish and run the migrations:
Quick Start
Define a toggle in config
Add your feature flags to config/toggle.php:
Check toggles in code
Use Blade directives
Configuration
Driver
Set the driver in your .env file:
The config driver is read-only at runtime — values come from environment variables and config files.
The database driver checks the database first, then falls back to config values. This allows you to define defaults in config while overriding specific toggles at runtime.
Per-flag driver routing
You can mix both drivers in the same application. Define config-driven flags in flags and list database-driven flags
in database_flags:
Resolution logic:
- Flags in
database_flagsalways use the database driver (with config fallback) - Flags in
flagsalways use the config driver (read-only) - Unlisted flags use the global
driversetting
This lets you keep stable flags in .env while allowing runtime control over flags that need to change without a
deploy.
Default behavior for undefined toggles
Caching
Usage
Facade methods
Using enums
Define your toggles as a backed enum for type safety:
Use the enum directly:
Eloquent model
When using the database driver, you can also use the Toggle model directly:
The model automatically clears the cache when toggles are saved or deleted.
Inertia
Share all toggles with your frontend by using the provided Inertia middleware. Replace your HandleInertiaRequests
middleware in bootstrap/app.php:
All toggles will be available as the flags prop in your frontend:
Artisan Commands
List all toggles
Displays a table of all defined toggles and their current state.
Create a toggle
This command will:
- Add the flag to
config/toggle.php - Add the environment variable to
.env - Optionally create a database record
Clear cache
AI Coding Assistant Skill
This package ships a Laravel Boost skill so coding assistants (Claude Code, Cursor, etc.) follow the package's conventions when generating code. Install it in your app with:
The skill source lives at skills/SKILL.md.
Testing
Contributing
Contributions are welcome! Please see the documents below before getting started.
- Contributing Guide — setup, workflow, commit conventions, and PR process
- Code of Conduct — expectations for participation in this project
Security
- Security Policy — how to report a vulnerability privately
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-toggle with dependencies
illuminate/contracts Version ^11.0|^12.0|^13.0
illuminate/database Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0