What is artisan command & Middleware in laravel?

Posted by

Artisan command

Artisan is a command-line interface that Laravel provides which helps in making the production process fast and easy. Laravel has its own Command Line interface called Artisan

Its like a Linux command line but the commands are helpful for building a Laravel application. With this command-line tool, we can make models, controllers, and can do data migrations 

Example

Here is a list of few commands in Artisan along with their respective functionalities

To start Laravel project

php artisan serve

To enable caching mechanism

php artisan route:cache

To view the list of available commands supported by Artisan

php artisan list

To view help about any command and view the available options and arguments

php artisan help serve

Middleware

Middleware acts as a bridge between a request and a response. It is a type of filtering mechanism. This chapter explains you the middleware mechanism in Laravel.

Laravel includes a middleware that verifies whether the user of the application is authenticated or not. If the user is authenticated, it redirects to the home page otherwise, if not, it redirects to the login page.

Creating middleware

php artisan make:middleware <middleware-name>
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x