Home > liteframe

liteframe

Liteframe is a project mainly written in PHP, it's free.

PHP 5.3+ lightweight framework

Liteframe PHP 5.3+ Framework http://github.com/nshahzad/liteframe

I know, I know, there are a ton of frameworks out there. But I needed something very lightweight, and figured it would be a nice and useful exercise in using some new features of PHP 5.3, particularly namespaces. This will stay really simple, emulating some of CakePHPs features. I'll be integrating Doctrine soon, but I don't really need database connectivity right now. I'm basically using this as a lookup server, for relaying Amazon API requests to the front-end, and caching them in memcache/APC.

CakePHP is a bit 'heavy' for my purposes, but I do like their ideas and some of their conventions. So I'm picking up their best habits and some of my habits I've picked up from using other frameworks as well. Overall, I just want this to be super light, with all the basics


Installation:

The easiest way to keep liteframe updated (since it's under heavy development) is to use it as a git repo:

git clone https://[email protected]/nshahzad/liteframe.git project
git submodule init
git submodule update

This also retrieves the php-activerecord submodule for database connectivity.


Usage:

Point Apache (or whatever webserver) to the app/www directory.

I'll have more detailed docs, but look at the app/controllers/default_controller.php Basically, that's it. I'll be adding more functions to the $this-> as I need them, or ones that make sense.

To add a new controller, create a file with

[controller name]_controller.php

With the class name being:

class [ControllerName]Controller extends LiteframeController {

}

For example:

filename: default_controller.php
class DefaultController extends LiteframeController {

}

Add your custom configuration options into app/config/config.php using:

LiteframeConfig::set('KEY', 'VALUE');

And retrieve using:

LiteframeConfig::get('KEY');

Default configuration options are located in:

/liteframe/config/config.php

Application Controller:

As with CakePHP, there's a controller you can use as the parent which you can modify to add custom stuff which is available to all controllers. The file is:

liteframe/controllers/app_controller.php

The default controller inherits from this. To customize, copy into the app directory:

app/app_controller.php

Layouts:

Under apps/layouts there's a default.tpl. This is the default layout used. You can have multiple layouts, and change the one that's used by changing:

$this->layout = 'default';

In the controller. All of your HTML will go there, just where content goes, place:

<?php echo $content_for_layout; ?>

You can also get information about the current controller/function using:

<?php print_r($run_info); ?>

$run_info is an Array containing:

Array ( [controller] => lookup [function] => index [args] => Array ( ) ) 

To Do List:

These are some things which I'll end up adding as I use this:

* Routing options/settings
* Integrate Doctrine2

License:

Copyright (c) 2010 Nabeel Shahzad

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.