| Recommend this page to a friend! | 
| Info | Documentation | Reputation | Support forum | Blog | Links | 
| Ratings | Unique User Downloads | Download Rankings | ||||
| Not enough user ratings | Total: 253 | All time:  7,888 This week: 455 | ||||
| Version | License | PHP version | Categories | |||
| lean 1.0.0 | GNU General Publi... | 5.3 | PHP 5, Libraries | 
| Description | Author  | ||||||||||||||||||||||
This package is a general purpose Web application framework.  | 
  | ||||||||||||||||||||||
Lean Framework is a tiny PHP framework (~40KB), modern frameworks are powerfull but so much complicated. With Lean I can construct apps really fast, using mvc, namespaces, autoloader, routes and more.
PHP 5.3+
-- app
	-- main (module)
		-- controllers
			-- BasicController.php
		-- models
		-- views
			-- basic
				-- index.phtml
	-- secondary (other module)
		-- controllers
		-- models
		-- views
-- public_html
	-- css
	-- js
	-- img
	-- index.php
	-- .htaccess
-- settings
	-- Bootstrap.php
	-- Routes.php
-- vendor
	-- Lean
	-- autoloader.php
create file index.php into public_html
<?php require_once '../settings/Bootstrap.php'; ?>
create file .htaccess into public_html to custom urls
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
create file autoloader.php into vendor directory, and use the Symfony Autoloader
<?php
require_once __DIR__ . '/Lean/Libs/Symfony/Component/ClassLoader/UniversalClassLoader.php';
/*
 * add new libs in autoloader is easy, clone libs in vendor directory and add array position, see example to Zend Framework and Amazon Web Service libs
 * $loader->registerNamespaces(array(
 * 		'Lean'     => __DIR__,
 *		'Zend'     => __DIR__,
 * 		'AWS'     => __DIR__
 * ));
 *
 * Just for now add only Lean Framework PHP lib, see below
 */
$loader = new Symfony\Component\ClassLoader\UniversalClassLoader();
$loader->registerNamespaces(array(
	'Lean'     => __DIR__
));
$loader->useIncludePath(true);
$loader->register();
create file Bootstrap.php into settings
<?php
require_once '../vendor/autoloader.php';
/
 * errors
 */
error_reporting(E_ALL);
/
 * include path
 */
set_include_path(
	PATH_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 
	PATH_SEPARATOR . get_include_path());
/ 
 * locale e zone 
 */
date_default_timezone_set('America/Sao_Paulo');
setlocale(LC_ALL, 'pt_BR', 'pt_BR.iso-8859-1', 'pt_BR.utf-8', 'portuguese');
/
 * init lean framework
 */
Lean\Launch::instance()->run();
It's work, access in your browser http://localhost/lean_project/public_html
Remember, in your domain shows only www.yourdomain.com
<?php
namespace app\main\controllers;
class IndexController extends \Lean\App
{
	public function index()
	{		
		echo 'HELLO WORLD';
	}
}
Call non-default module, controller and method, type in your browser localhost http://localhost/lean_project/public_html/foo/product/do-something
Remember, in your domain shows only www.yourdomain.com/foo/product/do-something
<?php
namespace app\foo\controllers;
class ProductController extends \Lean\App
{
	public function do_something()
	{		
		/*
		 * your action here
		 */
	}
}
http://localhost/lean_project/public_html/foo/product?name=foo&category=bar&price=15
<?php
namespace app\foo\controllers;
class ProductController extends \Lean\App
{
	public function index()
	{		
		/
		 * get HTTP $_REQUEST
		 */
		$request = $this->request();
		$name = $request->name;
		$category = $request->category;
		$price = $request->price;
	
	
		/
		 * get only $_POST
		 */
		$request = $this->request()->post();		
		
		/
		 * get only $_GET
		 */
		$request = $this->request()->get();		
		
		/
		 * get only $_FILE
		 */		 
		 $request = $this->request()->file();		
		 
		 
		/*
		 * your action here
		 */
	}
}
Create followings views index.phtml and edit.phtml into views
-- app
	-- foo (module)
		-- controllers
			-- ProductController.php
		-- models
		-- views
			-- product
				-- index.phtml
				-- edit.phtml
			-- layout
				-- header.phtml
				-- footer.phtml
				-- template.html
Create template.phtml in layout directory, you can include header and footer parts here
<html>
<head>
	<title>My new app</title>
</head>
<body>
	<? $this->app->view->render('layout.header') ?>
	<div id="container">
		<!--
		-- content page setted in controller will be render here
		-->
		<? $this->app->view->make('content') ?>
	</div>
	
	<? $this->app->view->render('layout.footer') ?>
	
</body>
</html>
Controllers shows yours views
<?php
namespace app\foo\controllers;
class ProductController extends \Lean\App
{
	public function index()
	{	
		/
		 * set the product/index.phtml to be render
		 */
		$this->view()->set('content', 'index');
		
		/*
		 * render the template
		 */
		$this->view()->render('layout.template');
	}
	
	public function edit()
	{	
		/
		 * this render file "../views/product/edit.phtml"
		 */
		$this->view()->set('content', 'edit');
		
		$this->view()->render('layout.template');
	}
}
add into Bootstrap.php before launch Lean
...
/
 * routes
 */
Lean\Route::set_routes_path('settings/Routes.php');
/
 * init lean framework
 */
Lean\Launch::instance()->run();
create file Routes.php into settings
<?php
use Lean\Route;
Route::set('foo/bar', function() {
	echo 'Hi';
});
<?php
use Lean\Route;
Route::set('product/do', array(
	'module' => 'basic', 
	'controller' => 'product',
	'method' => 'do_something'
));
<?php
use Lean\Route;
Route::set('product/do', function() {
	new app/basic/controllers/ProductController::singleton->do_something();
});
Route::alias('do-something', 'product/do');
Route::alias(array('do-something', 'do-something2', 'foo', 'bar'), 'product/do');
Lean is released under MIT public license.
http://www.opensource.org/licenses/MIT
Copyright (c) 2014, Dyorg Almeida <[email protected]>
| File | Role | Description | ||
|---|---|---|---|---|
| Data | Auxiliary data | |||
| Class | Class source | |||
| Class | Class source | |||
| Class | Class source | |||
| Class | Class source | |||
| Class | Class source | |||
| Class | Class source | |||
| Class | Class source | |||
| Class | Class source | |||
| Doc. | Auxiliary data | |||
| Class | Class source | |||
| Class | Class source | |||
| Class | Class source | |||
| Class | Class source | |||
| Class | Class source | |||
| / | File | 
| File | Role | Description | 
|---|---|---|
|    | 
Class | Class source | 
|    | 
Class | Class source | 
|    | 
Class | Class source | 
|    | 
Class | Class source | 
|    | 
Class | Class source | 
|    | 
Class | Class source | 
| / | Format | 
| / | Libs | / | Symfony | / | Component | / | ClassLoader | 
| File | Role | Description | 
|---|---|---|
|    | 
Class | Class source | 
| / | Request | 
| / | Utils | 
| File | Role | Description | 
|---|---|---|
|    | 
Class | Class source | 
|    | 
Class | Class source | 
|    | 
Class | Class source | 
|    | 
Class | Class source | 
| The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. | 
| Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
| 100% | 
  | 
  | 
| Applications that use this package | 
 If you know an application of this package, send a message to the author to add a link here.