
Laravel tutorial most imprtant Arisan commands
Published: August 28, 2025
Laravel is one of the most popular PHP frameworks for modern web development, known for its elegant syntax and robust feature set. A key part of what makes Laravel developer-friendly is Artisan, Laravel’s built-in command-line interface.
Artisan provides a suite of commands to handle various aspects of building a web application, from generating boilerplate code to running database migrations. In essence, Artisan is an indispensable tool that comes with Laravel – it lives in your project’s root as the artisan
script and offers numerous helpful commands to assist you during development. By leveraging Artisan, developers can interact with Laravel projects via the terminal to expedite setup and maintenance tasks. Check out prices for web development.

Why Artisan Matters for Speed and Reliability
Artisan plays a critical role in speeding up development, automating routine tasks, and reducing the risk of errors. Instead of writing a lot of code or configuration by hand, you can use Artisan commands to generate files and execute operations with a single line.
This automation saves time and ensures consistency – for example, using Artisan to create a model with a migration means the file structure and boilerplate are set up for you, leaving less room for typos or mistakes. In fact, industry surveys indicate that developers who embrace command-line tools like Artisan report around 30% less time spent on repetitive tasks, translating to faster project delivery.
By handling tasks like database schema updates, cache clearing, and code generation through well-tested commands, Artisan helps maintain reliability across different environments. For instance, running database migrations via Artisan ensures that schema changes are applied uniformly, which improves consistency across deployments. In short, Artisan’s automation not only boosts developer productivity but also leads to fewer errors since many processes are standardized and executed by the framework itself rather than manually.

Top 10 Laravel Artisan Commands (and When to Use Them)
Now, let’s dive into some of the most useful Artisan commands every Laravel developer should know. These commands will help you develop, debug, and deploy Laravel applications more efficiently. For each command, we’ll explain what it does and provide a real-world use case demonstrating why it’s useful.
1. php artisan serve
One of the first commands you’ll encounter in Laravel is php artisan serve
. This command launches a local development web server at http://localhost:8000
by default. It provides a quick way to run your Laravel application locally without needing to configure a dedicated web server (Apache, Nginx, etc.). Simply navigate to your project folder in the terminal and run this command – Laravel will start listening on port 8000 (or a port you specify).
Use Case: php artisan serve
is typically used during development for testing your application. For example, if you’re building a new feature, you can start the local server and immediately access your app in a browser at http://127.0.0.1:8000
. It’s extremely convenient for development demos or when you want to share progress with a colleague on your network (you can use the --host
option to serve on your LAN). The importance of this command lies in its simplicity – you don’t have to set up XAMPP or Docker just to see your app running; Artisan does it for you with one command, eliminating complex server configuration. This means you spend less time fiddling with environment setup and more time writing code.
Why It’s Useful: It spins up a PHP development server quickly, so you can test changes in your Laravel app on the fly. Whenever you need to preview your work or perform quick UI/UX checks, artisan serve
has you covered. (Do note that this is meant for development only, not for production deployment.)
2. php artisan make:model Post -mcr
When starting a new feature or module in a Laravel app, you often need to create several related classes – a database migration, an Eloquent model, and perhaps a controller. Artisan can do all of this in one go. The command php artisan make:model Post -mcr
will generate a new Eloquent model class named Post, make a migration file for creating the corresponding database table, and create a new controller for the Post model, with resourceful methods. In short, -mcr
flags ensure that along with the model, you get a migration and a resourceful controller (with typical CRUD methods) for that model.
Use Case: Imagine you’re building a blog module. You know you’ll need a Post
model, a database table for posts, and a controller to handle post-related HTTP requests. Running php artisan make:model Post -mcr
instantly creates:
app/Models/Post.php
– the Eloquent model for posts.- a migration file (e.g.
2025_08_27_123456_create_posts_table.php
in the database/migrations folder) for theposts
table. app/Http/Controllers/PostController.php
– a controller pre-filled with resource methods (index, create, store, show, edit, update, destroy).
All these files are generated in one shot, with boilerplate code in place. This is hugely beneficial because it streamlines the setup of a new model and its related pieces. You don’t have to manually create each file or worry about forgetting a step – Artisan scaffolds a baseline for you.
Why It’s Useful: This command promotes efficiency and consistency. By using Artisan to scaffold the model, migration, and controller, you reduce the chance of errors (for example, you won’t mistype the table name in the migration because Artisan uses the model name to generate it). It also saves time: what might take several minutes of setup and file creation is done in seconds.
In a real-world team scenario, this helps maintain a standard structure across the codebase. (Tip: Laravel also offers the -a
/--all
flag which generates all related classes – migration, seeder, factory, and resource controller – for a model. Using -mcr
is a fine-grained approach when you specifically want a migration and controller with resource methods.)
3. php artisan migrate
Laravel’s migration system is a lifesaver for database schema management. The php artisan migrate
command runs all pending migrations, applying new changes to the database schema. Migrations are PHP classes that define how to create or modify tables (located in the database/migrations directory). By running artisan migrate
, you execute these classes to make sure the database structure matches your application’s requirements.
Use Case: Say you added a new migration file to create a comments table (perhaps by using make:migration
). Before the changes take effect, you need to apply this migration to the database. Running php artisan migrate
will execute the new migration, creating the comments
table in your database. This command is used whenever you have new migrations – commonly during development (when adding features) and during deployment (to ensure the production database is up-to-date with the latest schema).
Why It’s Useful: It’s essential for keeping your database schema in sync with your application’s code. Instead of manually running SQL or using a GUI to alter tables (which is error-prone and hard to track), migrations provide a version-controlled way to evolve the database. The migrate
command applies all those changes reliably.
This reduces errors because the same migration code can be run in different environments (development, staging, production) to reproduce the schema changes consistently. In short, php artisan migrate
automates what would otherwise be a manual database update process, ensuring every developer or server applies the exact same changes.
4. php artisan migrate:rollback
As a counterpart to migrate
, the php artisan migrate:rollback
command undoes the last batch of migrations. Each time you run migrations, Laravel tags them with a batch number. Rollback will revert all migrations from the most recent batch (essentially “undoing” those database changes). There’s also an option --step=<n>
if you want to roll back a specific number of migrations, but running it without options will roll back the latest batch.
Use Case: Rollback is extremely handy during development and testing. For example, if you ran a migration that added a new column or created a table, but then you realize there’s an issue with the migration (maybe a typo in the schema or a wrong default value), you can rollback to undo that change. After rolling back, you can fix the migration file and run migrate
again. This is much easier than manually dropping tables or columns. Another scenario: in a test environment, you might migrate a set of changes and later want to revert them to test the “down” path of your migration or to reset the database state – migrate:rollback
does that in one command.
Why It’s Useful: This command is vital for undoing migrations in case of errors or changed requirementsm. It adds a safety net – if something goes wrong with a deployment or a migration, you can quickly revert to the previous state. For developers, it means you can experiment with database changes and easily back out if needed. For businesses, this ability reduces the risk of downtime or data errors, since schema changes aren’t one-way trips; you have a controlled way to step back. In practice, using rollback in combination with migrate (and even php artisan migrate:refresh
which rolls back everything and re-runs) allows for an iterative development workflow when working on database design.
5. php artisan tinker
“Tinker” is the name of Laravel’s REPL (Read-Evaluate-Print Loop), an interactive shell for the Laravel framework. By running php artisan tinker
, you can enter an interactive PHP console that bootstraps your Laravel application. This means you have access to your application’s classes and can interact with them in real time. Tinker is powered by the PsySH console, providing a pleasant environment to run PHP code.
Use Case: Tinker is incredibly useful for trying out code quickly or performing ad-hoc tasks. For instance, if you want to test a portion of your code or interact with the database without writing a dedicated script, you can do it in Tinker. Need to create a new User model instance and save it? Just open Tinker and type the Eloquent code (User::create([...])
). Want to debug what a certain function returns or what a query builder yields? You can do it live. It’s also great for inspecting your models and relationships – e.g., fetch a user and check their related posts via $user->posts
. All of this happens within an interactive environment that has loaded your Laravel app’s context.
Why It’s Useful: Tinker provides a quick way to test and debug code in a running application context. It’s like having a sandbox for your Laravel app. Instead of writing test routes or temporary scripts to run some code, you can use Tinker to run it on the fly. This speeds up experimentation.
For example, when debugging an issue, you might replicate a scenario in Tinker to see what’s going wrong with a model or to hash a password using Laravel’s Hash facade, etc. For developers, this means faster feedback loops – you can try something and see the result immediately, which is great for learning and problem-solving. Remember, anything you do in Tinker (like creating records) will affect your database just as if the code ran in the app, so it’s best used on local or a safe environment.
6. php artisan route:list
As an application grows, it can have dozens or hundreds of routes (endpoints). The php artisan route:list
command outputs a table of all registered routes in your Laravel application. By default, it will show columns like HTTP method, URI, route name, the controller/action it’s tied to, and the middleware applied. You can also filter this list with options (for example, --method=GET
to filter by method, or --name=api.
to filter by name, etc.), but simply running route:list
gives a comprehensive overview.
Use Case: This command is invaluable for debugging and documentation. Suppose you’re unsure if a route has been defined for a certain controller or you forgot the exact URI or name of a route. Running php artisan route:list
will let you quickly find that information. For example, if an AJAX call in your frontend is failing with a 404, you can check route:list
to see if the route exists or if the HTTP verb matches. It’s also useful to verify that your routes file changes have taken effect. Many developers use this to grep for a specific controller or middleware to see all routes hitting that controller. Essentially, it’s a quick way to audit your routing setup.
Why It’s Useful: It helps ensure that routes are registered correctly and makes it easier to spot issues like duplicate routes or wrong HTTP methods. In a large project, keeping track of all endpoints can be challenging; route:list
serves as a live reference. This improves maintainability – new team members can run it to understand the available endpoints, and QA teams might use it to see what URLs to test. Additionally, by seeing the middleware column, you can verify security (e.g., certain routes are behind auth middleware). Overall, this command provides transparency into the application’s navigation structure, reducing the time developers spend hunting through route files.
Output of php artisan route:list
, showing a sample of routes defined in a Laravel application (columns for domain, HTTP method, URI, name, action, and middleware).
7. php artisan cache:clear
Laravel provides various caching mechanisms (for configuration, views, application data, etc.) to improve performance. Over time, or during development, you may need to clear cached data. The command php artisan cache:clear
will flush the application cache (the data that’s been cached using Laravel’s Cache facade or cache functions). This does not clear config or route cache (which have their own commands), but it clears the general cache store for your app.
Use Case: A common scenario for using cache:clear
is when you are developing and you change something that is being cached. For example, you might be caching some query results or parts of pages. If you don’t see your changes taking effect, you might need to clear the old cached values. Running this command ensures that the next request will recompute whatever data was cached. Another scenario is after deploying a new version of your application – you might clear the cache as a precaution so that no stale data lingers. In some cases, even during production troubleshooting, if users are seeing old data that should have been updated, clearing the cache can resolve the inconsistency (though one must be careful using it in production).
Why It’s Useful: It guarantees that outdated cache data doesn’t interfere with the latest changes to your application. Essentially, it wipes the slate clean for the parts of your app that rely on cached information. This is important for ensuring users see up-to-date information, and it’s a quick fix for certain issues (“have you tried clearing the cache?” is a common debugging step).
As a strategic benefit, being able to clear cache helps maintain consistency between deployments. (For a thorough reset, Laravel also provides php artisan optimize:clear
which clears all caches including route, config, and compiled files in one go.) Remember that after clearing cache, the first request might be slightly slower as it rebuilds the cache, but at least you know you’re working with fresh data. In summary, cache:clear
is a straightforward way to eliminate mysterious “stale data” problems by purging the application’s cached entries.
8. php artisan config:clear
In Laravel, configuration caching is a feature to boost performance by combining all config files into one cached file. The command php artisan config:cache
does that for production environments, but sometimes you need to undo this. php artisan config:clear
is the command that purges the configuration cache. It deletes the cached config file so that your application will load the configuration fresh from the config files and .env
on the next request.
Use Case: Typically, you use config:clear
in development if you had previously run config:cache
, or in any situation where you suspect the environment variables or config files changes aren’t being picked up. For example, if you changed an environment variable in the .env
file (say, turning on debug mode or changing a database credential) and your app still behaves as if the old value is in effect, it might be because the config was cached. Running php artisan config:clear
will ensure that Laravel discards the old cached settings and reads from the updated files. Another use case is during deployment: if your deployment process caches config for performance, but you need to rollback or adjust something, clearing config cache will make the app flexible to config changes again.
Why It’s Useful: It ensures your application is using the latest configuration values by removing any cached config data. In other words, it prevents confusion where the code and environment say one thing but the app is stuck using older settings. This command is critical if you ever run config:cache
(because once cached, changes to .env
won’t have effect until cleared).
Strategically, knowing about config:clear
means you can confidently use config caching in production for speed, while still having a way to update settings when needed. It reduces the risk of configuration-related issues during development and deployment. (As a best practice, you wouldn’t cache config in local development, but it might happen accidentally or via some tool – so this is your fix.) Overall, config:clear
helps maintain flexibility and correctness in how your app reads configuration.
9. php artisan storage:link
By default, Laravel applications store user-uploaded files (like photos, documents) in the storage/app/public directory. However, files in storage/app are not directly accessible via the web server for security reasons. The php artisan storage:link
command creates a symbolic link (symlink) from storage/app/public
to the public directory (public/storage
). This makes those storage files accessible through the public/storage
URL path. Essentially, after running this, a file saved at storage/app/public/example.png
can be retrieved in a browser at http://your-app.test/storage/example.png
.
Use Case: Whenever you set up file uploads or any feature that stores files, you should run php artisan storage:link
. For example, you added a profile picture upload for users. The picture file is saved in storage. To display that image on the website, the app needs a public URL. By linking storage to public, the image becomes accessible. This command is often run once when setting up a project (especially if you clone a project from repository or deploy to a new server) – you run it to ensure the storage symlink exists. It’s also used whenever you might reset or move the storage folder. If you deploy to a server and user-uploaded files appear to be 404 not found, chances are you forgot to create the storage link.
Why It’s Useful: It’s necessary for serving user-uploaded or dynamically generated files via HTTP. Without this, those files remain trapped in the storage folder and cannot be accessed by browsers. The Artisan command automates the creation of the correct symlink with the proper targets. According to Laravel’s documentation, you should run this command to make files in the storage public
disk accessible from the web – otherwise features like displaying images or downloading user files won’t work out of the box. In real-world terms, it prevents broken images or inaccessible downloads on your site.
From a maintenance perspective, using storage:link
is much easier and less error-prone than manually typing OS-specific symlink commands. It encapsulates the correct paths for you. In summary, whenever your application deals with files intended for public access, php artisan storage:link
is the one-time step that ensures those files can actually be reached by the end users.
(Bonus tip: In Laravel, you can configure additional storage symlinks if needed in filesystems.php
configuration – running storage:link
will create all configured links, not just the default one. And if needed, there’s also a storage:unlink
command to remove symlinks.), with good website, you have to have and great graphic design.

Strategic Benefits of Using Artisan (Efficiency, Maintainability, Deployment Speed)
Mastering Artisan commands offers several strategic advantages for both developers and businesses:
- Developer Efficiency: Artisan drastically cuts down the time to perform common tasks. Generating code with commands like
make:model
or running automated migrations means developers spend less time on setup and rote work and more time on the important business logic. This boost in productivity can accelerate development cycles. In fact, as mentioned, studies have shown significant reductions in time spent on routine tasks when using CLI tool. Faster development means faster time-to-market for features, which is a direct benefit to businesses. - Consistency and Maintainability: When developers use Artisan to generate code and manage the application, the resulting structure is consistent. For example, a controller generated via Artisan will have the same skeleton methods in every project. This consistency makes the codebase easier to maintain and navigate, especially for onboarding new team members. It also reduces human error – using the built-in commands ensures things are done “the Laravel way” (e.g., a migration generated by Artisan is less likely to contain syntax errors than one written manually from scratch). A more maintainable codebase means fewer bugs and lower long-term costs.
- Automation and Reliability in Deployment: Artisan commands can be integrated into deployment scripts or Continuous Integration/Deployment (CI/CD) pipelines. For instance, a typical deployment might include steps like
php artisan migrate --force
(to apply new migrations),php artisan config:cache
(to optimize config loading), orphp artisan queue:restart
(to restart background workers). Using these commands in automation ensures that nothing is forgotten during deployment and that each deployment is performed in a repeatable, reliable way. This reduces the risk of mistakes that could cause downtime. Moreover, commands likeconfig:cache
androute:cache
significantly improve performance in production by caching vital data – leading to faster response times for users. In short, Artisan enables both speed and safety during deployments: speed by automating tasks, and safety by providing rollback mechanisms (like migrations rollback, orartisan down
for maintenance mode if needed). - Empowering Developers & Teams: Artisan is not just about saving time – it also provides helpful tools for quality. Commands like
route:list
andtinker
help developers debug and ensure the app is behaving correctly, which leads to higher quality output. Teams that leverage Artisan can standardize their workflow (everyone runs the same commands for setting up, building, and deploying), which improves collaboration. Less guesswork and manual steps mean smoother project management overall.
From a business perspective, all these benefits translate to cost savings and improved agility. Projects can be delivered quicker and with fewer errors. A well-optimized deployment process (thanks to Artisan commands) means the application can be updated frequently with minimal downtime, allowing the business to respond faster to market needs. In a nutshell, Artisan helps development teams work smarter and deliver robust applications more rapidly.
(As a best practice, it’s worth noting that Laravel’s own creators recommend using Artisan for as many tasks as possible – it’s a core part of the framework’s design. Embracing it fully can unlock the framework’s full potential in terms of developer experience and application performance.)
Conclusion
Laravel’s Artisan CLI is truly a powerful ally in a developer’s toolkit. From quick commands like serving the app locally to more complex ones like rolling back database changes, these Artisan commands make development more efficient, error-free, and enjoyable. Mastering the commands we’ve discussed – and others offered by Artisan – will not only make you a faster developer but also empower you to leverage Laravel’s full potential in building high-quality applications. Whether you’re crafting a simple blog or a large enterprise system, using Artisan helps ensure a streamlined and effective development process.
New web is waiting for you
We turn your website visitors into euros. Contact us and increase your profits today!