Laravel 4 Artisan Serve

I recently came about this nifty little command I can use to start a laravel application.

php artisan serve

What this does is starts the php5 built in webserver much like doing php -S localhost:8000. This gave me an idea though to extend upon Laravel. Imagine you had something like

php artisan watch

What would the watcher do? It could monitor some directories you have listed in config/packages/codesleeve/watcher/config.php for changes on the file system and then execute any commands you have listed in the watch config.

function($app)
{
	$app['watch'] = new Codesleeve\Watcher($app);
	// now run CLI for artisan serve
	// (if watch config has serve == true)
}

But alias, maybe this is just re-inventing the wheel? I mean, currently, use grunt watch for stuff like livereload. This way I get rid of the F5 (or ctrl+R) for page refresh. This workflow works nicely on my multiple monitor setup. The reason this urks me though is that this requires that I have the Chrome browser LiveReload plugin, along with npm, grunt, several grunt libs, a package.json and list of dependencies. This isn’t really a big deal I suppose, but if we follow the Einstein minimalism principle rule, this whole process could be simpler therefore it is not truly elegant.

So what if I went a different route? What if Laravel had a compser packagist package available to do watches? For example, if I forked/modified something like https://github.com/dbergey/Reloadr. No grunt, no problem. For now though, I will continue using grunt while I play with this idea some later in the future.

post by Kelt Dockins on 08/13/2013