Request dispatcher for PHP JSON web service
Now, to my best knowledge, $this->request in PHP always points to the HTTP-request when a HTTP-request has just been made


My guess is that you are thinking of the super-global $_REQUEST? That is not the same as $this-&gt;request (unless somehow that instance variable gets set to something else)...


  Is it okay to just ignore the warning or is there a best practice to deal with it?


Declare the property, just as the other instance properties are declared (i.e. $method, $endpoint, $verb, etc.):

class BaseAPI {

    protected $request;


That way the IDE will know that the property should at least exist for each instance (though it might not be assigned a value until that switch statement).

Other Feedback

Switch statement cases:


switch ($this-&gt;method) {
        case 'DELETE':
        case 'PUT':
            // don't do anything yet



Those first cases are missing a break; so the PHP pre-processor will fall-through to the POST case.

header() calls in constructor

The three calls to header() in the constructor feels a little strange but then again it is difficult to know what the rest of your code looks like. Typically those would go in a method to render/send output.