-
-
Notifications
You must be signed in to change notification settings - Fork 0
Installation Guide
This guide will walk you through the complete installation process for Laravel FeatureBox.
Before installing Laravel FeatureBox, ensure your system meets these requirements:
- PHP: >= 8.1
- Laravel: >= 10.0
- Database: MySQL, PostgreSQL, or SQLite
- Composer: Latest version
The following PHP extensions are required:
domcurllibxmlmbstringzippcntlpdo-
sqlite(if using SQLite) -
pdo_sqlite(if using SQLite) bcmathsoapintlgdexificonvfileinfo
composer require mohamedhekal/laravel-featureboxphp artisan vendor:publish --tag=featurebox-config
php artisan vendor:publish --tag=featurebox-migrationsphp artisan migratephp artisan featurebox:listThe package is available on Packagist and can be installed using Composer:
composer require mohamedhekal/laravel-featureboxThis command will:
- Download the package from Packagist
- Install all dependencies
- Register the service provider automatically (Laravel auto-discovery)
- Register the Facade alias
Publish the configuration file to customize the package settings:
php artisan vendor:publish --tag=featurebox-configThis creates config/featurebox.php with the following default configuration:
return [
'cache' => [
'enabled' => env('FEATUREBOX_CACHE_ENABLED', true),
'ttl' => env('FEATUREBOX_CACHE_TTL', 300), // 5 minutes
],
'default_conditions' => [
// Default conditions for all features
],
'table' => env('FEATUREBOX_TABLE', 'features'),
];Publish the database migrations to create the required tables:
php artisan vendor:publish --tag=featurebox-migrationsThis creates a migration file in database/migrations/ that will create the features table.
Execute the migrations to create the database table:
php artisan migrateThe migration creates a features table with the following structure:
CREATE TABLE features (
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) UNIQUE NOT NULL,
is_enabled BOOLEAN DEFAULT FALSE,
conditions JSON NULL,
created_at TIMESTAMP NULL,
updated_at TIMESTAMP NULL
);Test that the package is working correctly:
# List all features (should be empty initially)
php artisan featurebox:list
# Enable a test feature
php artisan featurebox:enable test_feature
# Check if the feature is enabled
php artisan featurebox:listAdd these variables to your .env file to customize the package behavior:
# Cache settings
FEATUREBOX_CACHE_ENABLED=true
FEATUREBOX_CACHE_TTL=300
# Database table name
FEATUREBOX_TABLE=featuresThe package uses Laravel's cache system for performance. You can configure caching in config/featurebox.php:
'cache' => [
'enabled' => env('FEATUREBOX_CACHE_ENABLED', true),
'ttl' => env('FEATUREBOX_CACHE_TTL', 300), // 5 minutes
],The package uses your Laravel database configuration. Make sure your database connection is properly configured in config/database.php.
If you prefer to install the package manually or need to customize the installation:
git clone https://github.com/mohamedhekal/laravel-featurebox.git
cd laravel-featurebox
composer installAdd the package to your composer.json:
{
"require": {
"mohamedhekal/laravel-featurebox": "dev-main"
},
"repositories": [
{
"type": "path",
"url": "./laravel-featurebox"
}
]
}Add the service provider to config/app.php:
'providers' => [
// ...
MohamedHekal\LaravelFeatureBox\FeatureBoxServiceProvider::class,
],
'aliases' => [
// ...
'FeatureBox' => MohamedHekal\LaravelFeatureBox\Facades\FeatureBox::class,
],Copy the configuration and migration files manually:
cp laravel-featurebox/config/featurebox.php config/
cp laravel-featurebox/database/migrations/* database/migrations/When upgrading the package:
-
Update the package:
composer update mohamedhekal/laravel-featurebox
-
Publish new configuration (if any):
php artisan vendor:publish --tag=featurebox-config --force
-
Run new migrations:
php artisan migrate
-
Clear cache:
php artisan cache:clear
Create a simple test to verify the installation:
// In a controller or route
use FeatureBox\Facades\FeatureBox;
// Enable a test feature
FeatureBox::enable('test_feature');
// Check if it's enabled
if (FeatureBox::isEnabled('test_feature')) {
echo "Feature is enabled!";
} else {
echo "Feature is disabled!";
}Test the Artisan commands:
# List features
php artisan featurebox:list
# Enable a feature
php artisan featurebox:enable my_feature
# Disable a feature
php artisan featurebox:disable my_featureIf you encounter memory issues during installation:
COMPOSER_MEMORY_LIMIT=-1 composer require mohamedhekal/laravel-featureboxIf you get permission errors:
sudo chown -R $USER:$USER .
chmod -R 755 storage bootstrap/cacheIf migrations fail:
# Check migration status
php artisan migrate:status
# Rollback and re-run
php artisan migrate:rollback
php artisan migrateIf the service provider is not auto-discovered:
- Check if Laravel auto-discovery is enabled
- Manually register the service provider in
config/app.php - Clear configuration cache:
php artisan config:clear
If the Facade is not working:
- Check if the alias is registered in
config/app.php - Clear application cache:
php artisan cache:clear - Clear configuration cache:
php artisan config:clear
Use these commands to verify the installation:
# Check if package is installed
composer show mohamedhekal/laravel-featurebox
# Check if service provider is registered
php artisan config:show app.providers | grep FeatureBox
# Check if facade is working
php artisan tinker
>>> FeatureBox::all()
>>> exit
# Check if commands are available
php artisan list | grep featureboxAfter successful installation:
- Read the API Reference to learn how to use the package
- Check the Examples for usage patterns
- Configure caching for better performance
- Set up your first features using Artisan commands
If you encounter any issues during installation:
- Check the Troubleshooting section above
- Search GitHub Issues
- Ask questions in GitHub Discussions
- Contact support at [email protected]