May 11, 2015

I really like building PHP applications with Laravel, but sometimes you're given an established project written in an unfamiliar framework (i.e. ZF2).

Sure, ZF2 is usually paired with Doctrine 2 or the builtin DBAL, but what if the inherited project wasn't even using an ORM to begin with? The ZF2 ORM made me want to tear my hair out, you know what doesn’t? Eloquent, a.k.a illuminate/database.

Guess what? You can use this component in just about any PHP project. Read the Readme.md and see for yourself.

Basically, you can do the following:

use Illuminate\Database\Capsule\Manager as Capsule;

$capsule = new Capsule;

	'driver'    => 'mysql',
	'host'      => '',
	'database'  => 'database',
	'username'  => 'root',
	'password'  => '',
	'charset'   => 'utf8',
	'collation' => 'utf8_unicode_ci',
	'prefix'    => '',


That gives you the connection, and then you're free to write Eloquent models like this:

use Illuminate\Database\Eloquent\Model;

class Article extends Model {

	public $timestamps = false;
	protected $guarded = [


How awesome, right? You wouldn't believe the sigh of relief I had when I knew the builtin ZF2 ORM would no longer become a new skill of mine. Is this kosher? Probably not, but in the grand scheme of things who cares? Using Eloquent allows me to leave the office feeling good about the code I write—that’s all that matters.

Next up: Markdown WYSIWYG