Laravel services for development, Artisan commands, database management, scheduling, debugging, and deployment.

Laravel Artisan is the command-line interface that facilitates developers in performing common tasks with a Laravel application. It can be used to generate application files, manage databases, execute scheduled tasks, troubleshoot problems, manage caches, and manage queues.

During the development of the Enterprise Audit Portal using Laravel 11, our team always relied on Artisan throughout the project. It performed server audits and managed data for technicians and billing across three MySQL databases. This experience revealed to us the most valuable of the Artisan commands for our everyday development and maintenance tasks.

These are the major Artisan commands that we used.

1. php artisan list

Start with:

php artisan list

This shows the commands available to Artisan, such as custom commands created for the application.

One such command that we added to our Audit Portal was sync:missing-time-logs. New developers were able to view the tools in the project with ease when they ran php artisan list.

This will produce the model at:

php artisan

to get the same command list.

2. php artisan serve

Use this command to start the Laravel development server:

php artisan serve

By default, the application runs at http://127.0.0.1:8000.

If that port is already in use, choose another one:

php artisan serve –port=8080

We used this during the early development of the Audit Portal before setting up Apache locally.

Explore Our Laravel Services.

Chat animation


3. make Commands

Artisan can create many common Laravel files for you.

Create a model

php artisan make:model Server

This creates the model at:

app/Models/Server.php

You can also create related files at the same time:

php artisan make:model AuditDetail -mcfs

This creates the model, migration, controller, factory, and seeder.

Create a controller

php artisan make:controller AuditController

For a resource controller:

php artisan make:controller AuditController --resource

For a single-action controller:

php artisan make:controller ReduceCreditController --invokable

We used resource controllers for common audit operations and an invokable controller for the WHMCS credit reduction workflow.

Create middleware

php artisan make:middleware VerifyTechnicianAccess

Our customised middleware verified that if a user was logged on, then they were a member of the appropriate technician team before granting access to the audit records.

Create a form request

php artisan make:request StoreAuditRequest

We used request classes such as StoreAuditRequest and UpdateAuditRequest to keep validation and authorization rules outside the controllers.

4. Database Commands

Artisan also makes database work easier.

Create a migration

php artisan make:migration create_audit_details_table

This creates a migration inside database/migrations/.

For another database connection, our project used:

Schema::connection('whmcs')->table('tblcredit', function (Blueprint $table) {

Run migrations

php artisan migrate

This runs pending migrations.

Other useful commands include:


php artisan migrate:rollback
php artisan migrate:fresh
php artisan migrate:fresh --seed
php artisan migrate:status

We often used migrate:fresh –seed to rebuild local databases and load test data.

Create and run seeders

Create a seeder with:

php artisan make:seeder ServerSeeder

Run all seeders:

php artisan db:seed

Or run one specific seeder:

php artisan db:seed --class=ServerSeeder

In the Audit Portal, seeders helped developers set up servers, schedules, and technician assignments without adding test data manually.

5. Custom Artisan Commands

You can create commands for tasks specific to your application.

php artisan make:command SyncMissingTimeLogs

Our sync:missing-time-logs command compared completed audit records with WHMCS time logs. If a completed audit did not have a matching time entry, the command created one.

We also added a –dry-run option so administrators could review the changes before writing data:

php artisan sync:missing-time-logs --month=2026-05 --dry-run

The same command could also be triggered from the admin panel.

6. Task Scheduling

The Audit Portal generated monthly audits automatically. Laravel’s scheduler handled this task.

In Laravel 11, the schedule was defined in routes/console.php:

Schedule::command(‘generate:monthly-audits’)->monthlyOn(1, ’00:00′);

The server only needed one cron entry:

* * * * * cd /path-to-project && php artisan schedule:run >> /dev/null 2>&1

Laravel checks the schedule every minute and runs tasks when they are due.

To view scheduled tasks, use:

php artisan schedule:list

This helped us check the schedule and its next execution time during deployment.

7. Debugging Commands

View application routes

php artisan route:list

This shows the application’s routes, HTTP methods, controllers, middleware, and route names.

You can also filter the results:

php artisan route:list --path=audit

php artisan route:list --method=POST

We used this when investigating 404 errors and unexpected middleware behavior.

Use Tinker

php artisan tinker

Tinker provides an interactive PHP shell with the Laravel application loaded.

We used it to test database queries and check WHMCS billing data:


$client = DB::connection('whmcs')->table('tblclients')->find(4521);

$credits = DB::connection('whmcs')
->table('tblcredit')
->where('clientid', 4521)
->sum('amount');

This was useful when checking billing logic without creating temporary scripts.

Check configuration

php artisan config:show database

This displays the resolved database configuration and helped us find connection settings that were causing problems.

8. Cache and Optimization Commands

Before deployment, we used:

php artisan optimize

Laravel also provides:

php artisan optimize:clear

For individual caches, you can use:


php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan event:cache

To clear them:


php artisan config:clear
php artisan route:clear
php artisan view:clear
php artisan event:clear

These commands helped us prepare the Audit Portal for production and manage its cached configuration, routes, views, and events.

9. Maintenance Commands

To place the application in maintenance mode:

php artisan down

Laravel then returns a 503 response to incoming requests.

For deployment checks, we also used a secret bypass:

php artisan down --secret="deploy-2026"

After maintenance, restore the application with:

php artisan up

Create the storage link

For public uploaded files, use:

php artisan storage:link

The Audit Portal allowed technicians to attach screenshots and log files to audit records. This command made those files accessible through the expected public storage path.

10. Queue Commands

For tasks that should run in the background, Laravel provides queues.

Start a queue worker with:

php artisan queue:work

We used queues for technician email notifications and heavier WHMCS synchronization tasks.

You can also control retries:

php artisan queue:work --tries=3 --backoff=30

Here, –tries controls the number of attempts, while –backoff sets the delay between attempts.

This helped when temporary WHMCS database connection issues caused synchronization jobs to fail.

Conclusion

Artisan can be very helpful beyond controller creation and migrations. We used it in the Audit Portal project for development, database maintenance, custom tasks, database scheduling, debugging, caching, deployment, and queues.

If you are new to Laravel, start with:

php artisan list

Then view the commands for your project’s needs. Custom Artisan commands can also be used to perform some of the same tasks that are repeated throughout your application, but require less manual effort.