masgeek / artisan-toolkit
A collection of custom and override Artisan commands for Laravel. Enable only what you need via a published config.
Requires
- php: ^8.2
- laravel/framework: ^11|^12
Requires (Dev)
- orchestra/testbench: ^9.0|^10.0
- phpunit/phpunit: ^11.0|^12.0
- dev-develop
- 1.0.0
- dev-renovate/laravel-framework-13.x
- dev-renovate/major-github-artifact-actions
- dev-main
- dev-renovate/actions-github-script-9.x
- dev-renovate/actions-checkout-6.x
- dev-renovate/actions-cache-5.x
- dev-renovate/ncipollo-release-action-1.x
- dev-renovate/devops-infra-action-pull-request-0.x
This package is auto-updated.
Last update: 2026-05-07 22:14:18 UTC
README
A collection of custom and override Artisan commands for Laravel. Enable only what you need via a single published config file.
Installation
composer require masgeek/artisan-toolkit
Publish the config:
php artisan vendor:publish --tag=artisan-toolkit-config
Configuration
The published config/artisan-toolkit.php controls which commands are active:
return [ 'overrides' => [ // Enabled — uses the package's safer implementation 'schema:dump' => \Masgeek\ArtisanToolkit\Commands\SchemaDumpCommand::class, // Disabled — leave the built-in untouched // 'schema:dump' => false, // Custom — provide your own class instead // 'schema:dump' => App\Console\Commands\MyDump::class, ], 'commands' => [ // Register additional custom commands here // 'my:command' => \Masgeek\ArtisanToolkit\Commands\MyCommand::class, ], ];
Setting a value to false (or removing the entry) disables that command and leaves Laravel's built-in in place.
Available overrides
schema:dump
The built-in php artisan schema:dump --prune deletes every file under database/migrations/. This override changes --prune to only delete migration files whose name exists in the migrations table — pending (unrun) migrations are kept on disk.
# Dump schema and delete only already-run migration files php artisan schema:dump --prune # Dump without pruning (identical to built-in behaviour) php artisan schema:dump
Output when --prune is used:
2024_01_01_000000_create_users_table.php .............. deleted
2026_05_07_085600_rename_playground_role.php .......... kept (pending)
Database schema dumped and pruned (1 deleted, 1 pending kept) successfully.
Available commands
make:enum
Laravel has no built-in enum generator. This command creates a PHP enum in app/Enums/.
# Pure (unbacked) enum php artisan make:enum Status # Backed string enum with cases pre-filled php artisan make:enum UserRole --backed=string --cases=Admin,Partner,User # Backed int enum in a sub-namespace php artisan make:enum Billing/InvoiceStatus --backed=int --cases=Draft,Pending,Paid,Void # Overwrite an existing file php artisan make:enum UserRole --force
Example output for php artisan make:enum UserRole --backed=string --cases=Admin,Partner,User:
<?php namespace App\Enums; enum UserRole: string { case Admin = 'admin'; case Partner = 'partner'; case User = 'user'; }
Sub-namespaces (e.g. Billing/InvoiceStatus) are placed under app/Enums/Billing/ with the correct namespace App\Enums\Billing; declaration.
Adding new commands
- Create a class in
src/Commands/using namespaceMasgeek\ArtisanToolkit\Commands.- To override a built-in: extend the original command class and change the behaviour.
- To add a new command: extend
Illuminate\Console\Commandas normal.
- Add it to the appropriate section in
config/artisan-toolkit.php(overridesorcommands). - The service provider registers it automatically when enabled.
License
MIT