symfony2: Problems after installing PUGXMultiUserBundle - symfony

I have installed PUGXMultiUserBundle for using multi-users in my symfony project (buyers and sellers). After installing PUGXMultiUserBundle, I create the abstract class and the 2 entities that inherit the abstract class (Seller,Buyer).
When I try to update the database by running the command:
php app/console doctrine:schema:update --force
I have the following errors:
[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
The service definition "fos_user.registration.form.factory" does not exist.
How do I fix this issue?

Related

generate initial migration after creating entity and repository for an existing database

After creating an Entity and Repository from an existing pre-doctrine database, I am unable to make an initial migration. It gave me this error [ERROR] The version "latest" couldn't be reached, there are no registered migrations. Any idea how to do an initial migration without starting fresh? And for some reason, the migration folder exists outside the src folder, why is it so? In a previous project, the migration folder exists inside the src folder.
Any insight would be appreciated. Thank you for reading.
EDIT: doctrine_migrations.yaml:
doctrine_migrations:
migrations_paths:
# namespace is arbitrary but should be different from App\Migrations
# as migrations classes should NOT be autoloaded
'DoctrineMigrations': '%kernel.project_dir%/migrations'
The commands I used to generate the Entity and its Repository is as follows:
php bin/console doctrine:mapping:import "App\Entity" annotation --path=src/Entity
modified the #ORM\Entity => #ORM\Entity(repositoryClass="App\Repository\UserRepository") in the entity .php
php bin/console make:entity --regenerate
Then when I run bin/console doctrine:migrations:migrate, the error pops up.
Work for me
doctrine_migrations:
migrations_paths:
'App\Migrations': '%kernel.project_dir%/src/Migrations'
and use for migration classes
namespace App\Migrations;
THis is my migrations config.You can test it :
doctrine_migrations:
dir_name: '%kernel.project_dir%/src/Migrations'
# namespace is arbitrary but should be different from App\Migrations
# as migrations classes should NOT be autoloaded
namespace: DoctrineMigrations
For migration commande i use : php bin/console d:m:diff and after this you can use the migration number with this commande :
php bin/console d:m:e --up the_migration_number
I tried most of the methods but it seems that it is possible to generate the migration. However, changes to the entity will not be detected by doctrine.
For example, if I change the field of name to username, php bin/console doctrine:migration:diff does not detect the changes.
What I found worked was exporting the database as .sql, creating the entity the normal way, and manually typing in the fields. Delete the generated table in phpmyadmin, and importing the data back in. Only then would it be working as I want it to be.

Symfony 4 production WebProfiler route

I try to change a Symfony 4.4 in production mode but after executing this command line from the documentation : APP_ENV=prod APP_DEBUG=0 php bin/console cache:clear
I get this error :
Bundle "WebProfilerBundle" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your App\Kernel.php file? in #WebProfilerBundle/Resources/config/routing/wdt.xml (which is being imported from "/home/admin/mercenaries/config/routes/dev/web_profiler.yaml")
The env is correct because the bundle is not loaded.
But how do I do for cancel this routes/dev repository to load ?

Cannot generate Entity from existing Oracle DB

Following symfony's documentation to create entities from exiting database,I get an error when running the first command:
php bin/console doctrine:mapping:import --force AppBundle yml
The error is:
[Symfony\Component\Debug\Exception\ContextErrorException]
Warning: file_put_contents(C:\WebApp\src\AppBundle/Resources/config/doctrine/"user".orm.yml): failed to open stream: Invalid argument
How can I fix it?
Looks like User is a reserved word within Oracle databases, so when I created the table, Oracle created a table named "user" with double quotes. So when trying to generate the entity, doctrine cannot find the table user and found an invalid argument "user" with double quotes in it. The way I solved the problem is by using another name other than user.
Hope this helps someone on the future.
php bin/console doctrine:mapping:import --force AppBundle yml
change to
php bin/console doctrine:mapping:import AppBundle yml --force
more details:
The doctrine:mapping:import command imports mapping information
from an existing database:
php app/console doctrine:mapping:import "MyCustomBundle" xml
You can also optionally specify which entity manager to import from with the
--em option:
php app/console doctrine:mapping:import "MyCustomBundle" xml --em=default
If you don't want to map every entity that can be found in the database, use the
--filter option. It will try to match the targeted mapped entity with the
provided pattern string.
php app/console doctrine:mapping:import "MyCustomBundle" xml --filter=MyMatchedEntity
Use the --force option, if you want to override existing mapping files:
php app/console doctrine:mapping:import "MyCustomBundle" xml --force

Symfoy2 Sonata page bundle

I am trying to install Page Bundle From Sonata Project with the help of their doc here : https://sonata-project.org/bundles/page/2-x/doc/reference/installation.html. For some reasons i cant install it because when i make this command php app/console sonata:easy-extends:generate SonataPageBundle i get this error Fatal error: Class 'Sonata\PageBundle\SonataPageBundle' not found in C:\www\SDIN\app\AppKernel.php on line 28
Thanks for your help

Create Entities from existing DB

Newest Version Symfony2 and using MAMP on a MAC. Following command:
php app/console doctrine:mapping:convert yml ./src/Acme/DemoBundle/Resources/config/doctrine/metadata/orm --from-database --force
My Error:
[Doctrine\DBAL\DBALException]
Unknown database type enum requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support it.
Don't have any idea. What is wrong?
A connection to my db is working. Because I tried to create a table and the output was that the table exist.
Sorry, I missed it and here is the solution of my question.
http://symfony.com/doc/current/cookbook/doctrine/dbal.html#registering-custom-mapping-types-in-the-schematool

Resources