Difficulty: Beginner
Artisan is Laravel's command-line interface.
You can inspect available commands using:
php artisan list
Examples:
php artisan serve
Create a model:
php artisan make:model Product
Create a controller:
php artisan make:controller ProductController
Create a migration:
php artisan make:migration create_products_table
Run migrations:
php artisan migrate
Clear application caches:
php artisan optimize:clear
Run tests:
php artisan test
The exact available commands depend on the Laravel version and installed packages.
Real-world example
Suppose you need:
Product ProductController Product migration Product factory Product seeder
Instead of manually creating files, Laravel can generate much of the boilerplate using Artisan.
This improves consistency and reduces repetitive work.
Q5. What is Composer and why does Laravel use it?
Difficulty: Beginner → Intermediate
Composer is PHP's dependency manager.
Laravel itself depends on many PHP packages.
A Laravel project therefore has:
composer.json composer.lock vendor/
For example:
{ "require": { "laravel/framework": "..." } }
Composer installs the required dependencies into:
vendor/
The application loads these dependencies through Composer's autoloader.
A common command is:
composer install
For development:
composer update
should be used carefully because it can update dependency versions according to the project's constraints.
0 Comments