Git Product home page Git Product logo

beaba's Introduction

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

beaba's People

Contributors

ichiriac avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

emayk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.