symfony-2.1
Troubleshooting “require_once(../bootstrap.php.cache): failed to open stream: No such file or directory”
Just go to your project and generate it with composer like php /path/to/composer/composer.phar install
How can i simulate a 404 error with Symfony2? [duplicate]
You can find the solution in the Symfony2 documentation: http://symfony.com/doc/2.0/book/controller.html Managing Errors and 404 Pages public function indexAction() { // retrieve the object from database $product = …; if (!$product) { throw $this->createNotFoundException(‘The product does not exist’); } return $this->render(…); } There is a short information in the documentation: “The createNotFoundException() method creates a special … Read more
How to create a good hypermedia format using JMSSerializerBundle?
The Serializer Bundle alone might not be enough for this situation as it is only concerned with serialization and deserialization, not more complex semantical tasks. I would suggest looking into FSCHateoasBundle to implement a pretty hypermedia format for your API.
How do I force doctrine to reload the data from the database?
Have you flushed your changes to the $audit object? $audit = $dm->getRepository(“WGenSimschoolsBundle:Audit”)->findOneById(“xxxx”); //do something somewhere to change the object $dm->flush(); Every time you do a findBy(…) or findOneBy(…) it actually fetches a new document from the DB. (you should see the query in the Symfony profiler) With a find() instead, it will fetch the document … Read more
Set default value on Datetime field in symfony2 form
Set it in the entity constructor: class Entity { /** * @var \DateTime */ private $date; public function __construct() { $this->date = new \DateTime(); } }
Deep clone Doctrine entity with related entities
You have to implement a __clone() method in your entities that sets the id to null and clones the relations if desired. Because if you keep the id in the related object it assumes that your new entity A has a relation to the existing entities B and C. Clone-method for A: public function __clone() … Read more
How to get list of all routes of a controller in Symfony2?
What you can do is use the cmd with (up to SF2.6) php app/console router:debug With SF 2.7 the command is php app/console debug:router With SF 3.0 the command is php bin/console debug:router which shows you all routes. If you define a prefix per controller (which I recommend) you could for example use php app/console … Read more
Too much data with var_dump in symfony2 doctrine2
Replace var_dump() with the debug method dump() provided by Doctrine Common. \Doctrine\Common\Util\Debug::dump($user); It works for single objects and Doctrine collections and should prevent browser displaying issues you are having.