This project is a light-weight version of the beaba framework - a PHP MVC based framework - written for helping you to increase your dev productivity without needing to use a big or hard to understnd framework.
Objectives are the following :
- 5 minutes to understand main principles
- 5 minutes to configure your server
You're ready to start your dev
- Boostrap a web environement
- Routing
- Light model layer (a bilbon ORM version)
- Templating (template - layout - reusable views & components)
- Application injection layer based on services
- Configuration (extension handler)
- Storage (based on PDO)
- Model (based on a tiny Active Record Mapper)
- Views (templating engine based on phtml)
- Router (closures & controller/action compliant)
- Request (HTTP request wrapper)
- Response (Output handler)
Documentation : https://github.com/ichiriac/beaba-doc
Demos : https://github.com/ichiriac/beaba-demos
Beaba is totaly compliant with these great projects :
- forp & forp-ui
- bootstrap css (from twitter)
+- config*
|
+- controllers
|
+- model*
|
+- locale*
|
+- views
|
+- www
|
+- index.php (the application bootstrap)
- optionnal folders, but in major projets they should be used. In theory, beaba only require the index.php but it's not a good thing to put all the application into a single file.
-
Download and put beaba somewhere (ex: /etc/beaba/framework )
-
Start to create your application folder (ex: /etc/beaba/apps/my-app)
-
Create all application folders, including the index.php. (copy/paste the squeleton from https://github.com/ichiriac/beaba-demos/tree/master/default)
The content of your index.php is :
<?php
// defines bootstrap
define('BEABA_PATH', '/etc/beaba/framework');
define('APP_NAME', 'my-app');
require_once( BEABA_PATH . '/bootstrap.php' );
// initialize the app
$app = new beaba\core\WebApp(array(
'infos' => array(
'title' => 'Your website title'
),
'routes' => array(
// @see beaba documentation
)
));
// execute and sends the response
$app->getResponse()
->setLang(
$app->getRequest()->getLang()
)->write(
$app->dispatch()
)
;
- Configure your webserver, beaba can be run on apache or nginx
<?php
namespace app\controller;
use \beaba\core\Controller;
class index extends Controller {
public function index_action() {
return 'Hello world';
}
public function with_template_action() {
return $this->getView()->push(
'content', // the placeholder name 'content'
'controllers/index/with_template', // views/controllers/index/with_template.phtml
array(
'text' => 'sent to view'
)
);
}
public function with_rest_action($args) {
return array(
self::GET => array(
self::HTML => function() use($app, $args) {
return $app->getView()->push(
'index', $args
);
},
self::JSON => $args,
self::ALL => function() { // this is a wildcard fallback
return null;
}
),
self::PUT => null
// ... etc ...
);
}
}