首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不使用Restler PHPDoc v3的智能路由

不使用Restler PHPDoc v3的智能路由
EN

Stack Overflow用户
提问于 2013-03-12 02:31:53
回答 1查看 413关注 0票数 0

在Restler、PHP框架v3中实现智能url路由有点问题。从根本上看,莱斯特勒似乎忽视了我的评论。我已经在这里附上了我的index.php和tests.inc.php文件。现在发生的事情,即使是PHPDoc注释,似乎也忽略了它们,并且只响应默认的“测试”调用,而不是“一些/新/路由”,正如我根据框架提供的路由示例所期望的那样。

index.php

代码语言:javascript
复制
<?php

$root_dir = $_SERVER['DOCUMENT_ROOT'];
$base_dir = getcwd();
$include = "{$base_dir}/include";
require_once("{$include}/config.inc.php");
require_once("{$include}/library-general.inc.php");

//include restler library
$restler_dir = "{$root_dir}/restler/{$settings['restler_version_string']}";
require_once("{$restler_dir}/restler.php");

//restler configuration
use Luracast\Restler\Restler;
use Luracast\Restler\Defaults;

//include database connector class
require_once("{$include}/db_connector_mysql.inc.php");

//include api handler classes
require_once('test.inc.php');
require_once('accounts.inc.php');

//instantiate our restler object; call with argument "true" to run in production mode
$r = new Restler();

//bind api classes
$r->addAPIClass('Tests');
$r->addAPIClass('Accounts');

//set supported formats: JSON ONLY!
$r->setSupportedFormats('JsonFormat');

//handle the request
$r->handle();

test.inc.php

代码语言:javascript
复制
<?php

class Tests {

    private $dbc;
    private $function_log_tag;

    public function __construct () {
        $this->dbc = DB_Connector_MySQL::getConnection();
        $this->response = new stdClass();
    }

    /*
    ** @url GET /some/new/route
    */
    public function get () {
        //load required global variables
        global $settings;

        //set logging tag
        $this->function_log_tag = '[' . __CLASS__ . '::' . __FUNCTION__ . '][v' . $settings['version'] . ']';

        return $this->function_log_tag;
    }
}

我一直在尝试一些不同的东西,试图找出问题的根源。值得注意的是,我似乎还无法找到"routes.php“文件,因此我可能认为这可能是服务器上的写权限问题。无论如何,任何帮助都将不胜感激!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-03-12 12:51:23

您的评论不是有效的PHPDoc评论,它只是一个常规的评论。

有关正确的语法,请参阅以下内容

代码语言:javascript
复制
<?php

class Tests {

    private $dbc;
    private $function_log_tag;

    public function __construct () {
        $this->dbc = DB_Connector_MySQL::getConnection();
        $this->response = new stdClass();
    }

    /**
    * @url GET /some/new/route
    */
    public function get () {
        //load required global variables
        global $settings;

        //set logging tag
        $this->function_log_tag = '[' . __CLASS__ . '::' . __FUNCTION__ . '][v' . $settings['version'] . ']';

        return $this->function_log_tag;
    }
}

Doc注释以/**而不是/*开头

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15352295

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档