-2

I have a problem with Symfony 4, I want generate entities from an existing database with the command :

php bin/console doctrine:mapping:import --force AppBundle xml

But an error appears :

Bundle "AppBundle" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your App\Kernel.php file?

I try to import in the file kernel.php in registerBundles() :

new AppBundle/AppBundle();

but undefined class and when I create it in src/AppBundle/AppBundle.php :

<?php namespace AppBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; class AppBundle extends Bundle { }

nothing change and when I retry the command :

PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "AppBundle" from namespace "App". Did you forget a "use" statement for another namespace? in /var/www/html/symfony/Mission3/src/Kernel.php:30

I would like to know if it's possible to create a bundle like that or if it exists an other command to generate entities from an existing database.

  • 1
    What are you asking? What have you tried? Did you check whether `you forgot to add [AppBundle] in the registerBundles() method of your App\Kernel.php file?` If you want an answer, you need to provide a specific question and enough information about your problem for people to help you. – divibisan Mar 26 '18 at 19:17
  • Do you understand your question when you read what you wrote? We neither ;). Follow the @divibisan advise – Dayron Gallardo Mar 26 '18 at 21:24

2 Answers2

1

in SF4, The main application component is named 'App' by default and is not a bundle. You have to manually create a dummy bundle under src\ directory in order to use old doctrine:command related to bundle. see how to manually create a bundle here

After that, you can import/generate mappings/entities using doctrine:commands and use them in the App main module space, or in those bundles.

The SF4 maker tool don't provide bundle creation yet ... But I suppose the SF4 developers consider it's not an urge must have requirement, because they want us to focus on putting most code in the bundle less App main module.

kasor
  • 179
  • 1
  • 5
0

In symfony 4 'AppBundle' is doesn't exist anymore. Try use 'App' instead 'AppBundle'

Arnold Richmon
  • 321
  • 3
  • 8