Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### âī¸ General Commands
- | Command | Description | Example Usage |
- | ---------------------------- | ------------------------------------------------- | -------------------------- |
- | `php artisan list` | Lists all available Artisan commands. | `php artisan list` |
- | `php artisan help <command>` | Displays help information for a specific command. | `php artisan help migrate` |
- | `php artisan tinker` | Opens the interactive REPL for Laravel. | `php artisan tinker` |
- | `php artisan inspire` | Displays a random inspirational quote. | `php artisan inspire` |
- ### đī¸ Application Setup & Configuration
- | Command | Description | Example Usage |
- | ---------------------------- | -------------------------------------------------------------- | ---------------------------- |
- | `php artisan key:generate` | Generates a new application key. | `php artisan key:generate` |
- | `php artisan config:cache` | Combines and caches all config files for faster performance. | `php artisan config:cache` |
- | `php artisan config:clear` | Clears the configuration cache. | `php artisan config:clear` |
- | `php artisan cache:clear` | Clears the entire application cache. | `php artisan cache:clear` |
- | `php artisan route:cache` | Caches all routes for better performance. | `php artisan route:cache` |
- | `php artisan route:clear` | Clears the route cache. | `php artisan route:clear` |
- | `php artisan view:clear` | Clears all compiled Blade view files. | `php artisan view:clear` |
- | `php artisan event:clear` | Clears cached events and listeners. | `php artisan event:clear` |
- | `php artisan optimize` | Optimizes the application by caching configuration and routes. | `php artisan optimize` |
- | `php artisan optimize:clear` | Clears all cached data (config, route, view, event, etc.). | `php artisan optimize:clear` |
- ### đ§ą Database & Migrations
- | Command | Description | Example Usage |
- | ------------------------------ | ----------------------------------------------------- | ----------------------------------------------- |
- | `php artisan migrate` | Runs all outstanding migrations. | `php artisan migrate` |
- | `php artisan migrate:rollback` | Rolls back the last batch of migrations. | `php artisan migrate:rollback` |
- | `php artisan migrate:reset` | Rolls back all migrations. | `php artisan migrate:reset` |
- | `php artisan migrate:refresh` | Resets and re-runs all migrations. | `php artisan migrate:refresh` |
- | `php artisan migrate:fresh` | Drops all tables and re-runs all migrations. | `php artisan migrate:fresh` |
- | `php artisan make:migration` | Creates a new migration file. | `php artisan make:migration create_posts_table` |
- | `php artisan db:seed` | Seeds the database with test data. | `php artisan db:seed` |
- | `php artisan make:seeder` | Creates a new database seeder class. | `php artisan make:seeder UsersTableSeeder` |
- | `php artisan migrate:status` | Displays the status of each migration. | `php artisan migrate:status` |
- | `php artisan db:wipe` | Drops all tables, views, and types from the database. | `php artisan db:wipe` |
- ### đ§Š Code Generation
- | Command | Description | Example Usage |
- | ------------------------------- | ---------------------------------------------------------------- | ----------------------------------------------------- |
- | `php artisan make:controller` | Creates a new controller class. | `php artisan make:controller PostController` |
- | `php artisan make:model` | Creates a new Eloquent model class. | `php artisan make:model Post` |
- | `php artisan make:model -mcr` | Creates a model with migration, controller, and resource routes. | `php artisan make:model Post -mcr` |
- | `php artisan make:middleware` | Creates a new middleware class. | `php artisan make:middleware CheckAdmin` |
- | `php artisan make:request` | Creates a new form request class. | `php artisan make:request StorePostRequest` |
- | `php artisan make:policy` | Creates a new policy class. | `php artisan make:policy PostPolicy` |
- | `php artisan make:command` | Creates a new Artisan command class. | `php artisan make:command SendEmails` |
- | `php artisan make:event` | Creates a new event class. | `php artisan make:event UserRegistered` |
- | `php artisan make:listener` | Creates a new event listener class. | `php artisan make:listener SendWelcomeEmail` |
- | `php artisan make:job` | Creates a new job class. | `php artisan make:job ProcessOrder` |
- | `php artisan make:factory` | Creates a model factory file. | `php artisan make:factory PostFactory` |
- | `php artisan make:notification` | Creates a new notification class. | `php artisan make:notification InvoicePaid` |
- | `php artisan make:mail` | Creates a new mailable class. | `php artisan make:mail OrderShipped` |
- | `php artisan make:test` | Creates a new test class. | `php artisan make:test PostTest` |
- | `php artisan make:observer` | Creates a model observer class. | `php artisan make:observer UserObserver --model=User` |
- | `php artisan make:provider` | Creates a new service provider class. | `php artisan make:provider EventServiceProvider` |
- ### đ§âđģ Route & Controller Utilities
- | Command | Description | Example Usage |
- | ------------------------- | ------------------------------------------------------------ | ------------------------- |
- | `php artisan route:list` | Lists all registered routes with methods, URIs, and actions. | `php artisan route:list` |
- | `php artisan route:cache` | Compiles and caches routes for performance. | `php artisan route:cache` |
- | `php artisan route:clear` | Clears the route cache. | `php artisan route:clear` |
- ### đ§° Queue & Job Management
- | Command | Description | Example Usage |
- | --------------------------- | --------------------------------------------------------- | --------------------------- |
- | `php artisan queue:work` | Processes jobs from the queue. | `php artisan queue:work` |
- | `php artisan queue:listen` | Listens to a queue and processes new jobs as they arrive. | `php artisan queue:listen` |
- | `php artisan queue:retry` | Retries a failed job by its ID. | `php artisan queue:retry 5` |
- | `php artisan queue:failed` | Lists all failed jobs. | `php artisan queue:failed` |
- | `php artisan queue:flush` | Deletes all failed jobs. | `php artisan queue:flush` |
- | `php artisan queue:restart` | Restarts queue workers after code changes. | `php artisan queue:restart` |
- ### đšī¸ Server & Environment
- | Command | Description | Example Usage |
- | ------------------- | ----------------------------------------------- | ------------------------------- |
- | `php artisan serve` | Starts the Laravel development server. | `php artisan serve --port=8080` |
- | `php artisan env` | Displays the current environment. | `php artisan env` |
- | `php artisan down` | Puts the application into maintenance mode. | `php artisan down` |
- | `php artisan up` | Brings the application out of maintenance mode. | `php artisan up` |
- ### đ§Ž Testing & Debugging
- | Command | Description | Example Usage |
- | --------------------------- | ---------------------------------------------- | ------------------------------------ |
- | `php artisan test` | Runs PHPUnit or Pest tests. | `php artisan test` |
- | `php artisan test --filter` | Runs tests matching the given name or pattern. | `php artisan test --filter=UserTest` |
- | `php artisan schedule:run` | Runs scheduled tasks. | `php artisan schedule:run` |
- | `php artisan schedule:test` | Shows which tasks are due to run. | `php artisan schedule:test` |
- ### đĨ Commonly Used Command Combinations & Flags
- | Command | Description | Example Usage |
- | ---------------------------------------------- | ---------------------------------------------------------------------------------- | --------------------------------------------------------------- |
- | `php artisan migrate:fresh --seed` | Drops all tables, re-runs migrations, and then seeds the database. | `php artisan migrate:fresh --seed` |
- | `php artisan migrate:refresh --seed` | Refreshes migrations and re-runs seeders. | `php artisan migrate:refresh --seed` |
- | `php artisan make:model -m` | Creates a model and its migration file. | `php artisan make:model Product -m` |
- | `php artisan make:model -mcr` | Creates model, migration, controller, and resource routes. | `php artisan make:model Post -mcr` |
- | `php artisan test --parallel` | Runs tests in parallel for faster execution. | `php artisan test --parallel` |
- | `php artisan schedule:run >> /dev/null 2>&1` | Common crontab entry to run Laravel's scheduler every minute. | `* * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1` |
- | `php artisan serve --host=0.0.0.0 --port=8080` | Runs the development server accessible from the network. | `php artisan serve --host=0.0.0.0 --port=8080` |
- | `php artisan queue:work --tries=3` | Processes queued jobs and retries failed ones up to 3 times. | `php artisan queue:work --tries=3` |
- | `php artisan storage:link` | Creates a symbolic link for public storage (used after migrations or deployments). | `php artisan storage:link` |
Advertisement