fibers/rocket
Fibers Rocket adds developer-friendly Artisan commands to quickly scaffold common Laravel parts—models, controllers, migrations, views, layouts, routes, and more. Templates follow Laravel conventions, are easy to customize, and commands are context-aware to auto-fill boilerplate.
Installation:
composer require-dev fibers/rocket
Add to composer.json under require-dev to ensure it’s not deployed to production.
Publish Config (Optional):
php artisan vendor:publish --provider="Fibers\Rocket\RocketServiceProvider"
Customize paths, templates, or naming conventions in config/rocket.php.
First Use Case: Scaffold a full CRUD resource (model, migration, controller, views, routes) in one command:
php artisan fibers:create Post
This generates:
app/Models/Post.php)database/migrations/..._create_posts_table.php)app/Http/Controllers/PostController.php)resources/views/posts/)routes/web.php)Verify:
routes/web.php for the new resource route.resources/views/posts/ (e.g., index.blade.php, create.blade.php).php artisan fibers:create User --resource
Generates a full RESTful resource with all standard actions (index, create, store, etc.).php artisan fibers:model User
php artisan fibers:controller User
php artisan fibers:views User
Generate components independently.Migration Fields:
Define fields in the model ($fillable or $casts) to auto-generate migration columns:
// app/Models/Post.php
protected $fillable = ['title', 'content'];
protected $casts = ['published_at' => 'datetime'];
Run php artisan fibers:model Post to update the migration accordingly.
View Templates: Customize templates by overriding default files in:
resources/views/rocket/
Example: Override resources/views/rocket/layouts/app.blade.php to modify the base layout.
Extend Controllers:
Add custom methods to generated controllers (e.g., app/Http/Controllers/PostController.php):
public function customAction()
{
return response()->json(['message' => 'Custom logic']);
}
Update routes manually or use php artisan fibers:routes Post to regenerate.
Seeders:
Use php artisan fibers:seeder User to generate a seeder with sample data based on the model’s fillable fields.
Override Defaults:
Copy templates from vendor/fibers/rocket/src/templates/ to resources/views/rocket/ to customize layouts, partials, or controllers.
Example: Modify resources/views/rocket/controllers/resource.blade.php to change the controller structure.
Add New Templates:
Extend the package by adding new template files in resources/views/rocket/ and reference them in the config.
php artisan fibers:create Post --api
Produces a controller with ApiResource and JSON responses.Laravel Mix/Vite:
Ensure generated views include proper asset paths (e.g., @vite(['resources/css/app.css'])). Override resources/views/rocket/layouts/app.blade.php if needed.
Testing:
Use php artisan fibers:test User to generate a feature test class with basic assertions for the scaffolded resource.
Database: Run migrations after scaffolding:
php artisan migrate
Namespaces:
Customize the namespace in config/rocket.php to match your project’s structure (e.g., App\Http\Controllers\Admin).
Overwriting Existing Files:
--force to overwrite:
php artisan fibers:create Post --force
config/rocket.php for overwrite settings to control default behavior.Migration Conflicts:
php artisan fibers:migration Post
Route Conflicts:
routes/web.php after running php artisan fibers:routes.Template Caching:
resources/views/rocket/ may not reflect immediately due to Laravel’s view caching. Clear cache:
php artisan view:clear
Deprecated Laravel Features:
Command Output:
Use --verbose for detailed logs:
php artisan fibers:create Post --verbose
Template Errors: If a template fails to render, check:
resources/views/rocket/.php artisan view:clear to reset).Configuration Issues:
Validate config/rocket.php for correct paths and settings. Example:
'paths' => [
'views' => resource_path('views/rocket'),
],
Partial Scaffolding: Use individual commands for incremental development:
php artisan fibers:model Post
php artisan fibers:migration Post
php artisan fibers:controller Post
Reusable Components: Generate a base layout once and reuse it:
php artisan fibers:layout admin
Then extend it in other views.
Custom Field Types:
Extend the package by adding custom field types in config/rocket.php:
'field_types' => [
'rich_text' => ['type' => 'text', 'attributes' => 'class="trix-editor"'],
],
Exclude Fields: Skip certain fields in migrations/views by marking them in the model:
protected $hidden = ['api_token'];
API + Web Hybrid: Generate both API and web controllers/views separately:
php artisan fibers:create Post --api
php artisan fibers:create Post --resource
Backup Before Regenerating:
Always back up custom files before running --force to avoid losing changes.
Laravel Forge/Envoyer:
Exclude rocket from deployment if using composer.json’s extra.deployer:
"extra": {
"deployer": {
"ignore": ["vendor/fibers/rocket"]
}
}
Legacy Support:
For older Laravel versions, pin the package version in composer.json:
"fibers/rocket": "dev-master"
How can I help you explore Laravel packages today?