Пример #1
0
 protected function load_model()
 {
     $params = array();
     foreach (func_get_args() as $index => $n) {
         if ($index == 0) {
             $path = $n;
         } else {
             $params[] = $n;
         }
     }
     $name = Loader::getHandlerFromPath($path);
     return is_null($this->{$name}) ? $this->{$name} = Loader::model($path, $params) : $this->{$name};
 }
Пример #2
0
<?php

use Ilex\Core\Loader;
/** @var \Ilex\Route\Route $Route */
$Route->get('/', function () {
    echo 'Hello world!';
});
$Route->post('/user/(any)', function ($name) {
    /** @var \Ilex\Base\Model\sys\Input $Input */
    $Input = Loader::model('sys/Input');
    echo 'Hello ' . $Input->post('title', 'Guest') . ' ' . $name . '!';
});
$Route->get('/projects', 'Project');
$Route->get('/project/(num)', 'Project', 'view');
$Route->group('/planet', function ($Route) {
    /** @var \Ilex\Route\Route $Route */
    $Route->get('/', function () {
        echo 'Hello Cosmos!';
    });
    $Route->back();
});
$Route->controller('/about', 'About');
$Route->controller('/play', 'Play');
$Route->get('(all)', function ($url) {
    echo 'Oops, 404! "' . $url . '" does not exist.';
});