Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

270
Visualizações
Symfony Request get all url Parameters

I have a Symfony\Component\HttpFoundation\Request object and from it I want to fetch all the url paramethers that provided. In other words when the user visits the http://example.org/soempage?param1=value1&param2=value2&param3=value3

I want to generate an array that has these values ['param1','param2','param3'] .

Also I have seen this one: How to get all post parameters in Symfony2?

And I tried the following based on above:

    /**
     * @var request Symfony\Component\HttpFoundation\Request
     */
    $parametersToValidate=$request->request->all();
    $parametersToValidate=array_keys($parametersToValidate);

And

    /**
     * @var request Symfony\Component\HttpFoundation\Request
     */
    $parametersToValidate=$request->all();
    $parametersToValidate=array_keys($parametersToValidate);

Without the desired result but instead I get this error message:

Attempted to call an undefined method named "all" of class "Symfony\Component\HttpFoundation\Request\

Edit 1

The request I use int into a static method that validates my input. The method is called via the controller and is implemented like that for reusability purposes.

public static function httpRequestShouldHaveSpecificParametersWhenGiven(Request $request,array $parametersThatHttpRequestShouldHave)
    {
        $parametersToValidate=$request->parameters->all();

        if(empty($parametersToValidate)){
            return;
        }
        
        $parameters=array_keys($parametersToValidate);
        
        foreach($parameters as $param){
            if(!in_array($parameters,$parametersThatHttpRequestShouldHave)){            
                throw new InvalidNumberOfParametersException(implode(',',$parametersToValidate),implode(',',$parametersThatHttpRequestShouldHave),implode(',',$diff));
            }
        }
    }
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Did you try:

$parametersToValidate = $request->query->all();
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda