Setting Up Filterable
About 302 wordsAbout 1 min
Purpose
The filterable:setup command initializes the Filterable package in your application. It publishes the package’s configuration file and ensures that the required directory structure (for filters) exists. This command is typically the first step after installing the package.
Usage
php artisan filterable:setupOptions
| Option | Description | Example |
|---|---|---|
--force | Overwrite the existing configuration file if it already exists. | php artisan filterable:setup --force |
What It Does
When executed, this command will:
Publish Configuration File It runs:
php artisan vendor:publish --tag=filterable-configand places the configuration file in:
config/filterable.phpEnsure Directory Structure Exists It creates:
app/Http/Filtersif it doesn’t already exist, ensuring you have a proper place to store your custom filters.
Provide Next Steps After setup, it suggests how to create your first filter:
php artisan filterable:make-filter PostFilter --filters=author,titleIf you need to generate a filter in a custom location, you can override the default target at generation time:
php artisan filterable:make-filter PostFilter \ --namespace="Modules\\Blog\\App\\Filters" \ --path="Modules/Blog/app/Filters"
Example Output
🚀 Setting up Filterable package...
✅ Configuration file published: config/filterable.php
📁 Created directory: app/Http/Filters
🎉 Setup complete! You can now create your first filter with:
php artisan filterable:make-filter PostFilter --filters=testNotes
- Use the
--forceflag if you want to re-publish the configuration file and overwrite existing settings. - The command automatically detects whether the
app/Http/Filtersdirectory already exists. filterable:make-filteruses the defaults fromconfig/filterable.php, but you can override them per run with--namespaceand--path.- Class names and namespaces must be valid PHP qualified names; invalid values fail without creating a file.
When to Use
- Right after installing the
kettasoft/filterablepackage. - When upgrading to a version that changes configuration defaults.
- When resetting your configuration to a clean state.
