0
我在Restler PHP REST Framework v3中實現智能url路由時遇到了一些問題。基本上看來,Restler忽略了我的評論。我在這裏附加了我的index.php和tests.inc.php文件。發生了什麼,即使是PHPDoc註釋,似乎restler正在忽略它們,只響應默認的「測試」調用,而不是「some/new/route」,正如我期望的那樣,根據提供的路由示例該框架。使用PHPDoc的智能路由不能與Restler v3一起使用
的index.php
<?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
<?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」文件,因此我可能認爲它可能是服務器上的寫入權限問題。總之,任何幫助將不勝感激!
嘆......非常感謝。不能相信我沒有抓到,哈哈。 – 2013-03-12 20:47:44