Skip to content

Tag: symfony

symfony2 get command line executed

I am creating a console command in symfony2. I need to log an executed line i run. How to get that line? So if i run: I want to get value “php app/console my-command fileName.txt –myoption=100” Thanks for any help Answer I’m interpreting the question as: Within the Command code itself,…

Symfony2 Accessing route variables

I know I can access current route name by $request->get(‘_route’);. If my route is defined this way: How can I retrieve the id variable from within service? Answer $request->attributes->get(‘id’) does the trick.

How can I send JSON response in symfony2 controller

I am using jQuery to edit my form which is built in Symfony. I am showing the form in jQuery dialog and then submitting it. Data is entering correctly in database. But I don’t know whether I need to send some JSON back to jQuery. Actually I am bit confused with JSON thing. Suppose I have added a row in

Getting all request parameters in Symfony 2

In symfony 2 controllers, every time I want to get a value from post I need to run: Is there any way to consolidate these into one statement that would return an array? Something like Zend’s getParams()? Answer You can do $this->getRequest()->query->all(); to get all GET params and $this->ge…