Skip to content

Best Practices to Generate Application Key in Laravel 2022

Reading Time: < 1 minute

Laravel is one of the modern frameworks for PHP application development. It has more security features to protect the application interface. Here we give an explanation of how to generate an application key in Laravel.

What is Laravel

Laravel is an MVC Framework written in PHP. It has all the necessary features such as signup, login, sending emails, and more. It is also very useful to build our own business logic into a beautiful web application.

Application Key in Laravel

Laravel Applications has a security key to protect the application code and make it more secure for input data. By default, it has some application with it. But It must be changed before you deploy as its needs for security purposes.

Here we explained how we can generate a new Laravel application key in the command line.

Open the command window in the project folder

Laravel Artisan Key Command

You can generate a key by the following command:

php artisan key:generate 

The key will be written automatically in your .env file.

APP_KEY=YOUR_GENERATED_KEY

If you want to see your key after generation use --show option

php artisan key:generate --show

Note: The .env is a hidden file in your project folder.

You can get more info in Laravel Documentation.

You might also like these Laravel related articles.

See also  How to Protect Folder with Password without a Software

Leave a Reply