/**
 * 追踪一下流程,你就会写一个php框架了。代码比较简单,不绕,应该花不了多少时间,或许一两天吧
 * 1)域名指向【public/】后,追踪【http://域名/mobile-web/admin/router/index/4-on.html】
 *
 * 需注意的地方
 * 1)【business/framework】目录,可按实际业务需求,随意修改
 * 2)在以下方法中,插入代码、调用其他方法,可以影响全局【流程:flow】
 *
 */

源码下载


/**
 * business/framework/application.php
 */
public function run()
{
    $resource_container = $this->_init_resource_container();
    $flow_handler       = $this->_init_flow_handler();

    $flow_handler->run();
}

/**
 * business/framework/application/flow_handler.php
 */
public function run()
{
    $resource_container = wwy_resource_container::get_instance();

    //$request = $resource_container->get_request();
    //var_dump($request); exit();

    $router = $resource_container->get_router();
    //var_dump($router); exit();
    //$request = $router->route();
    $router->route();

    $result = $this->dispatch();
}

/**
 * business/framework/application/flow_handler/controller.php
 */
public function dispatch($action)
{
    //$result = $this->_pre_dispatch();
    $result = $this->$action();
    //$result = $this->_post_dispatch();

    return $result;
}

/**
 * business/framework/application/flow_handler/controller_server.php
 */
public function dispatch($action_service, $param_data)
{
    $this->_init();

    //$data = $this->_pre_dispatch();
    $data = call_user_func_array(array($this, $action_service), $param_data);
    //$data = $this->_post_dispatch();

    return $data;
}