I earlier tested Symfony’s web app on both local computer and target host in both environments: prod and dev – both worked fine. So I finished a mile stone on my local computer, still testing only on dev. Everything works fine. However – Doctrine seems to not working on prod now – and I don’t know why and how it stopped working.
Here’s what I see – this code (from DefaultController.php) is working on both, prod and dev:
$tags = $this->getDoctrine()
->getRepository("MyWebBundle:Tag");
But this (one line more) is working only on dev, but not prod:
$tags = $this->getDoctrine()
->getRepository("MyWebBundle:Tag")
->find(1);
In prod the last line causes “die” to the webpage. There’s no doubt that an error occured, but I have no any message in log, and of course in prod env Symfony is silent. I have no idea how to approach this problem… The most weird thing is that prod worked earlier properly.
UPDATED:
Ok, I traced the part of code which makes a difference of working and not working (but in prod, in dev always works). There are some relations in database (Tag Many-to-One to Category). Here is this part of code in Entity/Tag.php:
/**
* @ORM\ManyToOne(targetEntity="Category")
* @ORM\JoinColumn(name="id_category", referencedColumnName="id_category", nullable=true)
*/
protected $category;
It’s interesting that Symfony2 is not verbose about it…
When I delete it from Tag.php, my webapp works. If I re-type it into this file, it doesn’t…
UPDATED:
After further research I can see that actually all relations are problematical (in prod, not in dev). I wrote additional “artificial” (for test purposes) queries to database – in a fashion as above, and all give one of two effects:
When table is on top of hierarchical dependencies, everything works (let’s call it A type)
*When table has relations, Symfony just stop working without any message (let’s call it B type…*
I also tried to make a test with empty table and with fulfilled one. Two cases are following in “B-type” tables:
When empty, it works
*When data are stored (with relations), it doesn’t work*
In your
app.phpchangeto
This will boot your application with prod environment and with enabled debugging