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

APi URL parameter problem #598

Closed engharb closed 3 years ago

engharb commented 6 years ago

Dears,

I'm using Symfony4 as project framework and I installed Restler Api.

I have a problem that when I call i.e api/explorer/functionName?abc=xxx

it says the argument abc is required. ???

I have chaeck my request url and I found that the GET parameter is rendered as \abc? Why?

Is there something to do with app.php or explorer/index.php.

//app.php
use App\Kernel;
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;

/** @var \Composer\Autoload\ClassLoader $loader */
$loader = require __DIR__.'/../../vendor/autoload.php';
if (PHP_VERSION_ID < 70000) {
    include_once __DIR__.'/../../var/bootstrap.php.cache';
}

// The check is to ensure we don't use .env in production
if (!isset($_SERVER['APP_ENV'])) {
    if (!class_exists(Dotenv::class)) {
        throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
    }
    (new Dotenv())->load(__DIR__.'/../../.env');
}

$kernel = new Kernel('prod', false);
if (PHP_VERSION_ID < 70000) {
    //$kernel->loadClassCache();
}

// fix undefined index notice's in restler lib
error_reporting(E_ERROR | E_WARNING | E_PARSE);

Luracast\Restler\Resources::$hideProtected = false;
Luracast\Restler\Resources::$placeFormatExtensionBeforeDynamicParts = false;
Luracast\Restler\Defaults::$crossOriginResourceSharing = true;
//let restler handle the api request
$API_PREFIX = "secret";
$r = new \Luracast\Restler\Restler(false, true);
$r->addAPIClass('Luracast\\Restler\\Resources'); //this creates resources.json at API Root
$r->addAPIClass('Luracast\\Restler\\Explorer\\v1\\Explorer'); //this creates resources.json at API Root

$r->setSupportedFormats('JsonFormat', 'XmlFormat', 'CsvFormat');
$r->addAPIClass('App\Api\SecretApi', $API_PREFIX);

$secretApi = Luracast\Restler\Scope::get('App\Api\MyApi');

$kernel = new Kernel('dev', true);
if (PHP_VERSION_ID < 70000) {
    //$kernel->loadClassCache();
}

$secretApi->kernel = $kernel;
$kernel->boot();
//RateLimit::setLimit('hour', 5000, 5010);
//$r->addFilterClass('RateLimit');
$r->handle();
Arul- commented 6 years ago

What will be the role of Restler in this?

Arul- commented 3 years ago

This kind of mix and match with Symfony is not supported