Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

174
Vistas
SlimPhp 2 optional route

I'm making an API with PHP Slim 2.

I'm trying to get a JSON of the request which have an obligatory dqaid and optional parameters.

$app->get('/stats/getCrash/dqaid=:dqaid(/appid=:app_id(/reason=:reason(/appvid=:app_version_id(/reasonh=:reason_hash
            (/brand=:brand(/model=:model(/osversion=:os_version(/portal=:portal))))))))',
    function ($dqaid, $app_id = null, $reason = null, $app_version_id = null, $reason_hash = null, $brand = null,
              $model = null, $os_version = null, $portal = null) use ($app) {
    $app->response->setStatus(200);
    $app->response->setBody(json_encode(CrashFilters::createRequest($dqaid, $app_id, $reason, $app_version_id, $reason_hash, $brand,
                                                                    $model, $os_version, $portal)));
    $app->response->headers->set('Content-Type', 'application/json');
});

this works if I put the optional parameters in the right order like this :

localhost:8180/stats/getCrash/dqaid=ff50640713c84a99/appid=229338/reason=150258106

But if I omit one or put them in the wrong order I get an error 404.

I'd like to be able to put only those I want and in the order I want.

Another question : I'd like to be able to access my page like that in the future :

localhost:8180/stats/getCrash?dqaid=ff50640713c84a99&appid=229338&reason=150258106

So using ? and & instead of / in my url.

Where can I set that ?

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda