I am new to PHP and have coded earlier with CodeIgniter. It is really easy to get started with CodeIgniter as it is light but powerful and has less features. As CodeIgniter is slowly phasing out I thought of moving to Laravel. Yes, it is powerful and AWESOME!!!
Lets get down to business.
1. Install composer
I was doing it for the first time and faced issues:
Lets get down to business.
1. Install composer
I was doing it for the first time and faced issues:
Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:
The detect_unicode setting must be disabled.
Add the following to the end of your `php.ini`:
detect_unicode = Off
A php.ini file does not exist. You will have to create one.
I was clueless at this moment and started to search. After some search I found an article which tells about setting up AMP (Apache, My SQL and PHP) environment.
While going through it I realized that I have Apache already installed on my system (I am new to Mac too). I followed the steps to configure it (took related path accidentally :D).
While doing this I found out that I am working in a system folder /etc. To check it out I jumped into it and to my surprise I found my missing php.ini.default.I created a copy of it, renamed it and opened it up in vim editor.
sudo vi php.ini
I added the line
detect_unicode = Off
at the end.
I tried to setup composer again and it worked.
2. Install Laravel
composer create-project laravel/laravel --prefer-dist
No surprises, I got another issue :D
Script php artisan optimize handling the post-update-cmd event returned with an error:
[InvalidArgumentException]
Command "optimize" is not defined.
I found out that mcrypt is not available. I searched again and realized that PHP version which I am using is old. I check it using "php -v" and checked the path of PHP which is being used using "which php". PHP version was 5.3.x.
3. Update PHP (Laravel needs a recent version)
I used this link (It is awesome, thanks to author).
#2. Go back to step 2.
Try again. I thought of using my XAMPP's Apache and tried creating project there. I faced the same issue. Why now :(. I thought it is something to do with PHP version that I am using. I checked the version again and found out that I am still using wrong version and php binaries from wrong path were being used.
I searched to find out how to use the right PHP version and found this Laravel forum link.
I am pasting the suggestion here for ready reference but all the credit goes to the contributor in forum.
You are using the built in version of PHP, did you install PHP-OSX for 5.4 installation? If so you need to overwrite it's path
from terminal:
sudo vi ~/.bash_profile
enter password
when file loads press A to access writing
paste this line:
export PATH=/usr/local/php5/bin:${PATH}
press ESC key
hold SHIFT and Press ZZ (z twice)
now do which php again it should say:
/usr/local/php5/bin/php
now install home brew and you can do stuff like like
brew install php54-mcrypt
restart apache in between steps
you may also be able to do other stuff like "brew search php54-module" or php54-* to see whats available.. always install with php54 to avoid conflicts.
My setup just worked. I did not need to install homebrew and perform rest of the steps.
For setting up mcrypt you can also refer this link I did not tried it though.
4. Tried http://localhost/laravel/public/ - did not work.
I got Laravel 4 blank screen issue (as people call it famously). I recalled that I need to set storage directory present in app directory of laravel setup as writable.
$ sudo chmod -R 7777 app/storage
As, I am the only user of my machine and this is my home machine I gave all permissions. Please provide appropriate permissions in your case.
5. Happy Ending!!! It worked. :D
Comments
Post a Comment