Empathy MVC

ELib Blog

System requirements

  • PHP 5.3
  • Memcached
  • Node.js/npm
  • make
  • Web server config that supports following symlinks (for admin/backend assets)


Create a composer.json file with elib-blog in the require block:

    "require": {
        "mikejw/elib-blog": "dev-develop"
    "minimum-stability": "dev"

Run composer install and then launch the empathy New App command line helper:

php composer.phar install --prefer-source
php ./vendor/bin/empathy --new_app


Add databse config settings to config.yml. (dbserver, dbuser, dbpass, dbname.) If the database doesn't exist create it at this point. (The database will be called 'project' for this tutorial.) Create a file called setup.sql for data definition and add the following to the top of the file:

USE project;

Next copy the contents of ./vendor/mikejw/elib-base/dd.sql and ./vendor/mikejw/elib-blog/dd.sql to this file. Between these two chunks of code (after use project; and before the create table blocks) create the SQL statement to drop these tables:

DROP TABLE IF EXISTS user_profile, e_user, blog, tag, blog_tag, blog_image,
                     blog_comment, blog_category;                        

Next create a file called inserts.sql for data manipulation and add at the top:

use project;

Copy the contents from ./vendor/mikejw/elib-base/dm.sql and ./vendor/mikejw/elib-blog/dm.sql to this file. Initiate the development database with:

php ./vendor/bin/empathy --mysql setup


Generate the default application controllers with:

php ./vendor/bin/empathy --inst_mod admin
php ./vendor/bin/empathy --inst_mod blog
php ./vendor/bin/empathy --inst_mod user

Enable the cache by adding the following to the ./application/CustonController.php constructor:

$cache_enabled = true;
$cache = new \Empathy\ELib\VCache('', 11211, null, $cache_enabled);
$this->stash->store('cache', $cache);

Add the following to ./elib.yml:

blog_description: Web programmer guy.
blog_entries: 60
truncate_blog_items: true
fetch_blog_images: false
blog_image_max_width: 960
def_blog_category: 0
def_blog_per_page: 3
blog_social_links: '{ "GitHub": "https://github.com/mikejw", "twitter": "https://twitter.com/mikejw", "Facebook": "https://www.facebook.com/mikewhiting" }'

Change the useelib bootoptions setting in ./config.yml to true and set the defaultmodule bootoptions setting to 'blog'.

In order for the logical URLs within the blog to work properly the project needs to be served from Apache or similar web browser wih the following rewrite/routing rules in place (for modrewrite). Typically these would go in ./publichtml/.htaccess.

RewriteRule ^([0-9]{4})/?$ index.php?module=blog&class=blog&event=year&id=$1 
RewriteRule ^([0-9]{4})/([a-z]{3})/?$ index.php?module=blog&class=blog&event=month&year=$1&month=$2 
RewriteRule ^([0-9]{4})/([a-z]{3})/([0-9]{2})/?$ index.php?module=blog&class=blog&event=day&year=$1&month=$2&day=$3 
RewriteRule ^([0-9]{4})/([a-z]{3})/([0-9]{2})/([a-z0-9-]+)/?$ index.php?module=blog&class=blog&event=item&year=$1&month=$2&day=$3&slug=$4&id=0 
RewriteRule ^tags/([_a-z0-9-\+]+)/?([0-9]+)?/?$ index.php?module=blog&class=blog&event=tags&active_tags=$1&id=$2
RewriteRule ^tags/?$ index.php?module=blog&class=blog&event=tags
RewriteRule ^set_category/([a-z]+)?/?$ index.php?module=blog&class=blog&event=set_category&category=$1 
RewriteRule ^category/([a-z]+)?/?$ index.php?module=blog&class=blog&event=category&category=$1 

View / frontend

Install bootstrap:

npm install 
make grunt

Follow this guide for creating blog frontend components.


Sign into the backend with username 'mikejw' and password 'password' at http://localhost/public_html/user/login"

Create a symlink to the admin asset directory:

cd public_html; ln -s ../vendor/mikejw/elib-base/public ./admin

Create the directory ./public_html/uploads and chmod to 777 for file uploads.

Update variables (WEBROOT, PUBLICDIR) in the file ./public_html/js/common.js to reflect those used in config.yml. This will ensure the drop-down help menu functions properly.