esfredderick / useful-artisan-commands
A collection of useful Laravel Artisan commands for generating actions, DTOs, and more.
Package info
github.com/esfredderickmx/useful-artisan-commands
pkg:composer/esfredderick/useful-artisan-commands
Requires
- php: ^8.2
- illuminate/console: ^12.0|^13.0
- illuminate/database: ^12.0|^13.0
- illuminate/support: ^12.0|^13.0
- laravel/prompts: ^0.3|^1.0
Requires (Dev)
- pestphp/pest: ^3.8|^4.0
README
A collection of handy Laravel Artisan commands for generating actions, DTOs, and configuring databases.
Requires PHP 8.2+ and Laravel 12 or 13.
Installation
composer require esfredderick/useful-artisan-commands --dev
Auto-discovery registers the commands automatically.
Automatic PostgreSQL Verification
When the package is installed, it automatically listens for migrate* Artisan commands. For PostgreSQL connections, it verifies that:
- the configured database exists, creating it through a maintenance
postgresconnection when possible - the configured migrations schema exists when
database.migrations.tableusesschema.tablenotation
This requires no application service provider setup while Laravel package auto-discovery is enabled. The verification also runs eagerly during unit tests so migration-backed test databases can be prepared before the test suite touches the connection.
If package discovery is disabled for this package, manually register EsFredDerick\UsefulArtisanCommands\UsefulArtisanCommandsServiceProvider in bootstrap/providers.php.
Commands
make:action
Generates an action class in app/Actions/. The Action suffix is auto-appended.
php artisan make:action CreateUser # -> app/Actions/CreateUserAction.php php artisan make:action Billing/ChargeInvoice # -> app/Actions/Billing/ChargeInvoiceAction.php
| Option | Description |
|---|---|
-d, --data |
Also generate a matching DTO class |
-f, --force |
Overwrite if file already exists |
make:data
Generates a final readonly DTO class in app/Data/. The Data suffix is auto-appended.
php artisan make:data CreateUser
# -> app/Data/CreateUserData.php
| Option | Description |
|---|---|
-f, --force |
Overwrite if file already exists |
app:config-db
Interactive prompt to configure PostgreSQL connection details in your .env file.
php artisan app:config-db
Prompts for host, port, database name, username, and password. Before saving, it shows a review table and lets you correct selected fields. Use schemas:config-defaults to configure schema-qualified Laravel framework tables such as the migrations table.
schemas:config-defaults
Interactive prompt to configure PostgreSQL schema-qualified Laravel framework tables.
php artisan schemas:config-defaults
It can write values directly to config files or to a selected .env* file, ignoring .env.example.
It also syncs starter migrations for schemas, users, password reset tokens, sessions, cache, cache locks, jobs, job batches, failed jobs, and optional starter-kit two-factor/team tables.
Prefer running it when starting a new project, before migration history matters.
| Option | Description |
|---|---|
-c, --clean-env |
After choosing config-file writes, remove managed schema table keys from local .env* files |
Starter-kit models stay in app/Models; only their table declarations are synced. The declaration style follows the host Laravel version:
| Laravel | Model table declaration |
|---|---|
| 13+ | #[Table('schema.table')] attribute |
| 12 | protected $table = 'schema.table'; property |
Customizing Stubs
Publish the stubs to customize the generated file templates:
php artisan vendor:publish --tag=useful-artisan-commands-stubs
This copies action.stub and data.stub to your project's stubs/ directory. The commands will use your local stubs over the package defaults.
License
MIT