Table of Contents
It is not at all complicated to install Laravel, as you will see in this tutorial.
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 using 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.
Notice the dot. It specifies that it should install Laravel in the dir you are currently in.
What does — prefer-dist do?
–prefer-dist will try to download and unzip archives of the dependencies using GitHub or another API when available. This is used for faster downloading of dependencies in most cases.
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: http://127.0.0.1:8000
Paste http://127.0.0.1:8000 in your web browser.
If everything went well you will see the image below:
http://localhost:8000 is the same as http://127.0.0.1:8000
4. Create a new repository with the new project on Github
You can create it from the GitHub panel interface or from the command line,
How to create a new repository from the GitHub panel?
1. Go to Github.
2. Log in to your account.
3. Click the “New” repository button.
4. then select the options you need:
You’ll have an option there to initialize the repository with a README file, but don’t. It will be replaced by README laravel file
5. Add .git ignore to your project!
6. Click the “Create repository” button
How to create a new repository from the command line?
Inside the Laravel project directory), runs the following commands:
git init git add README.md git commit -m "first commit"
5. Connect the new project with Github
From the directory that contains your Laravel project, push the existing repository from the command line:
git init git remote add origin https://github.com/your_username/repository_name.git git branch -m master git push -u origin master
Read more here about how to work with Git And GitHub.
Hello there!
I hope you find this post useful!I'm Mihai, a programmer and online marketing specialist, very passionate about everything that means online marketing, focused on eCommerce.
If you have a collaboration proposal or need helps with your projects feel free to contact me. I will always be glad to help you!