Set up Laravel 5.6 environment in under 5 minutes on Mac / Ubuntu
Why Laravel?
Laravel is one of the most popular php frameworks. When I first started learning Laravel I found that the setting up of the dev environment was the hardest part. I have created a tutorial below which I believe is the fastest and easiest way to get started on a mac. It should also work on Ubuntu.
Requirements
Before starting make sure you have the following installed
- Virtual Box - https://www.virtualbox.org/wiki/Downloads
- Vagrant - https://www.vagrantup.com/downloads.html
- Composer - https://getcomposer.org/download/
Install Laravel
- Open terminal and navigate to the folder where you would like to create your project (using 'cd' if you're a total beginner see https://computers.tutsplus.com/tutorials/navigating-the-terminal-a-gentle-introduction--mac-3855 step 5)
composer create-project --prefer-dist laravel/laravel blog
to create a folder called blog which contains your new laravel project. Replace blog at the end of the command with the name of your project.- Cd into your project
cd blog
- run
composer require laravel/homestead --dev
which will set up homestead to run laravel on your machine - run
php vendor/bin/homestead make
- run
vagrant up
this can take some time to download the virtual machine - next you should run the command
sudo nano /etc/hosts
it will ask for your password. This is the password that you use to log into your mac. - use the down arrow to go to the bottom of the file and add a new row in and paste the following
192.168.10.10 homestead.test
- Press
Ctrl
+o
to save the document andCtrl
+x
to exit - You should now be able to access your project in the browser by going to http://homestead.test
You can also:
- run
vagrant ssh
to ssh into your virtual machine to run migrations etc. This will be useful as you get to know the system.
The Docs
Best places to start:
- https://laravel.com/docs/5.6/routing#basic-routing Routes (how you access the pages)
- https://laravel.com/docs/5.6/controllers#introduction (Controllers to decide what those pages show)
- https://laravel.com/docs/5.6/eloquent#introduction (inserting and getting from the database)
Hopefully I helped somebody get started with laravel using this post. I am new on steemit and will be posting more laravel content shortly. I found when learning laravel that setting up the envoronment was the main hurdle. Once this is set up learning the docs and code is a breeze!
If you have any laravel questions ask them below and I will try my best to answer them.
Thanks! Dont forget to vote up!
Either you run the day or the day runs you.
Very true
Only buy something that you'd be perfectly happy to hold if the market shut down for 10 years.
good advice!