0% found this document useful (0 votes)
85 views

Laravel Commands

The document discusses various Laravel commands for generating models, controllers, migrations and other code. It describes commands for creating a new Laravel project, generating models and migrations, creating controllers, running migrations, seeding a database, clearing caches and routes, and more. Key commands include php artisan make:model to generate models, php artisan migrate to run migrations, and php artisan serve to start a Laravel project.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views

Laravel Commands

The document discusses various Laravel commands for generating models, controllers, migrations and other code. It describes commands for creating a new Laravel project, generating models and migrations, creating controllers, running migrations, seeding a database, clearing caches and routes, and more. Key commands include php artisan make:model to generate models, php artisan migrate to run migrations, and php artisan serve to start a Laravel project.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Laravel Commands

Creating Laravel Project

 Create a new laravel project.


 Composer create-project laravel/laravel ProjectName
 Composer create-project laravel/laravel firstproject
 ##Another Way Create a new laravel project.
 laravel new projectName
 Laravel new firstProject
 Run/Start a laravel Project/ Application
 Php artisan serve
Make Model and Controller

 Create/ Make Model in laravel


 Php artisan make: model ModelName
 i.e php artisan make: model Flight
 Create/ Make Controller
 Php artisan make: controller FlightController
 i.e php artisan make: controller ControllerNameController
Create and Run Migration

 Create/ Make Migration


 php artisan make:migration TableName
 i.e php artisan make:migration create_users_table
 Migrate Table/Migration
 Php artisan migrate
 Generate a database migration when you generate the model
 php artisan make:model TableName --migration
 php artisan make:model Flight --migration
Create Model, Migration and Controller

 Make Model with migration and Controller


 Php artisan make: model Name -mc
 i.e php artisan make: model article –mc
 Create Model, Controller and Resources
 php artisan make:model Name -mcr
 php artisan make:model Products -mcr
 Command is used to create a new migration file for the model(migration), create a new
controller for the model(controller) and to have a resource controller for the generated
controller.
 php artisan make: model Name --migration --controller --resource
 php artisan make: model Project --migration --controller --resource
Generate a migration, factory, and resource
controller for the model
 Create the migration, seeder, factory as well as Resource Controller for the model.
 Php artisan make: model Name --all
 I.e php artisan make: model Item –all
 Php artisan make: model Name --a
 I.e php artisan make: model Item --a
 Php artisan make: model Name --mfsrc
 i.e php artisan make: model Item –mfsrc
Clear Cache

 Clear Laravel cache via artisan command


 Php artisan cache:clear
 Clear this cache if you change a configuration, for example, during a production
deployment process
 php artisan config:clear
List directory and env file

 Command to know the current location


 ls
 Clear Command
 clear
 Command will tell you the environment in which the laravel application is running.
 Php artisan env
 Command will clear all the compiled view files.
 Php artisan view:clear
Route list, clear and cache

 Command will list all the registered routes.


 php artisan route: list
 Command will list all the registered routes.
 php artisan route: clear
 Command will clear all the route cache file.
 php artisan route: cache
Seeder Create, Run and Delete

 Create Seeder
 php artisan make:seeder User
 #Run All of them
 php artisan db:seed
 #Run One class
 php artisan db:seed --class=UserSeeder
 Delete seeder laravel
 php artisan migrate:refresh –seed
Generating Model Classes

 # Generate a model and a FlightFactory class...


 php artisan make:model Flight --factory
 php artisan make:model Flight -f
  
 # Generate a model and a FlightSeeder class...
 php artisan make:model Flight --seed
 php artisan make:model Flight -s
  
 # Generate a model and a FlightController class...
 php artisan make:model Flight --controller
 php artisan make:model Flight -c
Generating Model Classes: 1

 # Generate a model, FlightController resource class, and form request classes...


 php artisan make:model Flight --controller --resource --requests
 php artisan make:model Flight -crR
  
 # Generate a model and a FlightPolicy class...
 php artisan make:model Flight --policy
  
 # Generate a model and a migration, factory, seeder, and controller...
 php artisan make:model Flight -mfsc
Generating Model Classes: 2

 # Shortcut to generate a model, migration, factory, seeder, policy, controller, and form
requests...
 php artisan make:model Flight --all
  
 # Generate a pivot model...
 php artisan make:model Member --pivot

You might also like