22 октября 2017

Installing Laravel on Mac OS X with XAMPP

Detail on its website (https://www.laravel.com/)

PHP is pre-installed on Mac OS X as default that’s why if you install XAMPP or WAMP on your mac, you will install the second PHP version. 
Mac OS X with XAMPP step by step.

Open your Terminal and run the command below:

which php

If the output the path is:

/usr/bin/php

You need to change to the PHP version, which you installed with XAMPP.  To do this, you should create a .bash_profile file on your home directory by using Terminal and run the commands below one by one:

cd

sudo nano .bash_profile

Then you should add the following command inside the new .bash_profile file:

export PATH=/Applications/XAMPP/xamppfiles/bin:$PATH

Afterwards, press control-x,  when the terminal asks you to save the change, type Y and press enter again. Then you should quit and re-open your Terminal.

To make sure that you changed the PHP version correctly, you can run the “which php” command again and get the following output:

/Applications/XAMPP/xamppfiles/bin/php

Laravel utilizes composer to manage its dependencies. So, before using Laravel, you should install the composer to your mac. To install the composer, you should follow these two steps;

1. Locate to htdocs folder by using Terminal

cd /Applications/XAMPP/htdocs

2. Download and install the composer inside the htdocs folder

curl -sS http://getcomposer.org/installer | php

Now, you are ready to install the Laravel! To install the Laravel, please run the following command on your Terminal.

php composer.phar create-project laravel/laravel --prefer-dist

That’s all! To make sure that everything works correctly, while your Apache server is running, open your browser and type http://localhost/laravel/public