The terminal is the most loyal friend of Laravel developers. **Artisan** is Laravel's command-line interface, and it condenses dozens of tasks we would do manually into seconds.
Here are the life-saving commands you'll often need in your project, and what they do:
## 1. Basic Commands (Starter Pack)
These are used to get the project up and running and to understand the environment.
* `php artisan serve`
* Starts your project on a local server (localhost:8000).
* `php artisan list`
* Dumps a list of all the commands you can use.
* `php artisan help [command_name]`
* Shows how to use a command and which parameters it accepts.
* `php artisan tinker`
* **My favorite!** Opens a "playground" where you can run database queries and play with models without writing code.
---
## 2. "Make" Family (Generators)
Instead of right-clicking and saying "New File" to create files, use these. Template codes come automatically.
* `php artisan make:model Urun -m`
* Creates a Model named `Urun`. The `-m` suffix means "Prepare its migration file as well".
* `php artisan make:controller UrunController --resource`
* Creates a full Controller with ready-made methods like index, create, store.
* `php artisan make:request UrunKayitRequest`
* Creates a special request file to separate form validation processes from the controller.
* `php artisan make:seeder UrunSeeder`
* Creates a file to add fake or test data to the database.
---
## 3. Database Operations (Migrations)
Managing database tables has never been easier.
* `php artisan migrate`
* Runs pending migration files and creates tables in the database.
* `php artisan migrate:rollback`
* Reverts the last operation (Saves lives if you make a mistake).
* `php artisan migrate:fresh --seed`
* **Warning!** Deletes all tables, recreates them, and seeds them with test data. Ideal for starting from scratch during development.
---
## 4. Cleaning and Performance (Cache)
Sometimes the changes you make (especially .env or route changes) are not immediately reflected. Here's the solution:
* `php artisan optimize:clear`
* **One Shot:** Clears everything, including routes, views, config, and cache.
* `php artisan route:list`
* Lists all URLs in your project and which Controller they go to.
* `php artisan config:cache`
* Caches the configuration files for performance when taking the project live (production).
---
### A Little Tip
If you're too lazy to type the commands, you can define abbreviations (aliases) in your terminal. For example, writing just `pa` instead of `php artisan`.
*May your code be clean and your bugs few!*