I've a weird problem with propel.
My configuration in config.yml:
propel:
dbal:
driver: %database_driver%
user: %database_user%
password: %database_password%
dsn: %database_driver%:host=%database_host%;dbname=%database_name%;charset=UTF8
path: %kernel.root_dir%/../vendor/propel
phing_path: %kernel.root_dir%/../vendor/phing
I created my database with that command: php app/console propel:database:create and it worked very well but when I'm trying to create my first table with php app/console propel:model:build i've a fatal error telling: PHP Fatal error: Class 'Phing' not found.
I verified in the folder, everything is there. I guess that is an autoloading problem but I've followed the documentation at http://www.propelorm.org/cookbook/symfony2/working-with-symfony2.html and http://symfony.com/doc/master/book/propel.html
Any idea? Thanks a lot!
Which dependencies management system do you use?
This is an autoloading issue, and you should add the following definition:
$loader->registerPrefixes(array(
...
'Phing' => __DIR__.'/../path/to/phing/classes/phing',
));
where path/to/phing is the path where you installed Phing.
Related
Hello, i need to explain what i'm was doing at first:
I was on a project and for some reason I ended up having to use two databases instead of just one. so i do what it was needed to do, i change my doctrine.yaml settings with what is explain in the symfony doc and in that moment the error appeared
An SQL error that says that it was no column found for X request on X table
(the error is SQLSTATE[42S02], but it's not important)
(in parallel of that error i need to say that the "--em" shit didn't work for me when i do php bin/console doctrine:migrations:diff/migrate --em=default or customer so i does indeed php bin/console doctrine:schema:update --force --em=default or customer and i don't know why ! so if you have something to say here i'll take it too.)
Anyway i go back to what i was explaining,
This sql error appear because of my controller, they working with default Repository implementation (MyClassNameRepository $myClasNameReposiotry for an exemple) that was normaly implement the default EntityManager but it doesn't and that throw this error.
At this point i though that i had an error in some files in symfony because of a shit i probably does. I don't have the time for replacing all the repository implementation, soo i create a new project with the doctrine config that is needed for working with two database according to the symfony doc. Is the same as the One in my project :
doctrine:
dbal:
default_connection: default
connections:
default:
# configure these for your database server
url: '%env(resolve:DATABASE_URL)%'
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
customer:
# configure these for your database server
url: '%env(resolve:DATABASE_CUSTOMER_URL)%'
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
orm:
entity_managers:
default:
connection: default
mappings:
Main:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: Main
customer:
connection: customer
mappings:
Customer:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity/Customer'
prefix: 'App\Entity\Customer'
alias: Customer
That is the same config than the one in symfony doc except for the Main dir.
i created my entities, one in each database and i does a crud on them.
The Hierarchy files:
src/
-----Entity/
----Product
----Customer/
-ProductCustomer
-----Repository/
----ProductRepository
----Customer/
-----ProductCustomerRepository
And same for the form
And with this testApplication i saw a new error, for the customer part i had the same sql error, because the column was searched in the wrong bdd, after changing the code for :
this
/**
* #Route("/", name="customer_produit_customer_index", methods={"GET"})
*/
public function index(ProductCustomerRepository $productCustomerRepository): Response
{
return $this->render('customer/produit_customer/index.html.twig', [
'produit_customers' => $productCustomerRepository->findAll(),
]);
}
to this
/**
* #Route("/", name="customer_produit_customer_index", methods={"GET"})
*/
public function index(): Response
{
$productCustomers = $this->getDoctrine()
->getRepository(ProduitCustomerRepository::class, "customer")
->findAll()
;
return $this->render('customer/produit_customer/index.html.twig', [
'produit_customers' => $productCustomers,
]);
}
The error has changed, as I expected and know i have :
The class 'App\Repository\Customer\ProduitCustomerRepository' was not found in the chain configured namespaces App\Entity\Customer
No matter how much I search the internet, I can't find anything that really solves my mistakes. Now I'm tired of looking, especially since I don't understand these errors because it's not the first time I've set up an application connected to two databases, but it's the first time that I have these errors.
So please help me =D.
I'm trying to make migrations based on a diff of my entities.
I'm expecting for the initial run (and following runs) that doctrine generates a migration with the diff.
I've tried the following solution but this results in "No changes detected in your mapping information."
I've poked and went thru the doctrine migrations source code to see if I can extend/alter the behavior to no results.
I also found related issues in doctine dbal like this one and this one.
Is doctrine migrations still the way or is there another lib which is better suited for this problem?
I'm running PHP 7.4.4, Symfony 5.0.6, Doctrine Migrations 2.2.6 (latest stable), Postgres 12.1.
Doctrine config:
doctrine:
dbal:
driver: 'pdo_pgsql'
server_version: '12.1'
charset: utf8
url: '%env(resolve:DATABASE_URL)%'
dbname: storage001
default_dbname: storage001
Entity example:
/**
* #ORM\Table(schema="storage001", name="entityName")
*/
class EntityClass1
{
...
}
I´m trying to make working doctrine2 extensions but it still wrotes me this error:
Fatal error: Class 'Gedmo\Tree\TreeListener' not found in /data/web/virtuals/48565/virtual/www/domains/kozusnikjan.com/Symfony/app/cache/prod/appProdDebugProjectContainer.php on line 1377
And I don´t know, how to solve the problem. Please, help. Here are some files:
http://pastebin.com/k9rqvGQn -- config.yml
http://pastebin.com/TvxbvEyS -- doctrine-extensions.yml
http://pastebin.com/prUFmrTb -- AppKernel.php
http://pastebin.com/0zAaHwW9 -- DoctrineExtensionListener.php
Thank you very much
Edit:
New files:
http://pastebin.com/qEAZtFba -- composer.json
http://pastebin.com/aBnvrZj9 -- config.yml
http://pastebin.com/E1aSSddm -- appKernel.php
I edited this files. I didn´t create any file. Thank you for your help!
You're using Gedmo directly. Try through StofDoctrineExtensionsBundle...
If you are using composer add to your composer.json at require section
"stof/doctrine-extensions-bundle": "1.1.*#dev"
and run composer update. You must load bundle on AppKernel.
then put on your config.yml
stof_doctrine_extensions:
default_locale: %locale%
orm:
default:
tree: true
May be you wanna find your problem, but I use Gedmo this way and works fine.
I know it's an old Problem, but I had this one too today. Solved it by declaring the tree listener as a service:
https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/symfony2.md#doctrine-extension-listener-services
It's the same for every Gedmo extension such as translatable, sluggable, timestampable...
Ok I have one last problem with doctrine:generate:entities command
I run the below command and I get the expected file(s) in
/src/MyNamespace/Bundle/MyNamespaceBundle/Resources/config/doctrine/metadata/orm
comamnd:
php app/console doctrine:mapping:convert yml ./src/MyNamespace/Bundle/MyNamespaceBundle/Resources/config/doctrine/metadata/orm --from-database --em=my_manager --filter=TblReports --verbose
I see the TblReports.orm.yml file(s) and the first line is:
TblReports
command: ( should this be annotation instead of yml? )
php app/console doctrine:mapping:import MyNamespaceBundle yml --em=my_manager --filter=TblReports
I run the above command I get the files here
/src/MyNamespace/Bundle/MyNamespaceBundle/Resources/config/doctrine/
Same name as the first files that were generated from the first command, just in a different location and the first line ( Which I'm assuming is the namespace )
TblReports.orm.yml
and now the first line is:
MyNamespace\Bundle\MyNamespaceBundle\Entity\TblReports
but I think it needs to be
MyNamespace\Bundle\MyNamespaceBundle\Entity\Reports\TblReports
Now I run the last command
php app/console doctrine:generate:entities MyNamespaceBundle --path=src --no-backup
I get this error
[RuntimeException]
Bundle "MyNamespaceBundle" does not contain any mapped entities.
If I run the command like this
php app/console doctrine:generate:entities MyNamespaceBundle:Reports --path=src --no-backup
I get this error ( but the namespace looks correct )
[RuntimeException]
Namespace "MyNamespace\Bundle\MyNamespaceBundle\Entity\Reports" does not contain any mapped entities.
Here is my_manager ( config.yml )
# Doctrine Configuration
doctrine:
dbal:
default_connection: my_database
connections:
my_database:
driver: pdo_pgsql
port: 5432
dbname: tbl_reports
user: foo_user
password: foo_pass
charset: UTF8
mapping_types:
bit: string
orm:
auto_generate_proxy_classes: "%kernel.debug%"
default_entity_manager: my_manager
entity_managers:
my_manager:
connection: my_database
mappings:
MyNamespaceBundle:
mapping: true
dir: Entity/Reports
in config_dev.yml ( I use the dev and prod yml files to control the host(s) I can connect to )
# Doctrine Configuration
doctrine:
dbal:
connections:
my_database:
host: 172.0.0.1
Questions:
Why am I getting this error?
How can I fix it?
Related Questions:
Generate Entities with Doctrine into separate namespace
Entity Generation for Single Table
UPDATE #1:
Ok well I ran the second command as annotation instead of yml and the files were generated in:
MyNamespace\Bundle\MyNamespaceBundle\Entity
command:
php app/console doctrine:mapping:import MyNamespaceBundle annotation --em=my_manager --filter=TblReports
I ran the doctrine:generate:entities ( both ways ) and still got errors. I decided to move the files into this directory
MyNamespace\Bundle\MyNamespaceBundle\Entity\Reports
I ran the doctrine:generate:entities agin ( both ways ) and still got errors.
I looked at the namespace in the files and saw it was pointing to the work namespace. I updated from:
MyNamespace\Bundle\MyNamespaceBundle\Entity\TblReports
to
MyNamespace\Bundle\MyNamespaceBundle\Entity\Reports\TblReports
ran this command
php app/console doctrine:generate:entities MyNamespaceBundle:Reports --path=src --no-backup
and in now works
Generating entities for namespace "MyNamespace\Bundle\MyNamespaceBundle\Entity\Reports"
So I guess question #3 is:
How can I get the second command to add the correct namespace on the import?
I tried this but no dice
php app/console doctrine:mapping:import MyNamespaceBundle:Reports annotation --em=my_manager --filter=TblReports
Docs:
http://symfony.com/doc/master/reference/configuration/doctrine.html
Source:
https://github.com/doctrine/DoctrineBundle/blob/master/Command/ImportMappingDoctrineCommand.php
https://github.com/doctrine/DoctrineBundle/blob/master/Command/GenerateEntitiesDoctrineCommand.php
Your first line needs to end with a : as in:
MyNamespace\Bundle\MyNamespaceBundle\Entity\TblReports:
<yml> data.
You seem to be mixing annotations with yml. Pick one and stick with it. I don't use annotations, so the rest is yml comments. doctrine:mapping:import/convert with yml option generates yml files puts the yml files in Bundle/Resources/config/doctrine.
The collection of yml files are then used to make your entity classes, and it will put them in the location specified in each yml file, which be default is NamespaceBundle\Entity.
I don't know why show this error "[InvalidArgumentException] Driver "ORM" is unsupported for this extension" after Sylius Assortment Bundle installation with this documentation http://sylius.readthedocs.org/en/latest/bundles/SyliusAssortmentBundle.html
After adding these line In config.yml shows me error:
sylius_assortment:
driver: ORM
classes:
model:
product: Application\Bundle\AssortmentBundle\Entity\Product
Please any one suggest me What i am doing wrong..
The driver name has changed to doctrine/orm instead of just ORM. The documentation is out dated. I have fixed it and added a pull request. It should get updated soon.
With YAML (the config format) you must preserve the indenting
so indent the body of sylius_assortment with spaces:
sylius_assortment:
driver: ORM
classes:
model:
product: Application\Bundle\AssortmentBundle\Entity\Product
I solved it.I just add this code.Then it worked.
sylius_assortment:
driver: doctrine/orm
classes:
model:
product: Application\Bundle\AssortmentBundle\Entity\Product