-
-
Notifications
You must be signed in to change notification settings - Fork 404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'Make:entity' failed when don't use the default namespace 'App'. #133
Comments
Hmm, the command should work if you pass a fully-qualified class name to the first step - e.g. Here's the error I'm currently getting:
|
Hi guys, first of all thanks for this amazing and promising bundle! I am testing the bundle with symfony3.4 (as the documentation mentioned it should work with it) and indeed I had to go mess directly with the 2 lignes @yuhuaian mentioned to change "App" to "AppBundle" (unless I am wrong this is the convention for the bundle name for 3.4?). Otherwise, I would not get prompted for the entity's fully qualified name and would get this error instead:
Hope this helps. |
Hmm, this does help! What you’re describing is the expected behavior: we assume App unless you pass a full class name (including the beginning slash iirc). But, I think if we guess App, but we can’t determine where to generate the file (which means that you have no App namespace in your autoloading), we could THEN ask you to clarify by entering the full class name. Then you could easily know how to use the command in these cases :). |
Thanks for your answer, the solution sounds good to me! :) |
Wouldn't it be possible to reference namespace directly from composer.json ? If we anyway have to define it for autoload. |
Hello! I have the similar issue. We don't use
As we can see all errors are identical. It is because I've found 8 places where What do you think about? P.S. |
@upyx Actually, your description isn't quite right, but clearly the bundle isn't doing a very helpful job :). You can use a non-App namespace on any command, but you must type the full class name. For example, you should be able to php bin/console make:controller Then, when it asks you for the controller name, use:
By starting your namespace with We need to: A) Give a better error message in all commands. Instead of B) We probably need to make the |
Should we do a configuration file ? |
@weaverryan Oh, I didn't know that. Thank you for advice. @LeJeanbono I think so. Would you like to do that? |
This is not correct @weaverryan Sure you can use full class name when generating controllers etc. but when generating Entities it doesn't work. You can pass full class name for the Entity but when script reaches the point to start generating the Repository for the Entity it fails and there is no option to pass in the full namespace for that. Option B sounds reasonable and as i pointed out before, it actually should get the namespace from composer.json and default App namespace should be a fallback when everything else fails. But otherwise keep up the awesome work! |
Is any news about repository in Make:entity? I can do PR if needed. |
@helariL Hello! In my opinion we should use configuration file. "psr-4": {
"Symfony\\Bridge\\Doctrine\\": "src/Symfony/Bridge/Doctrine/",
"Symfony\\Bridge\\Monolog\\": "src/Symfony/Bridge/Monolog/",
"Symfony\\Bridge\\ProxyManager\\": "src/Symfony/Bridge/ProxyManager/",
"Symfony\\Bridge\\Twig\\": "src/Symfony/Bridge/Twig/",
"Symfony\\Bundle\\": "src/Symfony/Bundle/",
"Symfony\\Component\\": "src/Symfony/Component/"
} What is it the namespace to use as root? 😄 |
@upyx it was just a suggestion. 😄 Obviously configuration file would be the best option. To be honest I would be happy if we could even pass it in like other options |
@helariL You can use absolute path (https://github.com/symfony/maker-bundle/blob/master/src/Generator.php#L107) |
@eugenekurasov yes that works really well when generating controllers etc. but try the same thing with make:entity 😉 |
…averryan) This PR was merged into the 1.0-dev branch. Discussion ---------- Add configuration of root namespace This PR adds configuration for namespaces used in `make:*` commands that was discussed in #133. I've used [this doc](https://symfony.com/doc/current/bundles/configuration.html) in work and examples from `FrameworkBundle`. New parameter: `maker.root_namespace` - application root namespace, default: `App` To change it, you should create configuration file in `config/packages/dev` with name `maker.yaml` or `maker.xml` or `maker.php` with root node `maker`. For example YAML file: ```yaml # config/packages/dev/maker.yaml maker: root_namespace: 'App' ``` I've added some tests. I think we don't need Flex recipe but just document new feature. I need help for write documentation because my English. TODO: - [x] Tests - [x] Documentations - [ ] Squash commits Commits ------- 42b7008 Fixing accidental removal of property 545a422 Merge branch 'master' into configurable_namespace b92f19c Merge branch 'master' into configurable_namespace bf1b092 updating for now-missing property b5658c2 Merge branch 'master' into configurable_namespace 7440ade return type stuff 656116c Changing from an exception 5605d6e adding docs 23a715c Merge remote-tracking branch 'upstream/master' into configurable_namespace 152ffa6 The most important fix f34fa39 Add exception with hint message when root namespace is not found 758a2c9 Refactor AutoloaderUtil 5423250 Remove maker.root_namespace parameter and improve tests 7157e88 Fix file creation on Windows 657f653 Remove useless code a425953 Add functional tests for custom root namespace cases d4139d4 Make "abstract" command and remove entity namespace from config 51d7138 Add configuration of root and entity namespaces
Closing as fixed by #173. |
I'm getting the same error, having configured the default namespace. I'm using my own namespace under src/.
|
For People looking for answer: It works! To clarify use config similar to this:
doctrine:
orm:
mappings:
YourAcme:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'YourAcme\Entity'
alias: YourAcme
maker:
root_namespace: YourAcme |
If you are using 3.4 you need to place the maker config in
|
Hi, but it only works for 1 specific custom folder, in this case, YourAcme. |
No. See #133 (comment) You can set the full class name like: bin/console make:entity '\YourAcme2\Entity\SomeEntity' |
src/Doctrine/DoctrineEntityHelper.php
line 45
$entityClassDetails = new ClassNameDetails($metadata->name, 'App\\Entity');
src/Maker/MakeCommand.php
line 91
$generator = new Generator($this->fileManager, 'App\\');
The text was updated successfully, but these errors were encountered: