Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8417243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:59:10+00:00 2026-06-10T01:59:10+00:00

How can I get various parameters related to the page request in zf2? Like

  • 0

How can I get various parameters related to the page request in zf2? Like post/get parameters, the route being accessed, headers sent and files uploaded.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T01:59:12+00:00Added an answer on June 10, 2026 at 1:59 am

    The easiest way to do that would be to use the Params plugin, introduced in beta5. It has utility methods to make it easy to access different types of parameters. As always, reading the tests can prove valuable to understand how something is supposed to be used.

    Get a single value

    To get the value of a named parameter in a controller, you will need to select the appropriate method for the type of parameter you are looking for and pass in the name.

    Examples:

    $this->params()->fromPost('paramname');   // From POST
    $this->params()->fromQuery('paramname');  // From GET
    $this->params()->fromRoute('paramname');  // From RouteMatch
    $this->params()->fromHeader('paramname'); // From header
    $this->params()->fromFiles('paramname');  // From file being uploaded
    

     

    Default values

    All of these methods also support default values that will be returned if no parameter with the given name is found.

    Example:

    $orderBy = $this->params()->fromQuery('orderby', 'name');
    

    When visiting http://example.com/?orderby=birthdate,
    $orderBy will have the value birthdate.
    When visiting http://example.com/,
    $orderBy will have the default value name.
     

    Get all parameters

    To get all parameters of one type, just don’t pass in anything and the Params plugin will return an array of values with their names as keys.

    Example:

    $allGetValues = $this->params()->fromQuery(); // empty method call
    

    When visiting http://example.com/?orderby=birthdate&filter=hasphone $allGetValues will be an array like

    array(
        'orderby' => 'birthdate',
        'filter'  => 'hasphone',
    );
    

     

    Not using Params plugin

    If you check the source code for the Params plugin, you will see that it’s just a thin wrapper around other controllers to allow for more consistent parameter retrieval. If you for some reason want/need to access them directly, you can see in the source code how it’s done.

    Example:

    $this->getRequest()->getRequest('name', 'default');
    $this->getEvent()->getRouteMatch()->getParam('name', 'default');
    

    NOTE: You could have used the superglobals $_GET, $_POST etc., but that is discouraged.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm maintaining a script that can get its input from various sources, and works
When writing a Maven plugin, you can configure various parameters within the mojo class,
Can get all triples with value null in specific field? All people with date_of_birth
We can get class Class object by 3 methods: MyClass.class obj.getClass Class.forName(className) I don't
I can get the file path with: (message (file-name-directory (or buffer-file-name load-file-name))) But if
I can get this to work: [<DllImport(user32.dll)>] extern bool GetClientRect(nativeint, RECT*) let getClientRect hwnd
You can get the nodes of the document object of an <iframe> with the
You can get underground processes by ps ux I am searching a way to
You can get a list of databases using PRAGMA database_list or a list of
I can get the current selected row in this way: private void DataGridView1_CellContentClick(object sender,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.