Install Laravel Project using Composer

0
1759

Installing Composer

Composer is a dependency manager for PHP and we will be using it to download the Laravel core and install all necessary Laravel components.

To install composer globally, download the Composer installer with curl and move the file to the /usr/local/bin directory:

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

Verify the installation by printing the composer version:

composer --version

The output should look something like this:

Composer version 1.8.0 2018-12-03 10:31:16

Installing Laravel

At the time of writing this article, the latest stable version of Laravel is version 5.7.

Run the Composer create-project command to install Laravel in the my_app directory:

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

The command above will fetch all required php packages. The process may take few minutes and if it is successful the end of the output should look like the following:

Package manifest generated successfully.
> @php artisan key:generate --ansi
Application key set successfully.

At this point you have Laravel installed on your Ubuntu system.

When installed via Composer, Laravel will automatically create a file named .env. This files includes custom configuration variables including the database credentials. You can read more about how to configure Laravel here.

You can start the development server by navigating to the Laravel project directory and executing the artisan serve command:

cd ~/my_appphp artisan serve

The output will look something like this:

Laravel development server started: <http://127.0.0.1:8000>

Verifying the Installation

Open your browser, type http://127.0.0.1:8000 and assuming the installation is successful, a screen similar to the following will appear:

Conclusion

Congratulations, you have successfully installed Laravel 5.7 on your Ubuntu 18.04 machine. You can now start developing your application.

LEAVE A REPLY

Please enter your comment!
Please enter your name here