Skip to main content

50 Artisan Commands Every Developer Should Know

50 Artisan Commands Every Developer Should Know in Laravel

Published on: July 15, 2025   |   Author: Rana Saha

Laravel Artisan is a powerful command-line tool that helps developers manage their applications with ease. From generating files to running tests, Artisan commands save time and reduce repetitive work. In this blog, we’ll explore the top 50 Artisan commands every Laravel developer should know.

๐Ÿ“ Project & Environment

  • php artisan serve – Run Laravel development server.
  • php artisan config:cache – Cache the configuration files.
  • php artisan config:clear – Clear the config cache.
  • php artisan cache:clear – Clear the application cache.
  • php artisan route:cache – Cache the route definitions.
  • php artisan route:clear – Remove the route cache.
  • php artisan view:clear – Clear compiled view files.
  • php artisan optimize – Optimize the framework for better performance.

๐Ÿงฑ Migrations & Database

  • php artisan migrate – Run the database migrations.
  • php artisan migrate:rollback – Rollback the last migration.
  • php artisan migrate:reset – Rollback all migrations.
  • php artisan migrate:refresh – Reset and re-run all migrations.
  • php artisan migrate:fresh – Drop all tables and re-run all migrations.
  • php artisan db:seed – Seed the database with records.
  • php artisan db:wipe – Drop all tables, views, and types.
  • php artisan make:migration create_posts_table – Create a new migration file.

๐Ÿงฌ Models & Factories

  • php artisan make:model Post – Create a new model.
  • php artisan make:model Post -m – Create model with migration.
  • php artisan make:model Post -mf – Model with migration and factory.
  • php artisan make:factory PostFactory – Create a model factory.

๐Ÿง  Controllers & Resources

  • php artisan make:controller PostController – Create a new controller.
  • php artisan make:controller PostController --resource – Resourceful controller.
  • php artisan make:controller Api/PostController --api – API controller.

๐Ÿงฉ Middleware, Requests & Events

  • php artisan make:middleware CheckRole – Create a middleware.
  • php artisan make:request StorePostRequest – Create a form request class.
  • php artisan make:event PostCreated – Create an event.
  • php artisan make:listener SendNotification --event=PostCreated – Create event listener.

๐Ÿ’ก Commands, Jobs & Notifications

  • php artisan make:command SendEmails – Create a custom Artisan command.
  • php artisan make:job ProcessPodcast – Create a job.
  • php artisan make:notification InvoicePaid – Create a notification.
  • php artisan queue:work – Process jobs from the queue.
  • php artisan queue:restart – Restart queue workers.

๐Ÿงช Testing

  • php artisan test – Run all PHPUnit tests.
  • php artisan make:test PostTest – Create a test class.
  • php artisan test --filter=PostTest – Run specific test class.

๐ŸŽ›️ Miscellaneous

  • php artisan tinker – Interact with your app from the command line.
  • php artisan schedule:run – Run scheduled tasks.
  • php artisan event:cache – Cache events and listeners.
  • php artisan storage:link – Create a symbolic link to storage.
  • php artisan down – Put the app into maintenance mode.
  • php artisan up – Bring the app out of maintenance mode.

๐Ÿ› ️ Bonus: List All Artisan Commands

  • php artisan list – Display all available Artisan commands.
  • php artisan help migrate – Display help for a specific command.

๐Ÿš€ Conclusion

Mastering Laravel Artisan commands is key to faster development and better workflow. These commands not only reduce manual effort but also help you follow Laravel’s best practices. Bookmark this post or print it as a reference for your daily development.

Did I miss any important command you use daily? Drop a comment and share your thoughts!


๐Ÿ“š Also Read: 15 Common Git Commands Every Developer Should Know

Comments

Popular posts from this blog

How to Use L5-Swagger for API Documentation in Laravel

Integrating Swagger in Laravel: Annotations, JSON, and YAML What is Swagger? Swagger (OpenAPI) is a powerful tool for generating interactive API documentation. It helps developers understand and test your API easily. ✅ Step-by-Step Guide to Setup L5-Swagger 1. Install L5-Swagger Package composer require "darkaonline/l5-swagger" 2. Publish Config & View Files This command publishes the config file to config/l5-swagger.php : php artisan vendor:publish --provider "L5Swagger\L5SwaggerServiceProvider" 3. Configure Swagger (Optional) Edit the file config/l5-swagger.php to update: API Title Base Path Directories to scan for annotations 4. Add Swagger Annotations Add these before your controller class: /** * @OA\Info( * version="1.0.0", * title="Your API Title", * description=...

How to Send Emails in Node.js using Nodemailer and Ethereal

How to Send Email in Node.js using Nodemailer Email functionality is essential in modern web applications. Whether you're sending confirmation emails, password resets, or notifications, Node.js with Nodemailer makes this simple. In this blog, we'll walk through setting up email sending using Node.js , Express , and Ethereal Email for testing. ๐Ÿงพ Prerequisites Node.js installed Basic knowledge of Express.js Internet connection ๐Ÿ“ Project Structure project-folder/ ├── index.js ├── .env ├── package.json └── app/ └── controller/ └── emailSendController.js ๐Ÿ“ฆ Step 1: Install Dependencies npm init -y npm install express nodemailer dotenv npm install --save-dev nodemon ๐Ÿ” Configure nodemon (Optional but Recommended) Update your package.json with a custom start script: "scripts": { "start": "nodemon index.js" } ๐Ÿ” Step 2: Create a .env File Create a .env file a...

Realtime Device Tracker using Node.js, Socket.IO & Leaflet

Realtime Device Tracker using Node.js, Socket.IO & Leaflet In this tutorial, you’ll learn how to build a realtime location tracking application that uses the browser’s GPS, Socket.IO for live communication, and Leaflet.js to display users on a map. ๐Ÿš€ Project Overview Backend: Node.js, Express.js, Socket.IO Frontend: HTML, Leaflet.js, Socket.IO client Features: Live GPS tracking, multi-user map, disconnect cleanup ๐Ÿ“ Folder Structure project-root/ ├── app.js ├── package.json ├── src/ │ ├── public/ │ │ ├── css/ │ │ │ └── style.css │ │ └── js/ │ │ └── script.js │ ├── routes/ │ │ └── routers.js │ ├── socket/ │ │ └── socketHandler.js │ └── views/ │ └── index.ejs ๐Ÿง  How It Works Each user shares their location using the browser's navigator.geolocation API. Location is sent to the server via Socket.IO . The server broadcasts each user’s position to all clien...