Recommend this page to a friend! |
Download .zip |
Info | Documentation | View files (35) | Download .zip | Reputation | Support forum (1) | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2014-09-28 (2 years ago) | Not yet rated by the users | Total: 232 | All time: 7,556 This week: 1,099 |
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 <dyorg.almeida@gmail.com>
Files |
File | Role | Description | ||
---|---|---|---|---|
.phar (1 file) | ||||
File (6 files) | ||||
Format (3 files) | ||||
Libs (1 directory) | ||||
Request (4 files) | ||||
Session (1 file) | ||||
Utils (4 files) | ||||
.buildpath | Data | Auxiliary data | ||
App.php | Class | Class source | ||
Auth.php | Class | Class source | ||
Config.php | Class | Class source | ||
Format.php | Class | Class source | ||
Launch.php | Class | Class source | ||
Lean.php | Class | Class source | ||
Logger.php | Class | Class source | ||
Null.php | Class | Class source | ||
README.md | Doc. | Auxiliary data | ||
Request.php | Class | Class source | ||
Route.php | Class | Class source | ||
Session.php | Class | Class source | ||
Singleton.php | Class | Class source | ||
View.php | Class | Class source |
Files | / | File |
File | Role | Description |
---|---|---|
Download.php | Class | Class source |
Export.php | Class | Class source |
Handler.php | Class | Class source |
Image.php | Class | Class source |
Remove.php | Class | Class source |
Upload.php | Class | Class source |
Files | / | Format |
Files | / | Libs | / | Symfony | / | Component | / | ClassLoader |
File | Role | Description |
---|---|---|
UniversalClassLoader.php | Class | Class source |
Files | / | Request |
Files | / | Utils |
File | Role | Description |
---|---|---|
Hash.php | Class | Class source |
Label.php | Class | Class source |
Link.php | Class | Class source |
Select.php | Class | Class source |
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.