Skip to content

Artisan Commands

Artisan is Laravel's CLI tool. Below are the most commonly used commands for the CPR backend.

Development

CommandDescription
php artisan serveStart the development server
php artisan tinkerInteractive REPL for testing code
php artisan route:listList all registered routes
php artisan route:list --path=api/v1List API v1 routes only

Database

CommandDescription
php artisan migrateRun pending migrations
php artisan migrate:fresh --seedDrop all tables, re-migrate, and seed
php artisan migrate:rollbackRollback last migration batch
php artisan migrate:statusCheck migration status
php artisan db:seedRun all seeders
php artisan db:seed --class=RoleSeederRun a specific seeder

Code Generation

CommandDescription
php artisan make:model ModelName -mCreate model with migration
php artisan make:controller Api/V1/ExampleControllerCreate API controller
php artisan make:request StoreExampleRequestCreate Form Request
php artisan make:resource ExampleResourceCreate API Resource
php artisan make:factory ExampleFactoryCreate model factory
php artisan make:seeder ExampleSeederCreate seeder
php artisan make:migration create_examples_tableCreate migration
php artisan make:test Feature/Api/V1/ExampleTestCreate test file

Cache & Optimization

CommandDescription
php artisan config:cacheCache configuration (production)
php artisan config:clearClear config cache (development)
php artisan route:cacheCache routes (production)
php artisan route:clearClear route cache
php artisan view:cacheCache Blade views
php artisan view:clearClear view cache
php artisan optimizeRun all optimization commands
php artisan optimize:clearClear all caches

Queue

CommandDescription
php artisan queue:workStart processing queued jobs
php artisan queue:listenListen for jobs (restarts on code change)
php artisan queue:retry allRetry all failed jobs
php artisan queue:flushFlush all failed jobs

Logging & Debugging

CommandDescription
php artisan pailReal-time log tailing
php artisan pail --filter="error"Filter logs by level

Testing

CommandDescription
php artisan testRun all tests
php artisan test --parallel --processes=10Run tests in parallel
php artisan test --filter=PatientTestRun specific test

Useful Tips

List All Available Commands

bash
php artisan list

Get Help for a Command

bash
php artisan help migrate

Using with Sail (Docker)

When using Docker via Laravel Sail, prefix all commands:

bash
./vendor/bin/sail artisan migrate
./vendor/bin/sail artisan db:seed
./vendor/bin/sail artisan test

CPR - Clinical Patient Records