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

  • Home
  • SEARCH
  • 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 8198255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:54:48+00:00 2026-06-07T05:54:48+00:00

I’m testing ZF2 beta4 at the moment, and I’m having some issues accessing some

  • 0

I’m testing ZF2 beta4 at the moment, and I’m having some issues accessing some of the request properties from my controller.

From inside the indexAction(), here is an extract of what I get for the request object

var_dump($this->request); gives me:

object(Zend\Http\PhpEnvironment\Request)#119 (14) {

  ["baseUrl":protected]=>
    string(0) ""

  [...]

  ["version":protected]=>
    string(3) "1.1"

  ["queryParams":protected]=>
    object(Zend\Stdlib\Parameters)#122 (1) {
      ["storage":"ArrayObject":private]=>
      array(3) {
        ["q"]=>
        string(0) ""
        ["param1"]=>
        string(6) "value1"
        ["param2"]=>
        string(6) "value2"
      }
    }

I can access some of the properties:
var_dump($this->request->getBaseUrl()); -> string(0) ""
var_dump($this->request->getVersion()); -> string(3) "1.1"

But I am having issues with others, for instance $this->request->getQueryParams() returns:

Call to undefined method
Zend\Http\PhpEnvironment\Request::getQueryParams()

From there I have a few questions:
-Am I doing something wrong?
If not:
-How can I access the queryParams property?
-Is it common practice not to have methods to access certain properties (if so what’s the point of having these properties if I can’t access them) ?

  • 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-07T05:54:49+00:00Added an answer on June 7, 2026 at 5:54 am

    All the properties you dumped are protected, it’s why you needed a getter to fetch their values.

    Existing getter for some properties don’t mean that they exist for all 🙂

    If you take a look at the source of Zend\Http\Request (which is inherited by Zend\Http\PhpEnvironment\Request) you can see that the method name used to access the query param is query()

    Note: I agree that’s a bit inconsistent.

    Warning: It has been changed since the beta5 and it is now getQuery()

    Protected and private members are used to ensure that the data won’t be accessed directly.

    It is mostly used for internal use only, or provided with a public setter/getter to allow transformation, error checking, etc.

    For example, you may want to add type hinting.

    class Car {
    
        public $engine;
    }
    
    $car = new Car();
    $car->engine = new Truck();
    
    // Having a public member doesn't allow me to check for valid type (I don't want a `Truck` to be set in place of an `Engine`)
    
    class Car {
        private $engine;
    
        public setEngine(Engine $engine)
        {
            $this->engine = $engine;
            // Add additional code here
            $this->engine->warmUp();
        }
    }
    
    // Here I use type hinting to ensure validity of data, I also warmUp the Engine just after setting it.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a view passing on information from a database: def serve_article(request, id): served_article
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.