Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Laravel 5.x Cookbook

You're reading from  Laravel 5.x Cookbook

Product type Book
Published in Sep 2016
Publisher Packt
ISBN-13 9781786462084
Pages 402 pages
Edition 1st Edition
Languages
Authors (2):
Terry Matula Terry Matula
Profile icon Terry Matula
Alfred Nutile Alfred Nutile
Profile icon Alfred Nutile
View More author details

Table of Contents (17) Chapters

Laravel 5.x Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
1. Setting Up and Installing Laravel 2. Using Composer Packages 3. Routing 4. Building Views and Adding Style 5. Working with Data 6. Adding Angular to Your App 7. Authentication, Security, and Subscriptions 8. Testing and Debugging Your Application 9. Adding Advanced Features to Your App 10. Deploying Your App Index

Setting up your first application in Homestead


In this section, we will download Laravel and set up our local site to use for the rest of our recipes taking advantage of Homestead.

Getting ready

We have Homestead installed. My home folder called ~/Code is where we will be working.

How to do it...

  1. Type the following in the terminal:

    >cd ~/Code
    
  2. Then, download Laravel to a new folder:

    >composer create-project --prefer-dist laravel/laravel recipes 
    
  3. Move into the directory for your new application:

    >cd recipes
    
  4. Now we need to tell Homestead about our new application:

    >cd ~/.homestead && subl Homestead.yml
    
  5. Once the editor pops open, you can add your new site:

  6. Under database:

  7. Click on Save and close the editor.

  8. Then, start up Homestead or just provision it:

    >homestead provision
    

    You may be asked for a password, which is your system admin password and not the Homestead password.

  9. Then, we need to edit our system Host file (in this case, our local computer and not Vagrant and Homestead); this will again ask for our system password:

    >sudo subl /etc/hosts
    

    Tip

    I will show a shortcut command in the How it works… section.

  10. Next, edit the host file to set your recipes.dev domain right next to the default Homestead IP of 192.168.10.10; then, save and close the editor:

  11. Then, visit your site at https://recipes.dev! You may get an SSL warning but click on Advanced and Proceed:

How it works...

The composer command that we ran gets Laravel from its database of applications and libraries at https://packagist.org/ then download it. We began by installing Homebrew to make installing packages easier. We will periodically need to install packages such as Wget, Webdriver, and more as we progress through this book. Using the brew command supplied by Homebrew makes installing these packages a snap.

I also used some shortcuts. One shortcut was subl, which was what you get when you install http://www.sublimetext.com/. But you can use whatever editor you want.

Using some of the preceding tips will make a shortcut called hedit adding to my ~/.bash_profile:

alias homesteadedit='cd ~/.homestead && subl Homestead.yml'

So, we are editing the main file that Laravel uses for all its Homestead settings. You will be here a lot, so shortcuts really pay off.

The same is applicable with the hostedit command that I used:

alias hostedit='sudo subl /etc/hosts'

Here, we are adding to our .bash_profile a quick way to edit the file and add the needed domain recipes.dev and save and exit. Now, when you visit https://recipes.dev, your operating system will know that it is really for Homestead.

See also

You have been reading a chapter from
Laravel 5.x Cookbook
Published in: Sep 2016 Publisher: Packt ISBN-13: 9781786462084
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}