Skip to content

Anas-Hamo23/Laravel-Command-Line

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 

Repository files navigation

Laravel Command Line Guide

Install Laravel

composer create-project --prefer-dist laravel/laravel project-name
cd project-name

Start the Development Server

php artisan serve

Create a Controller Class

php artisan make:controller NameController

Create a Resource Controller Class

Creates a controller with default functions: index, create, store, show, edit, update, destroy.

php artisan make:controller PhotoController --resource

Create an API Controller Class via Command Line

php artisan make:controller PhotoController --api

Create a Model Class via Command Line

php artisan make:model NameModel

Create a Migration Class via Command Line

php artisan make:migration NameMigrate

Create a Model, Migration Classes via Command Line

php artisan make:model NameModel -m

Create a Model, Migration, and Controller Classes via Command Line

php artisan make:model NameModel -mc

Show All Routes

php artisan route:list

Create a Middleware

php artisan make:middleware NameMiddleware

Create a Request

php artisan make:request NameRequest

Create a Policy

php artisan make:policy NamePolicy --model=ModelName

Run Migrations

php artisan migrate

Rollback Migrations

php artisan migrate:rollback

Seed the Database

php artisan db:seed

Create a Seeder

php artisan make:seeder NameSeeder

Run Specific Seeder

php artisan db:seed --class=NameSeeder

Create a Factory

php artisan make:factory NameFactory --model=ModelName

Generate Auth Scaffolding (Laravel Breeze or Jetstream)

Laravel Breeze

composer require laravel/breeze --dev
php artisan breeze:install
npm install && npm run dev
php artisan migrate

Laravel Jetstream

composer require laravel/jetstream
php artisan jetstream:install [livewire|inertia]
npm install && npm run dev
php artisan migrate

Clear Application Cache

php artisan cache:clear

Clear Configuration Cache

php artisan config:clear

Clear Route Cache

php artisan route:clear

Clear View Cache

php artisan view:clear

List All Available Artisan Commands

php artisan list

Create a Job

php artisan make:job NameJob

Create a Listener

php artisan make:listener NameListener --event=EventName

Create an Event

php artisan make:event NameEvent

Create a Notification

php artisan make:notification NameNotification

Create a Mail

php artisan make:mail NameMail

Create a Console Command

php artisan make:command NameCommand

Queue Work Command

php artisan queue:work

Queue Listen Command

php artisan queue:listen

Create a Custom Validation Rule

php artisan make:rule NameRule