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, you want to determine what was written on the
Tag: symfony
How to retrieve all Variables from a Twig Template?
Is it possible to retrieve all variables inside a Twig template with PHP? Example someTemplate.twig.php: Now I want to do something like this: $variables should now contain “name” and “email”. The reason I want to do this is that I am working on a CMS system where my twig templates and variables are dynamically set by my users and they
getHost() or $_SERVER[‘SERVER_NAME’] from command component in Symfony2
I am executing a task (command component) in Symfony2 and I would like to use $this->getRequest()->getHost() just like I do in a controller. What is the way to get that value (/Command/…
How to use ‘interval’ in Doctrine2 Query Builder
In my Symfony2 repository, I’d like to get objects from a schedule table, that have started, but not finished yet. The interval, within the objects should be encountered as ‘not finished’, should be passed as a variable. Using plain SQL, it works like this: Can I achieve the same with DQL / Query Builder? This is what I have so
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->getRequest()->request->all(); to get all POST params. So in your case: For more
How to force Doctrine to update array type fields?
I have a Doctrine entity with array type field: /** * @ORMTable() */ class MyEntity { (…) /** * @var array $items * * @ORMColumn( type=”array” ) */ private $…
Symfony 2 dynamically change form based on a selected value
I have the following table: EventType can have a few values i.e check-in, checkout, room rent, misc, etc. I want to make a form that will change the field type of “Value” to text, date, or entity based on the selected type in “EventType”. I tried to find some solutions but didn’t succeed. The only thing I found is that
Working with two entity managers in the same bundle in Symfony2
I’m trying to work with two entity managers for the same bundle. My configuration is like this: Is there any way to tell which entities belong to which entity manager? It crashes now if I want to work with a table which doesn’t belong to the default entity manager. UPDATE here is my configuration for the connection: Answer For using