How to install and set up Laravel?

It is not at all complicated to install Laravel, as you will see in this tutorial.

This is part 1 of the series seo site manager in Laravel.

1. Install Composer on Your system

For managing dependencies, Laravel uses composer. Therefore before installing Laravel, make sure you have Composer installed on your system.

You can install composer to a specific directory by using the –install-dir option and providing a target directory. Example:

php composer-setup.php –install-dir=bin

2. Install Laravel with Composer

To install Laravel using composer, all you need to do is to run in your terminal:

composer create-project –prefer-dist laravel/laravel your-project-name

Where: your-project-name is the name of the folder containing your new Laravel instance.

To install Laravel directly within your chosen directory (not in a folder within it as demonstrated above), run the same command but this time without a folder name:

composer create-project –prefer-dist laravel/laravel

This command will download and install a fresh copy of Laravel in a new your-project-name folder within your current directory.

3. Start the application

To start the application run in your terminal:

php artisan serve

By default, your application will open at 8000 port.
You will see: Starting Laravel development server:
Paste in your web browser.

If everything went well you will see the image below:

install laravel

http://localhost:8000 is the same as

4. Create a new repository with the new project on Github

From the command line (inside the Laravel project directory), runs the following commands:

git init
git add
git commit -m "first commit"

//Connect it to Github
1. Go to Github.
2. Log in to your account.
3. Click the "New" repository button. You'll have an option there to initialize the repository with a README file, but don't.
4. Click the "Create repository" button
After, push the existing repository from the command line:

git remote add origin
git branch -M master
git push -u origin master

Read more here about how to work with Git And GitHub.

5. Connecting your Laravel project to MySQL database

Laravel makes interacting with databases extremely simple across a variety of supported databases using raw SQL, a fluent query builder, and the Eloquent ORM. Currently, Laravel provides support for four databases:

  • MySQL 5.7+
  • PostgreSQL 9.6+
  • SQLite 3.8.8+
  • SQL Server 2017+

1. Create a new database via phpmyadmin with your wanted name

2. Add database connection details in the configuration file.

Add database connection details in the .env file. .env is short for environment and contain Your app environment configurations.

In order to keep everything safe keep them in .env file. Laravel will prioritize .env variables.

Replace your data in the code below:


Read more here about databases in Laravel

Leave a Comment