70+ PHP Laravel Artisan CLI Commands (Cheatsheet)

PHP Laravel ARTISAN Commands Techhyme

Laravel, one of the most popular PHP frameworks, provides developers with a powerful command-line interface (CLI) tool called Artisan. Artisan is an essential part of Laravel, offering a wide range of commands that streamline various development tasks. In this article, we will explore the available Artisan CLI commands and their functionalities.

Before we delve into the commands, it’s crucial to understand that you can access Artisan by running the following command from your terminal or command prompt:

php artisan

This will display a list of available commands along with a brief description of each. Let’s explore some of the most commonly used Artisan commands and what they do:

Main Commands:

1. `php artisan clear-compiled`: This command removes the compiled class file, helping to clean up the application’s cached files.

2. `php artisan db`: Start a new database CLI session. This allows you to interact with your database directly from the command line.

3. `php artisan docs`: Access the Laravel documentation directly from the command line. A great way to quickly look up information.

4. `php artisan down`: Puts the application into maintenance mode, displaying a custom message to users. Useful during deployments or maintenance.

5. `php artisan dump-server`: Starts the dump server to collect dump information. Helpful for debugging purposes.

6. `php artisan env`: Displays the current framework environment, allowing you to check the current environment settings.

7. `php artisan help`: Displays help for a specific command. For example, `php artisan help make:controller` will show help for creating a new controller.

8. `php artisan inspire`: Displays an inspiring quote to brighten your day.

9. `php artisan list`: Lists all available commands with brief descriptions.

10. `php artisan migrate`: Runs the database migrations, creating or updating the database schema as per the migration files.

11. `php artisan optimize`: Caches the framework bootstrap files to speed up the application’s performance.

12. `php artisan preset`: Swap the front-end scaffolding for the application. Laravel provides different preset options like React, Vue.js, Bootstrap, etc.

13. `php artisan serve`: Serves the application on the PHP development server, making it accessible during development.

14. `php artisan tinker`: Launches an interactive shell where you can interact with your application and its components.

15. `php artisan up`: Brings the application out of maintenance mode, allowing normal operations.

App and Configuration Commands:

16. `php artisan app:name`: Sets the application namespace, helping avoid conflicts when developing packages.

17. `php artisan config:cache`: Creates a cache file for faster configuration loading, improving the application’s performance.

18. `php artisan config:clear`: Removes the configuration cache file.

Database and Migration Commands:

19. `php artisan db:seed`: Seeds the database with records using defined seed classes.

20. `php artisan db:show`: Displays information about the given database, showing tables, columns, and indexes.

21. `php artisan db:table`: Displays information about the given database table.

22. `php artisan db:wipe`: Drops all tables, views, and types from the database.

Model and Eloquent Commands:

23. `php artisan model:prune`: Prunes models that are no longer needed, helping to optimize the application.

24. `php artisan model:show`: Shows information about an Eloquent model, including attributes and relationships.

Artisan Make Commands:

Laravel’s “make” commands are powerful shortcuts for generating various components of your application. Each of these commands creates a stub file that you can then customize according to your needs.

25. `php artisan make:cast`: Creates a new custom Eloquent cast class.

26. `php artisan make:channel`: Creates a new channel class for broadcasting events.

27. `php artisan make:command`: Generates a new Artisan command.

28. `php artisan make:component`: Creates a new view component class.

29. `php artisan make:controller`: Generates a new controller class.

30. `php artisan make:event`: Creates a new event class.

31. `php artisan make:exception`: Generates a new custom exception class.

32. `php artisan make:factory`: Creates a new model factory class for generating fake data.

33. `php artisan make:job`: Generates a new job class for queuing tasks.

34. `php artisan make:listener`: Creates a new event listener class.

35. `php artisan make:mail`: Generates a new email class for sending emails.

36. `php artisan make:middleware`: Creates a new middleware class for filtering HTTP requests.

37. `php artisan make:migration`: Creates a new migration file for database schema changes.

38. `php artisan make:model`: Generates a new Eloquent model class for database interactions.

39. `php artisan make:notification`: Creates a new notification class for sending notifications.

40. `php artisan make:observer`: Generates a new observer class for Eloquent model events.

41. `php artisan make:policy`: Creates a new policy class for authorization rules.

42. `php artisan make:provider`: Generates a new service provider class.

43. `php artisan make:request`: Creates a new form request class for form validation.

44. `php artisan make:resource`: Generates a new resource class for API responses.

45. `php artisan make:rule`: Creates a new validation rule class.

46. `php artisan make:scope`: Generates a new scope class for Eloquent queries.

47. `php artisan make:seeder`: Creates a new seeder class for database seeding.

48. `php artisan make:test`: Generates a new test class for unit or feature testing.

Migration Commands:

49. `php artisan migrate:fresh`: Drops all tables and re-runs all migrations, effectively resetting the database.

50. `php artisan migrate:install`: Creates the migration repository.

51. `php artisan migrate:refresh`: Resets and re-runs all migrations, effectively refreshing the database.

52. `php artisan migrate:reset`: Rolls back all database migrations.

53. `php artisan migrate:rollback`: Rolls back the last database migration.

54. `php artisan migrate:status`: Shows the status of each migration, indicating which ones have been run.

Queue Commands:

Laravel’s queue system allows you to handle time-consuming tasks asynchronously. The following commands help manage the queue:

55. `php artisan queue:batches-table`: Create a migration for the batches database table.

56. `php artisan queue:clear`: Delete all jobs from the specified queue.

57. `php artisan queue:failed`: List all failed queue jobs.

58. `php artisan queue:failed-table`: Create a migration for the failed queue jobs database table.

59. `php artisan queue:flush`: Flush all failed queue jobs.

60. `php artisan queue:forget`: Delete a failed queue job.

61. `php artisan queue:listen`: Listen to a given queue.

62. `php artisan queue:monitor`: Monitor the size of specified queues.

63. `php artisan queue:prune-batches`: Prune stale entries from the batches database.

64. `php artisan queue:prune-failed`: Prune stale entries from the failed jobs table.

65. `php artisan queue:restart`: Restart queue worker daemons after their current job.

66. `php artisan queue:retry`: Retry a failed queue job.

67. `php artisan queue:retry-batch`: Retry the failed jobs for a batch.

68. `php artisan queue:table`: Create a migration for the queue jobs database table.

69. `php artisan queue:work`: Start processing jobs on the queue as a daemon.

Route Commands:

70. `php artisan route:cache`: Creates a route cache file for faster route registration.

71. `php artisan route:clear`: Removes the route cache file.

72. `php artisan route:list`: Lists all registered routes and their corresponding controllers/handlers.


Laravel’s Artisan CLI is a versatile and powerful tool that simplifies various development tasks. From managing the database to generating new components and optimizing the application, Artisan provides a range of commands to enhance productivity and streamline the development process. As you work with Laravel, you’ll find yourself relying heavily on Artisan to perform routine tasks efficiently. So, don’t hesitate to explore these commands and utilize them to their fullest to make your Laravel development journey even more enjoyable and productive. Happy coding!

The article provides an overview of Laravel Artisan commands, but the actual implementation and functionality might change over time with new Laravel versions.

You may also like:

Related Posts

Leave a Reply