{"id":1556,"date":"2022-08-30T15:17:31","date_gmt":"2022-08-30T15:17:31","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/27\/problem-about-symfony-2-3-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:17:31","modified_gmt":"2022-08-30T15:17:31","slug":"problem-about-symfony-2-3-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/problem-about-symfony-2-3-collection-of-common-programming-errors\/","title":{"rendered":"problem about symfony-2.3-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b6b0ca5d4ef200ec8e3cd1fa2aefd836?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nzerkms<br \/>\nphp symfony2 symfony-2.3<br \/>\nDisclaimer:seems like you guys need some real world example for that. So here it is:file_get_contents($filename);Keep in mind about thread safety and race conditions.or any other php notice\/warning or any kind of recoverable exception.where either is not defined. And run it in the default app.php with all the default symfony v2.3.5 configs &#8211; I seeNotice: Undefined variable: i in \/var\/www\/&#8230;\/UIBundle\/Controller\/DeployController.php on line 57Call Stack:0.0000 629696 1. {main}() \/var\/www\/..<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/loshM.png?s=32&amp;g=1\" \/><br \/>\nbenatespina<br \/>\ntwig symfony-2.3<br \/>\nI&#8217;m using Symfony 2.3.4 and I have a big bug that I cannot fix. I have tried:composer update -o app\/console cache:clear &#8211;env=prodand the file exists:vendor\/twig\/twig\/lib\/Twig\/Extension\/Escaper.php Still the bug.Here the error:[Wed Oct 16 11:44:21 2013] [warn] [client 85.93.195.236] mod_fcgid: stderr: PHP Fatal error: Uncaught exception &#8216;InvalidArgumentException&#8217; with message &#8216;Unable to load class &#8220;Twig_Extension_Escaper&#8221;&#8216; in ..\/vendor\/symfony\/symfony\/src\/Symfony\/Component\/ClassLoader\/ClassColl<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/GPPPT.gif?s=32&amp;g=1\" \/><br \/>\nartworkad ?<br \/>\nsymfony2 fosuserbundle jmsserializerbundle symfony-2.3<br \/>\nBasically I want to deserialize json to user object. Like this$serializer = $this-&gt;get(&#8216;jms_serializer&#8217;);$data = $serializer-&gt;deserialize($this-&gt;get(&#8216;request&#8217;)-&gt;getContent(),&#8217;My\\FooBundle\\Entity\\User&#8217;, &#8216;json&#8217;);The request data passed to deserializer:{&#8220;id&#8221;:2,&#8221;username&#8221;:&#8221;&#8230;@gmail.com&#8221;,&#8221;username_canonical&#8221;:&#8221;&#8230;@gmail.com&#8221;, &#8230; }Thrown error:request.CRITICAL: Uncaught PHP ExceptionJMS\\Serializer\\Exception\\RuntimeException: &#8220;You must define a type forFOS\\UserBundle\\Model\\User::$username.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8e0b37b1d256d30a69b77ea15811d229?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nradke<br \/>\nphp symfony2 http-status-code-404 symfony-2.3<br \/>\nAccording to symfony2 documentation NotFoundHttpException should be caught by the framework and ultimately trigger a 404 response, but I&#8217;m just getting fatal error (Uncaught exception) with status 200 on prod environment. On dev environment I got 404. I&#8217;m using this:throw $this-&gt;createNotFoundException();I just want to display my customized 404 page. I&#8217;ve cleared cache but it hasn&#8217;t helped. Am I doing something wrong?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/gSApx.jpg?s=32&amp;g=1\" \/><br \/>\nkeepitdk<br \/>\nsymfony2 doctrine2 symfony-2.2 fosrestbundle symfony-2.3<br \/>\nBuilt an API using Symfony2, FOSRest and Doctrine. Given the following route:&#8221;GET \/api\/path\/to\/product&#8221;And the following parameters:[(&#8220;vendorID&#8221;, 10), (&#8220;destination&#8221;, &#8220;tanzania&#8221;), (&#8220;type&#8221;, &#8220;accommodation&#8221;), (&#8220;sort&#8221;, &#8220;price&#8221;, &#8220;ASC&#8221;)]Using FOSRest bundle its possible to retrieve these strings, however, mapping them to doctrine queries is where the challenge arises.I thought about using numerous case statements customised for the different combinations of query strings, not an elegant solution. Wou<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/213f2a1135365443836698cbbda69608?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBonswouar<br \/>\nscope block twig symfony-2.3<br \/>\nI&#8217;m trying to customize a specific widget, like in the documentation : http:\/\/symfony.com\/doc\/current\/cookbook\/form\/form_customization.html#how-to-customize-an-individual-fieldThe problem is that in this custom block, I need to use a variable from my actual template. I thought &#8220;blocks have access to variables from outer scopes&#8221;, but apparently not in this case :{% extends &#8220;CDASvBundle::layout.html.twig&#8221; %} {% block _contact_activity1_widget %} &lt;select name=&#8221;contact[activity1]&#8221;&gt;{% for key,<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/247db738ce13f6fbcb0a6ce725eb79cb?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nTrololololol<br \/>\nphp symfony2 doctrine2 symfony-2.3<br \/>\nI have 2 Entities\/*** @ORM\\Entity(repositoryClass=&#8221;FLI\\ContractBundle\\Repository\\CarrierFuelRepository&#8221;)* @ORM\\Table(name=&#8221;carrier_fuel&#8221;)*\/ class CarrierFuel {\/*** @ORM\\Column(name=&#8221;id&#8221;, type=&#8221;integer&#8221;, nullable=false)* @ORM\\Id* @ORM\\GeneratedValue(strategy=&#8221;AUTO&#8221;)*\/protected $id;\/*** @ORM\\Column(type=&#8221;string&#8221;)*\/protected $title;\/*** @ORM\\ManyToOne(targetEntity=&#8221;FuelIndex&#8221;)*\/protected $index;\/*** @ORM\\OneToMany(targetEntity=&#8221;FuelLine&#8221;, mappedBy=&#8221;carrier_fuel&#8221;, cascade={&#8220;persist&#8221;, &#8220;remove&#8221;})*\/pr<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/cb791c8f12e687d3538677321cdc8d2a?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDaniel<br \/>\nphp symfony2 error-handling symfony-2.3<br \/>\nSince I updated my project to Symfony 2.3 php notices don&#8217;t throw exceptions any more.I can try to access undefined indexes in arrays and a notice is displayed but no exception is thrown.At first I tought I was confused and maybe this had been the behavior on prvious version. I found some question on stackoverflow that suggest otherwise.how to handle PHP notice in symfony2Is there anyway to make Symfony 2.3 throw exceptions on symfony2 notices?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/aee3b44e5f0b4dfa0e2da672897b3751?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nj0k<br \/>\nsymfony2 fosrestbundle symfony-2.3<br \/>\nI am trying to follow the tutorial ## but am running into an issue. I am receiving the following exception:Call to undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeBuilder::fixXmlConfig() in DIR\\vendor\\jms\\serializer-bundle\\JMS\\SerializerBundle\\DependencyInjection\\Configuration.php line 46Does anyone know what is going on?I have enabled both required bundles:new JMS\\SerializerBundle\\JMSSerializerBundle($this), new FOS\\RestBundle\\FOSRestBundle(),I&#8217;m guessing that one of the bundle<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/GCbQR.png?s=32&amp;g=1\" \/><br \/>\nReynier<br \/>\nsymfony2 symfony-forms symfony-2.3<br \/>\nI need to create a deleteForm in my view so I do this:\/*** Show created bank account** @Route(&#8220;\/{account_id}&#8221;, name=&#8221;wba_show&#8221;)* @Method(&#8220;GET&#8221;)*\/ public function showAction($account_id) {$em = $this-&gt;getDoctrine()-&gt;getManager();$entity = $em-&gt;getRepository(&#8216;BankBundle:Account&#8217;)-&gt;find($account_id);if (!$entity) {throw $this-&gt;createNotFoundException(&#8216;Unable to find Account entity.&#8217;);}$deleteForm = $this-&gt;createDeleteForm($account_id);return array(&#8216;entity&#8217; =&gt; $entity, &#8216;delete_f<\/li>\n<\/ul>\n<p id=\"rop\"><small>Originally posted 2013-11-27 05:10:57. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>zerkms php symfony2 symfony-2.3 Disclaimer:seems like you guys need some real world example for that. So here it is:file_get_contents($filename);Keep in mind about thread safety and race conditions.or any other php notice\/warning or any kind of recoverable exception.where either is not defined. And run it in the default app.php with all the default symfony v2.3.5 configs [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1556","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1556","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1556"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1556\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1556"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1556"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1556"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}