Configuring Laravel on Pagoda Box
I have been searching for cloud php hosting with good laravel support for testing purposes. The best option I found was FortRabbit that I absolutely fell in love with. However, they have this timer thingy after which app would freeze if timer was not reset. But the real issue was not freezing but unfreezing because unfreezing the app often caused the servers to change & I had to modify my git remotes, ssh & mysql hosts accordingly.
Moving on I came across OpenShift which was quite good although not as great as FortRabbit. However, I struggled fiercely with deploying my local laravel installation to it. After, couple of days of Googling & trying I decided to move on to Pagodabox free account. Unfortunately, setting up laravel here wasn’t that easy either. Although, they offered a quick-start laravel installation (that worked like a charm), I couldn’t get my local deployment to work online that easily. However, I was able to deploy my installation after hit & trials in two days. I’ll enumerate the steps for the deployment process quickly below.
Create laravel quick start app
Start by creating the laravel quick-start app provided by pagodabox. This should get all your basics covered including database, cache & other required Pagodabox processes.
Clone the Pagodabox repository to your local machine. Remember to add SSH public keys to your pagoda account before you do that or you won’t be able to access the repositories.
Move local installation into new repo
After successful clone, note down the database information in database.php file inside app/config folder. Then delete all files inside repo except the .git folder and the two Boxfile & Boxfile.installer files. Then move your local laravel installation files inside the repo, of course, except the vendor folder. Also, edit your application’s composer.json file to set minimum-stability to ‘stable’. [Suggested to prevent a possible error]
The pagodabox doesn’t come pre-packaged with composer as does FortRabbit. The Boxfile inside Laravel quick-start app includes required code to download Composer & then run Composer Install. However, in my app, the default Boxfile setup resulted in a few errors.
- the requested PHP extension curl is missing from your system - Aborting - Composer would abort with No Obvious reason. - Class 'Monolog\Logger' not found
To fix the curl issue, we need to add curl as a required extension in Boxfile file.
php_extensions: - curl
The composer abort [due to timeout] results in a corrupt push that cannot be deployed on Pagodabox. The reason for this timeout is that the new version of Composer uses GitHub Api for downloading all the dependencies. And if your dependencies are large in number, the GitHub Api limit is reached & Composer times out resulting in abort.
The solution is to modify Boxfile to download an older version of composer and use –prefer-install flag. Also, to fix the Monolog\Logger issue, we need to update the composer & do optimized dump-autoload before running composer install. The after_build: part of Boxfile after the above suggested changes looks something like
after_build: - "if [ ! -f composer.phar ]; then curl -s http://getcomposer.org/installer | php -- --version=1.0.0-alpha7; fi; php composer.phar self-update; php composer.phar dump-autoload -o; php composer.phar install --prefer-source; "
Commit & Push
Now commit your code & push to origin. Everything should work fine & application should be deployed to server properly. P.S. This blog is hosted at OpenShift :)