Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Laravel Commands

Laravel Commands

Laravel Commands

Laravel Command is the most popular and widely used PHP framework which is based on MVC (Model View Controller) Architecture. It is an open source web application development framework and was created by Taylor Otwell. As of now, the most recent release of laravel framework is Laravel 5.7 which was released in September 2018.

Prerequisites for starting with laravel

You should know basic/intermediate of:

  • PHP
  • HTML / CSS
  • Working of MVC Model
  • DB knowledge

Composer and Artisan

A composer is a tool which allows the user to create any project with respect to a given framework. It consists of all the dependencies and libraries.

Artisan is the command line interface of Laravel. It has the set of commands which will be discussing now in details which helps in building a web application.

Artisan command syntax:

php artisan [ options] [ arguments]

Basic Laravel Commands

Some of the basic laravel commands are mentioned below:

1. To list out all the Artisan commands

php artisan list: This command will list all the available commands that are a part of laravel – artisan console.

It starts with giving the syntax of executing the command i.e.

php artisan [command] [options] [arguments]

where,

  • options: It can be used like –h (for help), -q (for quiet), -v (for version) etc.
  • commands: It can be used as per command name followed by options and arguments. Few of the commands are migrate, serve, make, help, etc.

php artisan list

Source: From My Server

2. php artisan help

This command is used to get help on a particular command name. Let’s say if you would like to know more about the usage and meaning of the command, you can get it by making use of help utility provided by Artisan.

php artisan help makes: auth

where

  • make: auth: It is the command name for which we would like to know more.

php artisan help makes: auth

Source: From My Server

3. php artisan –version

This command will list out the version of Laravel framework which you are using.

4. php artisan down

This command is used to put the laravel application under maintenance mode.

Laravel Command - php artisan down

Source: From My Server

5. php artisan up

This command is used to bring back the laravel application up and running.

Laravel Command - php artisan up

Source: From My Server`

6. php artisan env

This command will tell you the environment in which laravel application is running.

Laravel Command - php artisan env

Source: From My Server

7. php artisan view: clear

This laravel command will clear all the compiled view files.

Laravel Command - php artisan view: clear

Source: From My Server

8. php artisan route: list

This command will list all the registered routes.

Laravel Command - php artisan route: list

Source: From My Server

9. php artisan route: clear

This command will clear all the route cache file

10. php artisan route: cache

This command creates a route cache file for faster route registration

Intermediate Laravel Commands

Some of those kinds of requiring intermediate laravel commands are mentioned below:

1. php artisan serve

This command is used to start a laravel project and by default, the application will be hosted at localhost with port number 8000

Laravel Command - php artisan serve

Source: From My Server

2. php artisan make: model Model_Name

This command is used to create a new model class.

 php artisan make

Source: From My Server

If we execute the command, Php Artisan list, we will find a couple makes commands. In order to see the list of make commands, please press shift + pg down key on your keyboard to navigate through all the pages.

3. php artisan make: controller Controller_Name

This command will create a new controller file in the below folder:

App/Http/Controllers

php artisan make: controller Controller_Name

Source: From My Server

4. php artisan make- request Request_Name

This command is used to create a new form request class in the below folder:

app/Http/Requests

php artisan make- request Request_Name

Source: From My Server

5. php artisan make seeder Seeder_Name

This command is used to create a new database seeder class.

php artisan make seeder Seeder_Name

Source: From My Server

6. php artisan make middleware Middleware_Name

This command is used to create a new middleware class.

php artisan make middleware Middleware_Name

Source: From My Server

7. php artisan make: policy Policy_Name

This command is used to create a new policy class.

php artisan make: policy Policy_Name

Source: From My Server

8. php artisan make: mail EMail_Class_Name

This command is used to create a new email class.

php artisan make: mail EMail_Class_Name

Source: From My Server

9. php artisan make: event Event_Class_Name

This command is used to create a new even class.

php artisan make: event Event_Class_Name

Source: From My Server

10. php artisan make: command Command_Name

This command is used to create a new artisan Laravel command

 php artisan make: command Command_Name

Source: From My Server

Advance Laravel Commands:

Below are Some of the advanced laravel commands which are as follows:

1. php artisan make: model Project –migration –controller –resource

This 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 Project –migration –controller –resource

Source: From My Server

2. php artisan make:listener Event_Listener_Class_Name

This command is used to create a new event listener class.

php artisan make:listener Event_Listener_Class_Name

Source: From My Server

3. php artisan migrate [–bench=”vendor/package”] [–database[=”…”]] [–path[=”…”]] [–package[=”…”]] [–pretend] [–seed]

This command is used to do Database migration.

4. php artisan vendor: publish

This command is used to publish any publishable assets from vendor packages.

php artisan vendor: publish

Source: From My Server

5. php artisan make provider service_provider_name

This command is used to create a new service provider class.

php artisan make provider

Source: From My Server

6. php artisan migrate:make name [–bench=”vendor/package”] [–create] [–package[=”…”]] [–path[=”…”]] [–table[=”…”]]

This command is used to create a new migration file

7. php artisan make job Job_Name

This command is used to create a new job class.

php artisan make job Job_Name

Source: From My Server

Recommended Articles

This has been a guide to Laravel Commands. Here we have discussed basic, immediate as well as advanced Laravel Commands with the help of examples. You may also look at the following articles to learn more.

  1. Docker Commands
  2. CSS Commands
  3. C# Commands
  4. Perl Commands

The post Laravel Commands appeared first on EDUCBA.



This post first appeared on Best Online Training & Video Courses | EduCBA, please read the originial post: here

Share the post

Laravel Commands

×

Subscribe to Best Online Training & Video Courses | Educba

Get updates delivered right to your inbox!

Thank you for your subscription

×