Exemplo n.º 1
0
<?php

//Change the include path to point to your application directory
ini_set('include_path', '../application:' . ini_get('include_path'));
//Change the include path of fango if you need
require_once '../../../fango.php';
require_once 'controllers/default.php';
//Just to show how plugins work
require_once 'plugins/stupid.php';
new StupidPlugin();
FangoDB::connect('mysql:dbname=fango;host=127.0.0.1', 'root');
$fango = new Fango();
//I'd like to have just a Controller for this application so a specify
//a custom rule using a regular expresssion
//By default the rules are /controller/actionname/par1/value1/par2/value2...
//The controller has to have a method named {actionname}Action, eg. indexAction
$fango->run('(\\w+)/?(.*)$ controller=default,action=$1,params=$2');
Exemplo n.º 2
0
<?php

ini_set('include_path', '../application:' . ini_get('include_path'));
require_once '../../fango.php';
require_once 'controller/default.php';
error_reporting(E_ALL);
$rules[] = '^/?$ controller=default,action=index';
$rules[] = '^(\\w+)/?$ controller=default,action=showClass,class=$1';
$rules[] = '^(\\w+)/(\\w+)/?$ controller=default,action=showMethod,class=$1,method=$2';
$fango = new Fango();
$fango->route($rules)->dispatch();
Exemplo n.º 3
0
        return $this;
    }
    /**
     * @param Object $subject
     */
    static function lazyLoading($subject, $event)
    {
        if (isset($subject->events) && is_array($subject->events) && in_array($event, $subject->events)) {
            $subject->{$event} = new FangoEvent($event);
            return $subject->{$event};
        }
        throw new Exception("Property {$event} doesn't exists");
    }
}
//onNew events set to class level
Fango::$onNew = new FangoEvent('onNew');
FangoDB::$onNew = new FangoEvent('onNew');
FangoModel::$onNew = new FangoEvent('onNew');
FangoView::$onNew = new FangoEvent('onNew');
FangoController::$onNew = new FangoEvent('onNew');
//CREATE A BASE APPLICATION STRUCTURE
if (PHP_SAPI === 'cli') {
    if (strtolower($argv[1]) === 'create') {
        if (version_compare(PHP_VERSION, '5.3.0') < 0) {
            throw new Exception("Version 5.3.0 minimum required");
        }
        if ($argc > 2) {
            $dir = $argv[2];
        } else {
            $dir = dirname(PHP_SELF);
        }