Laravel Repository Pattern: A Full Base Repository Example for Laravel 4

The repository pattern is gaining popularity in the PHP community these days. Here is a Base Repository class you can use to build your own implementation.

What Version of Laravel 4 do I have Installed?

Laravel Framework Logo

Laravel 4 is amazing. It has made development fun again, the same way CodeIgniter did for me a few years ago. Sadly, many developers are abandoning CodeIgniter, and even Ellis Lab seems content to let it fade quietly into the night.

I recently needed to know which version of Laravel 4 was installed on my development machine vs. my staging server for some debugging. I never did find anywhere in the Laravel 4 documentation where I could locate this information, and my Google-Fu was not helping much either. Eventually I did find this information by browsing the core source files, so I thought I would write up a quick blog post for anyone else looking for an answer to this question.

You can look in vendor\laravel\framework\src\Illuminate\Foundation\Application.php.

Near the top of the class you should see the following constant defined:

Simple CodeIgniter 2+ Messaging: MessageCI Spark

CodeIgniter Logo

I am pleased to announce my latest CodeIgniter Spark, MessageCI. MessageCI is quite possibly the simplest messaging library currently available for CodeIgniter. It makes no assumptions about your ORM or database code, application themes, CSS, views, models or anything else. It simply gets out of your way to you can get down to business.

Download MessageCI from Github

Set a Message

Detect an event to which you want to alert the user. For this example, we will assume a form has been POSTed and form validation failed.

Display a Message

Display a message to the user in a view. CSS styles are configured via the config file to decouple logic from presentation. If there are no messages set, nothing happens, so you can safely embed this code in every view without worrying about detecting messages.

CodeIgniter 2+ .htaccess file

htaccess

This is a general purpose .htaccess file for CodeIgniter. You can do all kinds of interesting things with an .htaccess file, but this one primarily rewrites URLs so you can remove index.php from your URL structure. This file also servers as a good foundation from which to build more complex .htaccess rules.