0

I am having a bit of an issue implementing the smart url routes in Restler PHP REST Framework v3. Basically it appears as if Restler is ignoring my comments. I have attached my index.php and tests.inc.php files here. What is happening, is even with the PHPDoc comments, it seems as though restler is ignoring them and only responding to the default "tests" call and not "some/new/route" as I would have expected based on the routes example provided with the framework.

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;
    }
}

I have been trying a number of different things to attempt to find the root problem. It is worth noting that I haven't seemed to be able to locate the "routes.php" file so I am possibly thinking it might be a write permission issue on the server. Anyhow, any help would be greatly appreciated!

Nate McIntyre
  • 63
  • 1
  • 7

1 Answers1

0

Your comment is not a valid PHPDoc comment, it is just a regular comment thats all

Look at the following for the correct syntax

<?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;
    }
}

a Doc Comment starts with /** instead of /*

Arul Kumaran
  • 983
  • 7
  • 23