How to Install Laravel Framework?

Laravel Installation

Hi guys,

Today is a great day to start to install Laravel Framework. We will go step-by-step through each process. So Don’t skip articles. Stay connected!

Before we start with the Laravel framework. Laravel framework has some system requirements, which a given below:

  • The PHP version must be greater than 8.0
  • some extensions should be installed on your system which are BCMath, Ctype, Fileinfo, JSON, Mbstring, OpenSSL, PDO, Tokenizer, and XML.
  • Must install a Composer

If the above requirement is fulfilled on your system, then we are good to go.

Laravel uses the composer utility to manage its dependencies. there are two ways to install Laravel:

1) Install Laravel via Laravel Installer

First, download the Laravel installer using a composer

composer global require laravel/installer

Once you installed the Laravel installer. Run the below command to get a fresh laravel installation in the directory.

laravel new DIRECTORY_NAME --VERSION

For example,

laravel new blog --6

This command will create a directory named a blog with Laravel 6 containing a fresh laravel installation with all Laravel’s dependencies already installed.

2) Install Laravel via Composer


You may create a project using the composer create-project command in your command prompt. Run the below command to create a new project

composer create-project --prefer-dist laravel/laravel DIRECTORY_NAME "VERSION_NUMBER"

for example,

composer create-project --prefer-dist laravel/laravel blog "9.*"

If you want to serve your application using a PHP built-in development server. Run the following command to start the development server

php artisan serve

After installing Laravel, you must assign some permission like writable to directories, which are storage and bootstrap/cache.

Application key:-

If you want to regenerate the application key, then run the following command.

php artisan key:generate

Laravel already set the application key while creating a new project. If the application key is not defined, then your user’s session and other encrypted data will not be secure.

Environment Configuration:-

It is helpful to have different configuration values against the environment. For example, If you want to configure a payment gateway for your application. Payment Gateway has two types of environment testing and live. You must configure them accordingly.

If you want to define a value with spaces, you must be enclosing this with double quotes.

Hiding Environment variables from debug pages:-

On the env file, APP_DEBUG has been set to true, and the exception occurs. The debug page will show all environment variables. You do not want to display some of the variables. You should update the debug_blacklist on the config/app.php file. For example, given below:

'debug_blacklist' => [
'_ENV' => [
'APP_KEY',
'DB_PASSWORD',
],
    '_SERVER' => [
        'APP_KEY',
        'DB_PASSWORD',
    ],

    '_POST' => [
        'password',
    ],
],

Accessing configuration values:-

You access the configuration variable using the global config helper function anywhere in your application. The syntax for accessing configuration values is

$value = config('app.name');

For the config function, you can assign configuration values using the name of the file, a variable name with the ‘dot’ operator.

To set configuration value at runtime. using the following syntax

config(['app.name'=>'Laravel Test Application']);

Configuration caching:-

To give your application a speed boost. Run the following command:

php artisan config:cache

Maintenance Mode:-

If you want to update the application, you should enable maintenance mode. All requests will display a custom view for your application. It is a good practice.

To enable maintenance mode, run the following command:

php artisan down

You may also provide messages and retry options to the down command. The message value may be used to display or log a custom message, while the retry value will be set as the Retry-After HTTP header’s value:

php artisan down --message="Upgrading Database" --retry=60

Even while in maintenance mode, specific IP addresses or networks may be allowed to access the application using the command’s allow option:

php artisan down --allow=127.0.0.1 --allow=192.168.0.0/16

To disable maintenance mode, use the up command:

php artisan up

Thank you for reading this article. Please share this article with your friend circle. That’s it for the day. Stay Connected!
Cheers,

Loading

1 thought on “How to Install Laravel Framework?”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top