PHP Artisan Commands Guide
Complete reference for Laravel Artisan commands, testing, code quality, and development workflows.
Essential Commands for Every Engineer
php artisan test
Run all tests
php artisan pint
Fix code style
php artisan migrate
Run migrations
npm run quality
Full quality check
php artisan cache:clear
Clear all caches
php artisan tinker
Test code interactively
Daily Development Workflow
Commands you should use every day for smooth development.
๐ Start of Day
git pull origin main
Get latest changes from repository
composer install
Update PHP dependencies
php artisan migrate
Run new database migrations
php artisan config:clear
Clear configuration cache
๐ป During Development
php artisan serve
Start development server (port 8000)
npm run dev
Start Vite dev server for frontend
php artisan test --watch
Auto-run tests on file changes
php artisan tinker
Test code snippets interactively
โ Before Commit
php artisan pint
Fix code style issues automatically
php artisan test
Run all tests
npm run quality
Run full quality check (lint + analyze + test)
๐ End of Day
php artisan cache:clear
Clear development cache
git push origin feature-name
Backup your work to remote
๐งช Testing Commands
Run and manage test suites for your application.
PHP Artisan Commands
php artisan test
Run the entire test suite
php artisan test --testsuite=Unit
Run only unit tests
php artisan test --watch
Watch for file changes and re-run tests
php artisan test --coverage
Run tests with code coverage report
php artisan test --filter "TestName"
Run specific test or test class
php artisan test --stop-on-failure
Stop on first failure
NPM Shortcuts
npm test
Run all tests
npm run test:unit
Run unit tests only
npm run test:feature
Run feature tests only
npm run test:coverage
Run with coverage report
๐ Code Quality & Style
Ensure code follows standards and best practices.
Code Style (Pint)
php artisan pint --test
Check code style without fixing
php artisan pint
Fix code style issues automatically
Static Analysis (PHPStan)
vendor/bin/phpstan analyse
Run static analysis
vendor/bin/phpstan analyse --memory-limit=512M
Run with increased memory
NPM Shortcuts
npm run lint
Check code style only
npm run lint:fix
Fix code style
npm run analyze
Run static analysis
npm run quality
Lint + analyze + test
๐พ Database Operations
Manage database migrations, seeding, and operations.
Migrations
php artisan migrate
Run all pending migrations
php artisan migrate:rollback
Rollback last migration
php artisan migrate:fresh
Drop all tables and re-run migrations
php artisan migrate:fresh --seed
Fresh migrate with seeding
php artisan migrate:status
Show migration status
NPM Shortcuts
npm run migrate
Run migrations (with --force)
npm run fresh
Fresh migrate with seed
โก Cache Management
Clear and rebuild various application caches.
Clear Caches
php artisan cache:clear
Clear application cache
php artisan config:clear
Clear configuration cache
php artisan route:clear
Clear route cache
php artisan view:clear
Clear compiled views
Rebuild Caches
php artisan config:cache
Cache configuration files
php artisan route:cache
Cache routes for faster loading
php artisan optimize
Optimize for production
NPM Shortcuts
npm run clean
Clear all caches
npm run optimize
Optimize for production
๐ง Troubleshooting & Maintenance
Commands to diagnose and fix common issues.
Common Issues & Solutions
404 errors or strange behavior
php artisan optimize:clear && php artisan cache:clear
File permission issues
php artisan storage:link
Route not found
php artisan route:list | grep keyword
Class not found errors
composer dump-autoload
Diagnostics
php artisan about
Show application overview
php artisan tinker
Interactive REPL for testing code
Quick Reference Card
Testing
php artisan test
Style Fix
php artisan pint
Migrate
php artisan migrate
Clear Cache
php artisan cache:clear
Quality Check
npm run quality
Optimize
php artisan optimize