PHPStan is a tool that allows for automatic static analysis of the source code. The tool is very easy to install and configure: just select the application directory that you want to analyze, indicate the level of analysis of the code to be executed and after a while we get a detailed report on potential […]
PHP
Translating Doctrine Entities with Symfony forms
As described here I’m using KnpLabs\DoctrineBehaviors for Doctrine2 entity translations. While using this bundle we have nice interface for translations but usually we also need some UI (forms) for managing such translations from user interface. We can always write our own dedicated solution but there is already a nice bundle that will do the job […]
Working with Symfony and Doctrine entities translations
As you know there is no built-in feature in Doctrine2 for translating entities. If you need entities translation you can choose one of several already existing bundles or create the new one. As there is no “the right” way of working with Doctrine2 translations I just want to share my experience. DoctrineExtensions: translatable I don’t […]
Doctrine2 entity changeset for relations
Doctrine2 offers very powerful API for getting entity properties that have changed. This can be achieved using Doctrine\ORM\UnitOfWork. We can call: Doctrine\ORM\UnitOfWork::computeChangeSets() to compute all the changes that have been done to entities and collections and store these changes; Doctrine\ORM\UnitOfWork::getEntityChangeSet($entity) to retrieve all changes to our entity object; Doctrine\ORM\UnitOfWork::getOriginalEntityData($entity) to retrieve the original data of […]
Ignore entity or table when running Doctrine2 schema update command
Recently I came accross a problem with entity that was mapped to view in database. In such scenario calling doctrine:schema:update command was producing errors. I know that we can create custom schema based command tool but I think that my solution is easier and more efficient. The solution is using Doctrine2: postGenerateSchema event listener – […]