Alex Rhea

Student at Virginia Tech and Front End Nerd

Laravel Artisan on a Shared Host

Recently while using Laravel I ran into a problem running my artisan tasks on a shard hosting platform like Bluehost and there many others. There was an issue filed on the Laravel Github Issues Tracker so I had ran into a dead end. Google searches came up empty. After some investigating I found the solution.

So here is the error that started the whole issue.

1
2
3
4
Warning: Invalid argument supplied for foreach() in <working_directory>laravel/helpers.php on line 577
You forgot to provide the task name.

[17-Jan-2013 13:54:28 America/Denver] PHP Notice:  Undefined index: argv in <working_directory>laravel/core.php on line 218

And there were many other weird erros arising. So after looking around I found another CLI PHP issue that someone had on a shared host from like 2009. At this point I figured I would give it a try.

On these shard hosts they have two version of PHP install. There is a command line version and a regular version. However, that regular version doesn’t work with artisan in laravel.

If you run which php you end up with /usr/php/53/usr/bin/php however, this doesn’t work. What they don’t exactly publish is there is another version /usr/php/53/usr/bin/php-cli. This version will work with Laravel.

So you can use /usr/php/53/usr/bin/php-cli artisan migrate:install.

Long winded answer for something so simple and core to Laravel which is what makes Laravel so awesome.

Adding Deferreds to Backbone

Since jQuery Ajax has supported the concept of “Deferreds” I have really liked working with them. They make your code look cleaner and read a little nicer. So from my early days of jQuery I made the natural progression to writing web apps and using frameworks like Backbone to structure these apps. However, Backbone requires you pass your callbacks as options to the function. There is nothing wrong with this paradigm but, I perfer to use chaining to attach my callbacks.

There was always a snippet I included in all of my Backbone apps to add deferreds beyond just the raw jQuery Ajax object. So I have broken it out into it’s own library called backbone-deferred. backbone-deferred allows you to access all the same parameters that success and error handlers have as well as the same context.

backbone-deferred Example
1
2
3
4
5
6
7
8
9
var Model = Backbone.DeferredModel.extend({});

var model = new Model({ id: 1 });

model.fetch().done(function(model, response, options) {
    alert('Yay!');
}).fail(function(model, xhr, options) {
    alert('Darn!');
});