How easy would it be if you could open up a shell or terminal window and type in:

$ laravel new blog

And a Laravel app is created inside a folder named "blog". Well, that's exactly what the laravel installer does. So, let's learn how we can use this on our computer.

The Laravel Installer, as well as many PHP packages, use a dependency manager called Composer to add this functionality.

So, What exactly is a dependency manager? Well, a dependency manager is nothing more than a tool to manage your dependencies. "WHAT!!!?", yeah the definition still sounds pretty abstract, right?

Let me put this in another way to help you understand how Composer works.

I know you are probably a fan of eating pizza instead of eating brains, so let's pretend we could use a command to make us a pizza:

$ composer make pizza

By default we are given a pepperoni pizza. But let's say we wanted this command to make us a pizza with different toppings. Perhaps we wanted a Meat-lovers pizza. We would probably want the following toppings:


{
    "toppings" : [
        "peperoni", "ham", "bacon", "beef", "sausage" 
     ]
}

Now, if we save this file in our current directory and name it 'composer.json' and run this command again:

$ composer make pizza

DING! We now get our Meat-lovers pizza instead of our Peperoni Pizza. Hazzzaa!

As you can see Composer is a way of managing the things we need to build our app (or pizza).

Composer is also a command line tool we can use it to install other command line tools. One of those tools is the Laravel Installer.

To add the Laravel installer to our computer, we must first install composer. Visit https://getcomposer.org/ click on the 'Getting Started' button, navigate to 'Installing Globally', and walk through how to globally install composer on your machine.

After you have downloaded and installed composer you can run the following composer command to add the Laravel Installer.

$ composer global require "laravel/installer=~1.1"

And now we have successfully added the laravel installer to your machine and you can simply create a new laravel app by typing:

$ laravel new app_name

Then navigate to your new app_name folder in terminal/shell. And run:

$ php artisan serve

Finally, navigate to http://localhost:8000/ in your browser and you will see a Welcome to Laravel screen. Now you're ready to start building your amazing app!

If the laravel installer does not globally work you may need to specify where your composer bin directory is located on your machine. Visit http://devdojo.com/post/composer-bin-directory-path to learn how to do this.

How awesome is this! With a single command line you can be up and running with a new laravel app in a few seconds! You can learn more about the Laravel installer at http://laravel.com/docs.

This is an excerpt from our book "The Laravel Survival Guide", be sure to check it out here: https://leanpub.com/laravelsurvivalguide


Login

or Sign Up

Sign Up

or Login