Luracast / Restler

Simple and effective multi-format Web API Server to host your PHP API as Pragmatic REST and/or RESTful API
http://luracast.com/products/restler/
GNU Lesser General Public License v2.1
1.36k stars 315 forks source link

Defaults::$smartAutoRouting issue #612

Closed eduh closed 5 years ago

eduh commented 5 years ago

I am migrating from restler2 to version 3. I try to disable the $smartAutoRouting but it looks like I struggle with the location of Defaults::$smartAutoRouting = false;

In index.php this throws an error Class 'Defaults' not found in .....

require_once 'vendor/restler.php';
use Luracast\Restler\Restler;
$r = new Restler();
Defaults::$smartAutoRouting = false;

When I alter index.php the error disappears but it looks like smartautorouting is still on

require_once 'vendor/restler.php';
use Luracast\Restler\Restler;
$r = new Restler();
$r->setSupportedFormats('JsonFormat');
$r->addAPIClass('say');
$r->handle('');
Defaults::$smartAutoRouting = false;

One other question: I see Restler2.0 is running on php 7.1 for basic functionality but are there compatible issues known?

Arul- commented 5 years ago

Try importing the Defaults class as well

require_once 'vendor/restler.php';
use Luracast\Restler\Restler;
use Luracast\Restler\Defaults;

$r = new Restler();
$r->setSupportedFormats('JsonFormat');
$r->addAPIClass('say');
$r->handle('');
Defaults::$smartAutoRouting = false;

We have not tried restler 2 on php 7.1 please try and let us know if you hit any issue, we can write a fix!

eduh commented 5 years ago

This seems to work and the Defaults::$smartAutoRouting should be set before the init of Restler.

require_once 'vendor/restler.php';
use Luracast\Restler\Restler;
use Luracast\Restler\Defaults;
Defaults::$smartAutoRouting = false;
$r = new Restler();
$r->setSupportedFormats('JsonFormat');
$r->addAPIClass('say');
$r->handle('');

But now it throws some warnings

<b>Notice</b>:  Undefined index: properties in <b>......Luracast/Restler/Routes.php</b> on line <b>469</b><br />
<br />
<b>Notice</b>:  Undefined index: properties in <b>......Luracast/Restler/Routes.php</b> on line <b>469</b><br />
<br />
<b>Notice</b>:  Undefined offset: 2 in <b>......Luracast/Restler/Restler.php</b> on line <b>948</b><br />
<br />
<b>Notice</b>:  Undefined offset: 3 in <b>......Luracast/Restler/Restler.php</b> on line <b>948</b><br />

It looks like this is caused by some PHPDOC content. It contained an old piece of a non-existing parameter ( @param string $did_not_exist) . Is there a way to disable the validation of PHPdoc content?

Arul- commented 5 years ago

The only way is to clean up the phpdoc comments