A light-weight framework written in PHP
PHP HTML
Switch branches/tags
Nothing to show
Permalink
Failed to load latest commit information.
assets
config
core
services
views
.gitignore
.gitmodules
README.md
bootstrap.php

README.md

Beaba-light

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

What does this version

  • Boostrap a web environement
  • Routing
  • Light model layer (a bilbon ORM version)
  • Templating (template - layout - reusable views & components)
  • Application injection layer based on services

List of built-in 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

Extras

Beaba is totaly compliant with these great projects :

  • forp & forp-ui
  • bootstrap css (from twitter)

Your application structure

  +- 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.

How to create an application

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

A controller sample

<?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 ...
        );
    }
}