Override Zend\Http\Request

Discussion for various published PHP frameworks, including Zend Framework, CodeIgniter, Kohana, CakePHP, Yii, Symfony, and others.

Moderator: General Moderators

Post Reply
User avatar
DaveTheAve
Forum Contributor
Posts: 385
Joined: Tue Oct 03, 2006 2:25 pm
Location: 127.0.0.1
Contact:

Override Zend\Http\Request

Post by DaveTheAve »

I have tried several ways to acheive this and each time I receive the error
Fatal error: Uncaught exception 'Zend\View\Exception\RuntimeException' with message 'No base path provided' in \vendor\zendframework\zendframework\library\Zend\View\Helper\BasePath.php on line 38
First I tried:

Code: Select all

    'service_manager' => array(
        'invokables' => array(
            'request' => 'Application\Http\Request',
        ),
    ),
That told me I could not override the class. So I tried this:

Code: Select all

    public function onBootstrap(MvcEvent $e)
    {
        $serviceManager        = $e->getApplication()->getServiceManager();
        $serviceManager->setAllowOverride(true)
            ->setInvokableClass('request', 'Application\Http\Request')
            ->setAllowOverride(false);
    }
The whole reason I'm doing this is because I have the need for "per-instance variables", variables that only last for that single HTTP GET execution. Essentially, I wish to have an access log built into my system but I do not wish for it to log EVERY AJAX query yet I do need SOME AJAX queries logged. For instance, I don't want calls to AjaxController\getCompanyListingAction() to be logged but I would like AjaxController\createNewCompanyAction() to be logged.

Would anyone please be kind enough to point me in the right direction? :D

I have already extended Zend\Http\Request with "getInstanceParam()" and "setInstanceParam()" functions and just wish to plug-it-in but I am open to alternative options.
Post Reply