Most developers first encounter Artisan when they need to generate a controller or run a migration. But stopping there means missing much of what Artisan can do.
Artisan handles database schema management, application scaffolding, task automation, debugging, caching, queues, and production maintenance. It sits behind many of the everyday development and operational tasks in a Laravel application.
We saw this firsthand while building an enterprise Audit Portal. The project was a custom Laravel 11 platform designed to centralize server audit scheduling, technician assignments, and real-time billing integration with WHMCS across three MySQL databases.
As the application grew beyond basic CRUD, Artisan became useful at almost every stage. We used it for initial scaffolding, multi-database migrations, scheduled operations, debugging, caching, and custom synchronization commands that reconciled audit records with WHMCS billing entries.
As Laravel applications grow more complex, having the right development and maintenance support can make it easier to manage new requirements and keep the application running smoothly. Our Laravel Services can support businesses through these evolving application needs.
This blog covers the Artisan commands that proved most useful during that project, organized around the development lifecycle.
Start by Discovering Available Commands
php artisan list
A logical starting point for any Laravel project is understanding which commands are available:
php artisan list
This displays a categorized list of registered Artisan commands, including commands created specifically for your application.
When a new developer joined the Audit Portal project, this was one of the first commands we had them run. It provided an immediate overview of the application’s console layer.
Our custom
sync:missing-time-logs command appeared alongside Laravel’s built-in commands, giving the developer a quick view of the application’s operational capabilities.
Running
php artisan without the list argument produces the same command listing.
php artisan serve
The serve command starts Laravel’s lightweight PHP development server:
php artisan serve
By default, the application becomes available at:
http://127.0.0.1:8000
We relied on this during the early stages of the Audit Portal build, before the Apache virtual host configuration was ready on our local machines.
If port 8000 is already being used, you can specify another port:
php artisan serve --port=8080
It is a simple command, but useful when you need to get a Laravel application running quickly in a local development environment.
Scaffold the Application Structure
The first few days of a Laravel project can involve a lot of repetitive work.
You create models, controllers, migrations, request classes, and other files. Artisan’s
make commands handle much of this scaffolding.
The benefit is not only speed. These commands also place generated files in the expected locations and follow Laravel’s naming conventions.
php artisan make:model
To create a model:
php artisan make:model Server
This creates:
app/Models/Server.php
The main Audit Portal models included Server, AuditDetail, AuditSchedule, and TechAssignment, each associated with data in the primary application database.
You can also combine several scaffolding options.
For example:
php artisan make:model AuditDetail -mcfs
This creates the model along with a migration, controller, factory, and seeder.
During the initial development of the Audit Portal, this was useful as the domain model continued to evolve. Creating the related files together made it easier to iterate on new entities.
php artisan make:controller
A basic controller can be created using:
php artisan make:controller AuditController
This creates:
app/Http/Controllers/AuditController.php
If you need the standard resource controller methods, use:
php artisan make:controller AuditController --resource
Laravel generates methods for common CRUD operations such as index, create, store, show, edit, update, and destroy.
We used resource controllers for the main CRUD operations around servers and audit records.
Some workflows needed a different structure.
The WHMCS credit reduction workflow contained more specialized business logic, so we created an invokable controller:
php artisan make:controller ReduceCreditController --invokable
An invokable controller exposes a single __invoke method.
The credit reduction workflow involved validating client balances across databases, applying row-level locking for concurrency control, and logging time entries in WHMCS.
Keeping that workflow in its own controller helped avoid adding more complexity to a shared resource controller.
php artisan make:middleware
Middleware provides a checkpoint before a request reaches the controller.
We created custom middleware for the Audit Portal using:
php artisan make:middleware VerifyTechnicianAccess
Authentication alone was not enough for the application. A user could be logged in and still lack permission to access particular audit records.
The custom middleware checked the logged-in user’s technician assignment against the groupware database before allowing access to the relevant workflows.
This added an authorization layer beyond basic authentication.
php artisan make:request
Form Request classes can keep validation logic separate from controllers.
We created request classes such as:
php artisan make:request StoreAuditRequest
The Audit Portal also used UpdateAuditRequest.
These classes contained validation rules and authorization checks for the relevant requests.
Keeping those rules outside the controller made them easier to locate and update later.
Manage Databases With Artisan
Database management became one of the most important areas where Artisan helped during the Audit Portal project.
The application worked with three MySQL databases, each with its own credentials and schema.
Managing those changes through version-controlled migrations was important because database changes needed to remain consistent across development and deployment environments.
php artisan make:migration
To create a migration:
php artisan make:migration create_audit_details_table
Laravel places the migration in database/migrations/
The filename includes a timestamp, which Laravel uses to determine the order in which migrations are executed.
Most of our migrations targeted the default application database.
Some changes needed to target the WHMCS database explicitly. For example, adding an index to a table on the WHMCS connection:
Schema::connection('whmcs')->table('tblcredit', function (Blueprint $table) { $table->index('clientid'); });
The ability to manage this change through the normal migration workflow meant the change could remain version-controlled, reviewed, and reversible rather than being applied manually against production.
php artisan migrate
To execute pending migrations:
php artisan migrate
During active development, we ran migrations frequently as the database schema evolved.
Several related commands were also useful:
php artisan migrate:rollback php artisan migrate:fresh php artisan migrate:fresh --seed php artisan migrate:status
These commands serve different purposes:
reverts the most recent batch of migrations.migrate:rollback
drops all tables and runs the migrations again.migrate:fresh
rebuilds the database and runs the seeders.migrate:fresh --seed
shows which migrations have already been executed and which remain pending.migrate:status
We used
migrate:fresh --seed when resetting local development environments to a predictable state.
php artisan make:seeder and db:seed
Seeders provide a way to populate tables with test data or required default records.
For example:
php artisan make:seeder ServerSeeder
The resulting seeder could then be executed using:
php artisan db:seed
A specific seeder can also be executed independently:
php artisan db:seed --class=ServerSeeder
The Audit Portal used seeders for servers, schedules, and technician assignments.
Since the application worked across three databases with related data, manually creating test records was not practical. Seeders gave developers a repeatable way to prepare a working local environment.
Build Custom Artisan Commands
The built-in commands cover many common Laravel tasks.
Custom Artisan commands become useful when your application has recurring operations that are specific to its business logic.
php artisan make:command
We created a custom command using:
php artisan make:command SyncMissingTimeLogs
This created a command class at:
app/Console/Commands/SyncMissingTimeLogs.php
The command defines its name and arguments through the
$signature property, while the handle() method contains the command’s execution logic.
One of the Audit Portal’s most important custom commands was:
sync:missing-time-logs
Its job was to compare completed audit records in the application database against corresponding time log entries in WHMCS.
If an audit was marked as completed internally but had no corresponding WHMCS time log, the command could create the missing entry.
The command accepted a target month and a dry-run option:
protected $signature = 'sync:missing-time-logs {--month= : The target month to synchronize} {--dry-run : Preview changes without executing writes}';
The –dry-run option was particularly important because the command interacted with billing data.
An administrator could first preview the changes, verify the results, and then execute the actual synchronization.
Execute Custom Commands
Once created, custom commands can be executed just like Laravel’s built-in commands:
php artisan sync:missing-time-logs --month=2026-05
A dry run could be performed using:
php artisan sync:missing-time-logs --month=2026-05 --dry-run
We also added an option in the administration panel that triggered the same command.
This meant the operation could be started through the terminal, the web interface, or a scheduled task while still using the same underlying command logic.
Automate Recurring Tasks
The Audit Portal needed to generate monthly audits without manual intervention.
On the first day of each month at midnight, the application evaluated active server schedules and populated the audit queue for the upcoming month.
Artisan and Laravel’s scheduler handled this process.
Configure the Laravel Scheduler
In Laravel 11, scheduled tasks can be defined in
routes/console.php.
The server’s cron configuration only needs to invoke Laravel’s scheduler:
* * * * * cd /path-to-project && php artisan schedule:run >> /dev/null 2>&1
This tells the server to evaluate Laravel’s scheduled tasks every minute.
The application then determines which tasks are due.
The Audit Portal’s monthly audit generation was configured as:
Schedule::command('generate:monthly-audits')->monthlyOn(1, '00:00');
Keeping the schedule in application code also meant the configuration could go through the same version-control and review process as the rest of the application.
php artisan schedule:list
To inspect scheduled tasks:
php artisan schedule:list
This displays registered scheduled tasks along with their frequencies and next execution times.
During deployment, we used it to verify that the scheduler recognized the custom commands and their intended schedules.
Debug and Inspect the Application
Artisan is also useful when something goes wrong.
php artisan route:list
The route:list command displays the application’s routes:
php artisan route:list
The output includes information such as HTTP methods, URIs, controllers, middleware, and route names.
The Audit Portal contained several route groups covering authentication, administration, user views, and WHMCS API endpoints.
When a request returned a 404 or the wrong middleware appeared to be applied, this was one of the first commands we checked.
You can also filter the results:
php artisan route:list --path=audit
Or display only routes using a particular HTTP method:
php artisan route:list --method=POST
php artisan tinker
Tinker provides an interactive PHP shell with the Laravel application loaded:
php artisan tinker
You can access models, database connections, and application services directly from the shell.
During development, we used Tinker to test the WHMCS credit reduction logic.
For example:
$client = DB::connection('whmcs')->table('tblclients')->find(4521); $credits = DB::connection('whmcs') ->table('tblcredit') ->where('clientid', 4521) ->sum('amount');
This allowed us to inspect records across database connections and test queries without creating temporary scripts or browser endpoints.
php artisan config:show
The
config:show command can be used to inspect resolved configuration values:
php artisan config:show database
During the Audit Portal project, this helped us investigate a connection problem between the application and groupware databases.
Inspecting the resolved configuration made it easier to identify an incorrect hostname without adding temporary debugging code to the application.
Manage Caches for Performance
Before deploying the Audit Portal to production, we used Laravel’s caching commands to prepare the application for production use.
php artisan optimize
The optimize command provides a convenient way to cache several parts of the Laravel application:
php artisan optimize
The corresponding command for clearing those caches is:
php artisan optimize:clear
During development, clearing caches can be useful when configuration or application changes aren’t reflected as expected.
Laravel also provides more targeted cache commands:
php artisan config:cache php artisan route:cache php artisan view:cache php artisan event:cache
The corresponding clear commands are:
php artisan config:clear php artisan route:clear php artisan view:clear php artisan event:clear
On the Audit Portal, configuration caching was particularly relevant because the application used environment variables for database settings across three connections.
Handle Maintenance and Deployment
Artisan also provides commands for operational tasks during deployment.
php artisan down and php artisan up
To place the application into maintenance mode:
php artisan down
Laravel returns a 503 Service Unavailable response to incoming requests while the application is in maintenance mode.
The Audit Portal used maintenance mode during certain database changes involving the WHMCS integration. This helped prevent technicians from initiating workflows while those changes were being performed.
Laravel also supports a secret bypass:
php artisan down --secret="deploy-2026"
This allows authorized deployment checks to be performed while the application remains in maintenance mode.
Once deployment is complete:
php artisan up
php artisan storage:link
Applications that store publicly accessible files can use:
php artisan storage:link
This creates a symbolic link from:
public/storage
to:
storage/app/public
The Audit Portal allowed technicians to attach screenshots and log excerpts to audit records.
The storage link ensured those uploaded files could be accessed through the application after being stored on disk.
Manage Background Jobs With Queues
Some operations should not block an HTTP request.
The Audit Portal used Laravel’s queue system for tasks such as technician email notifications and heavier WHMCS synchronization operations.
php artisan queue:work
A queue worker can be started using:
php artisan queue:work
This starts a long-running process that retrieves and processes queued jobs.
We also used retry settings:
php artisan queue:work --tries=3 --backoff=30
The
--tries option controls the maximum number of attempts for a failed job, while --backoff specifies the delay between attempts.
These settings were useful when the WHMCS database experienced intermittent connection timeouts. Instead of immediately failing, synchronization jobs could retry after a delay.
Conclusion
Artisan becomes increasingly valuable as a Laravel application grows. In the Audit Portal, it supported everything from scaffolding and database management to scheduling, debugging, deployment, and custom business workflows.
Developers building or maintaining Laravel applications can also use our Laravel Services for help with Laravel development, customization, and ongoing application needs.
The key takeaway is simple: start with php artisan list, learn the commands relevant to your project, and turn repetitive tasks into reliable Artisan commands.