libheart - PHP Web Application Framework

What is libheart?

libheart is a collection of leading PHP solutions for the common things that a web application may require, such as database access and templating, glued together into a coherent framework. libheart also extends the third party tools to allow them to assist one another to provide unique features.

I still don't quite get it...

Here's an example. Say you're given the task of creating an application, or perhaps you want to create a database-driven website. What might you normally do? Perhaps you setup PEAR so you can use PEAR::DB for database access and PEAR::Log for logging. Perhaps you download the latest smarty and set that up as well. What about other common things like authentication, form building, e-mailing...

Obviously, setting that stuff up gets tedious after a while. You'd rather be coding the meat of your application, right? That's what libheart comes in.

libheart changes this process from being a two-hour slog to find all the "parts" you need into a five minute configuration job. The steps involved are as follows:

  1. Download libheart: currently, just do an anonymous checkout from CVS, though in future downloads will be available.
  2. Add to your include path: If you are able to edit your configuration somehow, just add libheart to your include_path. Failing that, you can use the htdocs/libheart.php to set the absolute path to your libheart installation.
  3. Write a libheart config file: You simply write a configuration file to hook in only the modules you need. An example file might look like:
    $lhc['core']['posthook'] = 'setup.php';
    
    // DB configuration
    $lhc['db']['enabled'] = true;
    $lhc['db']['phptype']  = 'pgsql';
    $lhc['db']['username'] = 'myuser';
    $lhc['db']['password'] = 'mypasswd';
    $lhc['db']['database'] = 'mydb';
    $lhc['db']['fetchmode'] = DB_FETCHMODE_ASSOC;
    
    // Smarty configuration
    $lhc['smarty']['enabled'] = true;
    $basedir = '/your/project/include/dir/';
    $lhc['smarty']['template_dir'] = $basedir . 'templates';
    $lhc['smarty']['compile_dir'] = $basedir . 'templates_c';
    
    // Logging configuration
    $lhc['log']['enabled'] = true;
    $lhc['log']['handler'] = 'file';
    $lhc['log']['name']    = '/var/log/apache/my.log';
    $lhc['log']['ident']   = 'projname';
    $lhc['log']['level']   = PEAR_LOG_DEBUG;
    
    // Quickform configuration
    $lhc['quickform']['enabled'] = true;
    $lhc['quickform']['defaulttracksubmit'] = true;
    
    // Message Handler configuration
    $lhc['messagehandler']['enabled'] = true;
    
    // Auth configuration
    $lhc['auth']['enabled']   = true;
    $lhc['auth']['loginfunction'] = 'login';
    $lhc['auth']['showlogin'] = true;
    Notice how all you have to do for a module is define it as enabled, then define some extra things for your application.
  4. Include libheart.php in your scripts: If you put libheart in your include_path, simply require_once the libheart.php file, otherwise require_once the libheart file you moved to your project's directory.

And instantly, you have database access, logging, templating...

There's more to it than that, but I haven't got time now. I will put more here later, or if you ask me: nigel.mcnie@gmail.com.

SourceForge.net Logo