示例#1
0
文件: __init.php 项目: toohamster/ws
<?php

use Ws\Env;
use Ws\Mvc\Request;
use Ws\Mvc\Cmd;
$app = $this->me();
/*@var $app \Ws\Mvc\App */
$dir = $app->config()->get('app.dir');
// 注入类路径
Env::classLoader()->addPsr4('Im\\', $dir);
// 绑定命令
Cmd::id('index')->bind(Request::GET, function ($app) {
    output('App: ' . $app->config()->get('app.id'), '');
    output('Hello World!', 'text');
    output($app->pagePathing('who.are.you', ['name' => 'a test']), 'url');
    output($app->jsonPathing('who.love.you', ['tag' => 'php']), 'url');
})->bindTo($app);
Cmd::id('view')->bind(Request::GET, 'Im\\Controller\\Index@index')->bindTo($app);
Cmd::group([['id' => 'hello', 'event' => Request::GET, 'closure' => function ($a) {
    Env::dump($a);
}]])->bindTo($app);
// Env::dump($app);
示例#2
0
文件: AsDebug.php 项目: toohamster/ws
 public static function cmdBind(App $app)
 {
     Cmd::group([['id' => 'asdebug', 'event' => Request::GET, 'closure' => function ($a) {
         $f = Request::get('f');
         if ($f == 'json') {
             return AsDebug::instance()->cmdView($a, 'json');
         }
         return AsDebug::instance()->cmdView($a, 'ui');
     }]])->bindTo($app);
 }