symfony / maker-bundle

Symfony Maker Bundle
https://symfony.com/
MIT License
3.36k stars 404 forks source link

make:entity argument name #555

Open Mynyx opened 4 years ago

Mynyx commented 4 years ago

The command help make:entity shows the argument name of make:entity, which would be the Class name of the entity to create or update.

If using the command (e. g. make:entity --regenerate VictoriousGnome) the error message is No entities were found in the "VictoriousGnome" namespace.

But according to help, the argument name should be the clase name and not a namespace. The help and the error message appear inconsistent.

$ php bin/console help make:entity
Usage:
  make:entity [options] [--] [<name>]

Arguments:
  name                  Class name of the entity to create or update (e.g. VictoriousGnome)

Options:
  -a, --api-resource    Mark this class as an API Platform resource (expose a CRUD API for it)
      --regenerate      Instead of adding new fields, simply generate the methods (e.g. getter/setter) for existing fields
      --overwrite       Overwrite any existing getter/setter methods
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -e, --env=ENV         The Environment name. [default: "dev"]
      --no-debug        Switches off debug mode.
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

[...]
$ php bin/console make:entity --regenerate VictoriousGnome

 ! [NOTE] It looks like your app may be using a namespace other than "AppBundle".
 !
 !        To configure this and make your life easier, see:
 !        https://symfony.com/doc/current/bundles/SymfonyMakerBundle/index.html#configuration

 [ERROR] No entities were found in the "VictoriousGnome" namespace.
tacman commented 4 years ago

Here's a transcript showing the problem. In short, regenerate ONLY works with the full class name.

bin/console make:entity Foo -n

 created: src/Entity/Foo.php
 created: src/Repository/FooRepository.php

 Next: When you're ready, create a migration with php bin/console make:migration

tac:~/maker-demo$ bin/console make:entity Foo --regenerate

 [ERROR] No entities were found in the "Foo" namespace.                                                                 

tac:~/maker-demo$ bin/console make:entity App\\Entity\\Foo --regenerate

 no change: src/Entity/Foo.php

  Success! 

tac:~/maker-demo$ bin/console make:entity --regenerate

 This command will generate any missing methods (e.g. getters & setters) for a class or all classes in a namespace.     

 To overwrite any existing methods, re-run this command with the --overwrite flag                                       

 Enter a class or namespace to regenerate [App\Entity]:
 > Foo

 [ERROR] No entities were found in the "Foo" namespace.                                                                 

tac:~/maker-demo$ bin/console make:entity --regenerate

 This command will generate any missing methods (e.g. getters & setters) for a class or all classes in a namespace.     

 To overwrite any existing methods, re-run this command with the --overwrite flag                                       

 Enter a class or namespace to regenerate [App\Entity]:
 > App\Entity\Foo

 no change: src/Entity/Foo.php

  Success! 

tac:~/maker-demo$ 
LeJeanbono commented 4 years ago

Can we just change the message ? Enter a class (App\Entity\MyClass) or namespace to regenerate [App\Entity]: