PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, March 9, 2022

[FIXED] Symfony ResponseEvent arguments

 March 09, 2022     php, symfony     No comments   

Issue

I'm following a Symfony tutorial and am currently on The Event Dispatcher section. In the first code block (after the composer part) I'm instructed to set up the dispatcher

// dispatch a response event
$this->dispatcher->dispatch(new ResponseEvent($response, $request), 'response');

I'm using PHPStorm, and when I create the ResponseEvent class it is asking for 4 arguments

new ResponseEvent($kernel, $request, $requestType, $response)

While I could create a $kernel element by importing the HttpKernelInterface, I'm unsure if this is correct.

I also have no idea where to get the $requestType from, since the ResponseEvent class definition says that this should be of type int and I only know of request types in string format (e.g. 'GET', 'POST' etc).

Here is the full file in case I have made a mistake elsewhere.


Solution

The tutorial that you are following wants you to use the Simplex ResponseEvent, that method signature is for the kernel ResponseEvent

At the top of your file you should see something like this:

use Symfony\Component\HttpKernel\Event\ResponseEvent;

Replace it with

use Simplex\ResponseEvent;


Answered By - TheGentleman
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing