symfony

Unable to read environment variables

有些话、适合烂在心里 提交于 2021-02-05 07:09:49
问题 I have a simple Symfony project, using "symfony/dotenv": "4.3.*", in the composer.json and trying to read in the value of an environment variable. This is my command: var_dump($_ENV['MY_NEW_VAR']); This is my .env file MY_NEW_VAR=testing Upon executing the command I get the following string(7) "testing" All good so far.... But now if I want to use environment variables to override the setting it returns an error. First I set the environment variable export MY_NEW_VAR="something_else" Then

Unable to read environment variables

徘徊边缘 提交于 2021-02-05 07:06:24
问题 I have a simple Symfony project, using "symfony/dotenv": "4.3.*", in the composer.json and trying to read in the value of an environment variable. This is my command: var_dump($_ENV['MY_NEW_VAR']); This is my .env file MY_NEW_VAR=testing Upon executing the command I get the following string(7) "testing" All good so far.... But now if I want to use environment variables to override the setting it returns an error. First I set the environment variable export MY_NEW_VAR="something_else" Then

How to stipulate a range of years using the date field type in doctrine2

て烟熏妆下的殇ゞ 提交于 2021-02-05 06:47:45
问题 I need a date drop down in a Symfony2 site form, and am using the 'date' field type in my form builder. Here is my declaration: $builder->add('date', 'date', array( 'label' => 'Date', 'format' => 'dd MM yyyy', 'required' => true )); By default this will display 5 years in the past and 5 years in the future (i.e. 2010 - 2020) but I need it to start from this year and only show a couple of years in the future, as for this particular form there is no need for a past date or a date too far in the

twig dynamic variable call

不想你离开。 提交于 2021-02-05 05:31:18
问题 I passed data in 3 languages to the twig template and display this data in this way: {% set lang=app.request.get("lang")%} {% for item in contests%} {% if lang=="fa"%} {{item.titlefa}} {% elseif lang=="en"%} {{item.titleen}} {% elseif lang=="ar"%} {{item.titlear}} {% endif%} {% endfor%} It is wirking but I must create 3 if condition for each object in "contests" How can i show data in this logic: {% set lang=app.request.get("lang")%} {{item.title~lang}} {% endfor%} that can call proper method

twig dynamic variable call

无人久伴 提交于 2021-02-05 05:29:11
问题 I passed data in 3 languages to the twig template and display this data in this way: {% set lang=app.request.get("lang")%} {% for item in contests%} {% if lang=="fa"%} {{item.titlefa}} {% elseif lang=="en"%} {{item.titleen}} {% elseif lang=="ar"%} {{item.titlear}} {% endif%} {% endfor%} It is wirking but I must create 3 if condition for each object in "contests" How can i show data in this logic: {% set lang=app.request.get("lang")%} {{item.title~lang}} {% endfor%} that can call proper method

'Circular reference has been detected' error when serializing many-to-many-associated objects

岁酱吖の 提交于 2021-02-04 17:59:10
问题 Since upgrading to Symfony 2.7, I seem to keep getting 'circular reference has been detected' errors when attempting to serialize an array of contacts associated with a given group. They're setup in a many-to-many association (one group has many contacts; one contact has many group-associations). Now, I followed the guide for using serialization groups as per the 2.7 upgrade post, but still seem to get the error. My controller code for this is currently as follows: $group = $this->getDoctrine

Serialization of UploadedFile is not allowed

我的未来我决定 提交于 2021-02-04 16:42:05
问题 I'm trying to upload a file via vichuploader bundle on my Users entity. Using hwioauthbundle that implements UserInterface, and i think the errors comes from that bundle... So every time i try to uplod a file i got this exception : Serialization of 'Symfony\Component\HttpFoundation\File\UploadedFile' is not allowed I already tried this solution but also same exception. namespace AppBundle\Entity; use Doctrine\ORM\Mapping as ORM; use HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface;

How to delete rows from join-table (ManyToMany) in Doctrine?

老子叫甜甜 提交于 2021-02-04 14:23:58
问题 I have a join-table which is created by using @ORM\ManyToMany annotation in Symfony2/Doctrine. It joins Category and Parameter table. Now I want to delete all parameters from the Parameter table. Because there are foreign key constraints defined on join-table I can't just delete rows from Parameter table. First I have to delete child rows from join-table. But Dotrine's DQL syntax require to give a name of the entity, like: DELETE Project\Entity\EntityName But what is the name of the join

How to delete rows from join-table (ManyToMany) in Doctrine?

走远了吗. 提交于 2021-02-04 14:23:26
问题 I have a join-table which is created by using @ORM\ManyToMany annotation in Symfony2/Doctrine. It joins Category and Parameter table. Now I want to delete all parameters from the Parameter table. Because there are foreign key constraints defined on join-table I can't just delete rows from Parameter table. First I have to delete child rows from join-table. But Dotrine's DQL syntax require to give a name of the entity, like: DELETE Project\Entity\EntityName But what is the name of the join

How to write custom endpoints with parameters not related to any specific entity

旧时模样 提交于 2021-02-03 21:32:42
问题 I'm trying to write custom GET endpoints, which must have one or more custom parameters, but not built on top of specific entity. Something like: /assets/{device_id}/{scene_id}/{maybe_other_param} which I imagine to be just own controller class, in which I do something, calculate values from input, read some data manually and return array of entities. What I only get is an Asset entity, but it requires {device} and {scene} to be properties of this entity... I don't want this to work as