Hello Folks! I am writing this post after a long time.
Today, I decided to start learning a new PHP framework, which is Laravel, for my master thesis. I am not going to talk about the pros and cons of this framework, it is already explained in detail on its official website (https://www.laravel.com/). I will explain how to install Laravel on Mac OS X with XAMPP step by step.
PHP is pre-installed on Mac OS X by default that’s why if you install XAMPP or WAMP on your mac, you will install the second PHP version. To find out which version of the PHP, you are running on your Mac, open your Terminal and run the command below:
1 |
which php |
If the output the path is:
1 |
/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:
1 |
cd |
1 |
sudo nano .bash_profile |
Then you should add the following command inside the new .bash_profile file:
1 |
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 have changed the PHP version correctly, you can run the “which php” command again and get the following output:
1 |
/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
1 |
cd /Applications/XAMPP/htdocs |
2. Download and install the composer inside the htdocs folder
1 |
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.
1 |
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, the default Laravel page will be seen in your browser as can be seen below.
I did all of your steps and it worked, but on the end, when i trying to check it on the browser with http://localhost/laravel/public, i am getting to blank page.
i have checked my XAMPP and the services are on.
I see the folder of laravel project in the htdocs.
What can i do?
Thanks,
Nir
Thank you for your effort
Wonderfull, you just made my day i am trying to install larval 5 on mac since 1 week. This article solved my problem.
I perform all the step
but when I open the http://localhost/laravel/public/
I get this message
localhost is currently unable to handle this request.
Hi.. I tried this everything went as per your tutorial.. but when open localhost/laravel/public its not working..
Any guesses?
Ok i figured it out.. You are missing below 2 steps:
Cd /Applications/XAMPP/htdocs/laravel
After that, type the following ad hit enter
sudo chmod -R 7777 storage
Hi there, thanks for the complete tutorial. It really help.
– From Malaysia
(1/1) UnexpectedValueException
The stream or file “/Applications/XAMPP/xamppfiles/htdocs/laravel/storage/logs/laravel.log” could not be opened: failed to open stream: Permission denied
that’s what is happened for me :S
Perfect, worked beautifully, thank you!
Great Information. Thumbs up. Put this information also >>
Cd /Applications/XAMPP/htdocs/laravel
After that, type the following ad hit enter
sudo chmod -R 7777 storage
Here is a post that i leave on stackoverflow with another solution for this case
https://stackoverflow.com/questions/49131156/laravel-not-work-in-xampp-mac-os/51330133#51330133
Thanks for sharing your knowledge
So great, steps are very much detailed and I was able to handle the errors by following additional instructions in the comment box :). Thank you for this guide!
At the end, this line should change:
$>composer create-project laravel/laravel dev-develop
(or anyname of app, the name was dev-develop)
and you should run this:
$>sudo chmod -R 777 storage/*
Helped me a lot!
Nice post! The information you provided is very helpful if someone is planning to develop the Website. I think Digitalopment is a better way to get all the information about laravel development services.