Reading these docs:
Doctrine DBAL Configuration with Symfony
Doctrine ORM Configuration with Symfony
Doctrine Configuration with Symfony
I created this and added to /src/MyBundle/Resources/config/services.php of my generated bundle:
My Configuration code
But I get the error:
[Symfony\Component\DependencyInjection\Exception\LogicException]
Container extension "doctrine" is not registered
What more I missed to do? I probably have to add that I did NOT remove the default orm/dbal settings in /app/config/config.yml.
Also I have no idea what 'read' and what 'host'=>'from_user_config.db' is, I copied/pasted from a third-party application and how to inject db credentials from a separate file into this services.php?
Related
Is there a way to disable Doctrine MongoDB bundle logger on fixture load only? like suggested in https://stackoverflow.com/a/35222045/3965970 but for MongoDB bundle.
Thanks
Yes, absolutely the same way, call
$manager->getConnection()->getConfiguration()->setLoggerCallable(null); right in the fixture.
Unfortunately in Doctrine MongoODM-bundle version 4.0 and higher this approach no longer works.
The easiest way is to disable logging in the configuration, see https://symfony.com/doc/master/bundles/DoctrineMongoDBBundle/config.html
You can also disable the logger manually, but you'll need doctrine_mongodb.odm.command_logger service.
What I did in my Symfony 4 application is to create an alias to enable proper dependency injection and then unregister the listener:
services.yaml
Doctrine\Bundle\MongoDBBundle\APM\PSRCommandLogger:
alias: "doctrine_mongodb.odm.command_logger"
some constructor of a Command or Service:
public function __construct(PSRCommandLogger $mongoLogger)
{
$mongoLogger->unregister();
}
I am trying to configure translatable extension in my own project. The problem is that I have a whole bundle configured using yaml for mapping entities, so each entity have its own .orm.yml file. Now, I am trying to add the translatable extension but when I run the schema update command I get:
No identifier/primary key specified for Entity "Ruck\SportsBundle\Entity\Tr anslation\SportTranslation" sub class of "Sonata\TranslationBundle\Model\Ge dmo\AbstractPersonalTranslation". Every Entity must have an identifier/prim ary key.
In other bundle where I have used annotations it works fine... So my question is if translatable extension is incompatible with yaml files.
I have reading about this issue
https://github.com/Atlantic18/DoctrineExtensions/issues/671
https://github.com/Atlantic18/DoctrineExtensions/issues/989
but I think is too strange that I can't use yml files with translatable extension...
Thanks
I've got a test bundle which has some doctrine entities. In AppKernel I added this bundle only to the dev and test environments and also made the mapping definitions for doctrine in the config.yml. The problem is in prod environment doctrine can't find the entities as the bundle isn't loaded in kernel. I don't want to load the test bundle in prod env.
I also have other entities defined in different bundles for doctrine so I'd switch the test bundle off in the config_prod.yml or set it to null - is it possible somehow? I don't want to copy and redefine the whole mappings array/list in config_prod.yml.
I am migrating from symfony1 to symfony2, I have hard time implementing propel behaviors. Where do I actually have the propel.ini in symfony2?
Well in sf1.4, it was inside root config directory. How about symfony2?
The Propel ORM Symfony2 page says this:
You can add a app/config/propel.ini file in your project to specify some configuration parameters. ... However, the recommended way to configure Propel is to rely on build properties.
You can define build properties by creating a propel.ini file in app/config like below, but you can also follow the Symfony2 convention by adding build properties in app/config/config.yml
So I believe you can come close to the Symfony1 behaviour by creating app/config/propel.ini, but the more idiomatic way is to use app/config/config.yml as that page illustrates.
Caveat: I haven't used Propel with Symfony2, so this answer is solely based on the manual.
I create project from Symfony 2, but I have a problem:
In project have multi-bundles(ex: AdminBundle and FontEndBundle)
Case 1: Doctrine orm and Entities generate on FrontEndBundle, then from AdminBundle, I will call Entity via FrontEndBundle:Object it work OK.
Case 2: I want to config structure folow
src/Project/
Model/Entity
OrmYml/doctrine/orm
Bundles(contains FontEndBundle & AdminBundle)
Extensions
In case 2, How do I config Entity mapping to generate Entities to src/Model/Entity directory ? Because when I using Command: doctrine:generate:entities Project/Model/Entity,
error : Namespace "Project\Model\Entity" does not contain any mapped
entities.
How do you declare your entities ?You should put your entities within a bundle. You cant have them outside a bundle .
Usually, Symfony developpers create a third bundle called "CoreBundle" (for example) where you place all the shared resource between your three bundles, namely the entities, some services (like twig extensions), config (with service.xml/yml), ... Also, you can delete the controller and views directories in this bundles, which are useless (don't forget to clean the app/config/routing.yml file by removing the CoreBundle controller injection) !
Then just call your entities in the right bundle with:
use MyName\Bundle\CoreBundle\Entity\MyEntity;
Never create a model repertory not in a bundle, this is not the Symfony philosophy and you are really wrong !