rahasistiyak / laravel-super-artisan
Enhanced Artisan tools for Laravel to streamline file generation and workflows
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/rahasistiyak/laravel-super-artisan
Requires
- php: >=8.0
- laravel/framework: ^11.0|^12.0
Requires (Dev)
- orchestra/testbench: ^9.0
- phpunit/phpunit: ^10.0
README
Super Artisan is a powerful Laravel package that enhances the Artisan console to streamline repetitive development tasks. The make:super command generates multiple files (e.g., models, controllers, migrations, views, or front-end components) in a single command, with support for custom paths and design patterns like MVC, repository, or service. The run:workflow command executes predefined sequences of Artisan commands for tasks like deployment.
Features
- Generate Multiple Files: Create models, migrations, controllers, and views (Blade, Livewire, Vue, or React) with one command.
- Optional Custom Paths: Place files in default locations or specify custom subfolders for models, controllers, views, and migrations.
- Design Patterns: Support for MVC (default), repository (with interfaces and bindings), and service patterns.
- Front-end Flexibility: Generate Blade views (default), Livewire components, or Vue/React components.
- Workflows: Execute predefined sequences of Artisan commands.
- Configurable: Define custom blueprints and workflows in a configuration file.
Requirements
- PHP >= 8.0
- Laravel 11.x or 12.x
Installation
Install the package via Composer:
composer require rahasistiyak/laravel-super-artisan
Publish the configuration and stub files:
php artisan vendor:publish --tag=super-artisan-config php artisan vendor:publish --tag=super-artisan-stubs
This creates:
config/super-artisan.php: Configuration for blueprints and workflows.stubs/vendor/super-artisan/: Customizable stub files.
Usage
make:super Command
The make:super command generates files for a resource (e.g., Post) with customizable paths and patterns. By default, it uses standard Laravel directories, but you can optionally specify custom paths.
Syntax:
php artisan make:super {name} [--livewire|--vue|--react] [--path={path}] [--controller_path={path}] [--model_path={path}] [--view_path={path}] [--migration_path={path}] [--pattern=repository|service]
Options:
--livewire: Generate a Livewire component (inapp/Livewireandresources/views/livewire).--vue: Generate a Vue component (inresources/js).--react: Generate a React component (inresources/js).--path={path}: (Optional) Base path for controllers and views/components (e.g.,Adminplaces controllers inapp/Http/Controllers/Adminand views inresources/views/Adminorresources/js/Admin).--controller_path={path}: (Optional) Subfolder withinapp/Http/Controllers(e.g.,Adminplaces controllers inapp/Http/Controllers/Admin).--model_path={path}: (Optional) Subfolder withinapp/Models(e.g.,Customcreatesapp/Models/Custom/{name}.php).--view_path={path}: (Optional) Subfolder withinresources/views(for Blade/Livewire) orresources/js(for Vue/React).--migration_path={path}: (Optional) Subfolder withindatabase/migrations.--pattern=repository|service: (Optional) Generate files for repository (with interface and controller injection) or service pattern.
Note: Only one of --livewire, --vue, or --react can be used. Specifying multiple will result in an error.
Examples:
-
Default MVC with Blade Views:
php artisan make:super Post
Generates:
- Model:
app/Models/Post.php - Migration:
database/migrations/*_create_posts_table.php - Controller:
app/Http/Controllers/PostController.php - Views:
resources/views/post/index.blade.php,create.blade.php,edit.blade.php,show.blade.php
- Model:
-
Livewire with Default Paths:
php artisan make:super Post --livewire
Generates:
- Model:
app/Models/Post.php - Migration:
database/migrations/*_create_posts_table.php - Controller:
app/Http/Controllers/PostController.php - Livewire:
app/Livewire/Post.php - View:
resources/views/livewire/post.blade.php
- Model:
-
Livewire with Custom View Path:
php artisan make:super Post --livewire --view_path=admin/posts
Generates:
- Model:
app/Models/Post.php - Migration:
database/migrations/*_create_posts_table.php - Controller:
app/Http/Controllers/PostController.php - Livewire:
app/Livewire/admin/posts/Post.php - View:
resources/views/livewire/admin/posts/post.blade.php
- Model:
-
Vue with Default Path:
php artisan make:super Post --vue
Generates:
- Model:
app/Models/Post.php - Migration:
database/migrations/*_create_posts_table.php - Controller:
app/Http/Controllers/PostController.php - Vue:
resources/js/components/Post.vue
- Model:
-
Vue with Custom Path:
php artisan make:super Post --vue --path=Admin
Generates:
- Model:
app/Models/Post.php - Migration:
database/migrations/*_create_posts_table.php - Controller:
app/Http/Controllers/Admin/PostController.php - Vue:
resources/js/Admin/Post.vue
- Model:
-
Repository Pattern with Custom Controller Path:
php artisan make:super Post --pattern=repository --controller_path=Admin
Generates:
- Model:
app/Models/Post.php - Migration:
database/migrations/*_create_posts_table.php - Controller:
app/Http/Controllers/Admin/PostController.php(with repository injection) - Repository:
app/Repositories/PostRepository.php - Interface:
app/Repositories/PostRepositoryInterface.php - Binding:
app/Providers/RepositoryServiceProvider.php - Views:
resources/views/post/index.blade.php, etc.
- Model:
-
Custom Model Path:
php artisan make:super Post --model_path=Custom
Generates:
- Model:
app/Models/Custom/Post.php - Migration:
database/migrations/*_create_posts_table.php - Controller:
app/Http/Controllers/PostController.php - Views:
resources/views/post/*.blade.php
- Model:
-
Error on Multiple Front-end Options:
php artisan make:super Post --livewire --vue
Output:
Only one of --livewire, --vue, or --react can be used.
run:workflow Command
Execute a sequence of Artisan commands defined in config/super-artisan.php.
Syntax:
php artisan run:workflow {workflow}
Example:
php artisan run:workflow deploy
Executes commands like optimize:clear, migrate --force, etc., as defined in the deploy workflow.
Configuration
The config/super-artisan.php file allows you to define custom blueprints (file generation templates) and workflows (command sequences).
Blueprints
Define sets of files to generate. Example:
'blueprints' => [ 'crud' => [ 'description' => 'Generates a full CRUD stack.', 'commands' => [ 'make:model {name} -m -f', 'make:controller {name}Controller --resource --model={name}', ], ], ],
Workflows
Define sequences of Artisan commands. Example:
'workflows' => [ 'deploy' => [ 'description' => 'Clears caches and runs migrations.', 'commands' => [ 'optimize:clear', 'migrate --force', 'route:cache', 'view:cache', ], ], ],
Customizing Stubs
Published stubs are located in stubs/vendor/super-artisan/. Modify these to customize generated files:
view_*.stub: Blade view templates.vue_component.stub: Vue component template.react_component.stub: React component template.repository.stub: Repository class template.repository_interface.stub: Repository interface template.repository_controller.stub: Controller with repository injection.service.stub: Service class template.
Repository Pattern
When using --pattern=repository, the package generates:
- A repository class (
app/Repositories/{name}Repository.php). - An interface (
app/Repositories/{name}RepositoryInterface.php). - A controller with dependency injection (
app/Http/Controllers/*/{name}Controller.php). - A binding in
app/Providers/RepositoryServiceProvider.phpto connect the interface to the repository.
This promotes loose coupling and maintainable code.
Testing
Run tests to ensure the package works as expected:
vendor/bin/phpunit
Tests verify file generation, path handling, repository bindings, and error cases (e.g., multiple front-end options).
Contributing
Contributions are welcome! Please submit pull requests or issues to the GitHub repository.
License
This package is licensed under the MIT License.
Contact
For any questions or support, you can reach us at: Email: rahasistiyak.official@gmail.com