Laravel Installation

Written by Laravel Master on Jul 10th, 2020 Views Report Post

Installing Laravel is very simple, but there are a few system requirements you will need to have on your machine, which include:

  • PHP >= 7.2.5
  • BCMath PHP Extension
  • Ctype PHP Extension
  • Fileinfo PHP extension
  • JSON PHP Extension
  • Mbstring PHP Extension
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension

In most cases, if you have PHP installed on your machine, you can probably get Laravel to install.

Installing Composer

Composer is a PHP package manager that will allow you to install many different PHP applications, Laravel is one of them.

So, first you'll need to install composer. You can do so by running the following command in your terminal:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'e5325b19b381bfd88ce90a5ddb7823406b2a38cff6bb704b0acc289a09c8128d4a8ce2bbafcd1fcbdc38666422fe2806') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

You can see those same instructions here.

After you run those commands above you'll see a new file in your current directory called composer.phar, we probably want to make Composer available globally, so we can run the next command to do that:

mv composer.phar /usr/local/bin/composer

After doing that, you may need to restart your command prompt (terminal), and then you can run the following command:

composer --version

And if everything worked, you'll get a nice output displaying which version of Composer you have installed.

Installing Laravel via Composer

Now that we have Composer installed, we can use Composer to install Laravel. You can do that with the following command:

composer create-project --prefer-dist laravel/laravel folder_name

After running that command, a new Laravel application will be available inside of folder_name. You will now be able to change into that directory:

cd folder_name

And run a local copy of your application by running:

php artisan serve

You will now be able to visit your local laravel application by opening a browser and visiting https://localhost:8000.

Installing the Laravel Installer

There is an even easier way that we can install new Laravel applications on our machine, and that is by installing the Laravel Installer via Composer:

composer global require laravel/installer

In addition to installing the Laravel Installer, you will need to add Composers directory to your $PATH environment of your machine. You can learn how to do that here.

After doing that, you may have to restart your Cmd prompt (terminal), and you'll now be able to run the following command:

laravel new blog

This command will install a new Laravel application inside a new folder called blog.

By adding the Laravel installer to your machine, you'll be able to run the laravel new command anywhere on your computer, and you will have a new Laravel application up and ready to go within seconds.

Learning More

Of course, you can also check out the official Laravel documentation on how Installing Laravel.

If you run into any issues while running the installation, just try googling your problem, and I'm sure you'll find a solution.

Comments (0)