Comments (22)
For People looking for answer:
It works! To clarify use config similar to this:
config/packages/doctrine.yaml
doctrine:
orm:
mappings:
YourAcme:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'YourAcme\Entity'
alias: YourAcme
config/packages/dev/maker.yaml
maker:
root_namespace: YourAcme
from maker-bundle.
Hmm, the command should work if you pass a fully-qualified class name to the first step - e.g. Acme\Foo\Bar
, but it looks like we missed at least one thing:
Here's the error I'm currently getting:
./bin/console make:entity
Class name of the entity to create or update (e.g. GentleGnome):
> \App\Foo\Bar\Entity\Baz
created: src/Foo/Bar/Entity/Baz.php
created: src/Repository/Foo/Bar/Entity/BazRepository.php
[ERROR] Only annotation mapping is supported by make:entity, but the
<info>App\Foo\Bar\Entity\Baz</info> class uses a different format. If you would like
this command to generate the properties & getter/setter methods, add your mapping
configuration, and then re-run this command with the <info>--regenerate</info> flag.
from maker-bundle.
@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
--namespace=\\MyAwesomeApp\\src
( or something similar )
from maker-bundle.
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 :).
from maker-bundle.
@helariL Hello! In my opinion we should use configuration file.
There is part of composer.json
from symfony project:
"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? ๐
from maker-bundle.
I'm getting the same error, having configured the default namespace. I'm using my own namespace under src/.
ubuntu@aerobill:/var/www/aerobill$ ./bin/console make:entity
Class name of the entity to create or update (e.g. BraveElephant):
> Tenant
created: src/Entity/Tenant.php
created: src/Repository/TenantRepository.php
[ERROR] Only annotation mapping is supported by make:entity, but the <info>XXX\Entity\Tenant</info> class uses
a different format. If you would like this command to generate the properties & getter/setter methods, add your
mapping configuration, and then re-run this command with the <info>--regenerate</info> flag.
ubuntu@aerobill:/var/www/aerobill$ cat config/packages/dev/maker.yaml
maker:
root_namespace: 'XXX'
from maker-bundle.
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:
bin/console make:entity Test
Could not determine where to locate the new class "App\Entity\Test".
Hope this helps.
from maker-bundle.
Thanks for your answer, the solution sounds good to me! :)
from maker-bundle.
Wouldn't it be possible to reference namespace directly from composer.json ? If we anyway have to define it for autoload.
from maker-bundle.
Hello!
I have the similar issue. We don't use App
as root namespace of our project so all make:*
commands doesn't work. Few examples:
Command | Error |
---|---|
make:auth | Could not determine where to locate the new class "App\Security\SuperAuth". |
make:command | Could not determine where to locate the new class "App\Command\ProjHelloCommand". |
make:controller | Could not determine where to locate the new class "App\Controller\VictoriousGnomeController". |
make:entity | Could not determine where to locate the new class "App\Entity\TinyKangaroo". |
make:form | Could not determine where to locate the new class "App\Form\TinyPizzaType". |
make:functional-test | Could not determine where to locate the new class "App\Tests\DefaultControllerTest". |
make:unit-test | Could not determine where to locate the new class "App\Tests\UtilTest". |
As we can see all errors are identical. It is because App
is hardcoded and there is no way to change it without interfering to code. I'm not sure that simple determining root namespace is possible. But we can do it configurable.
I've found 8 places where App
was hardcoded. So refactoring won't be very difficult.
What do you think about?
P.S.
What do you say about changing title to "All 'make:*' failed..."?
from maker-bundle.
@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:
\MyNamespace\Controller\FooController
By starting your namespace with \
, we know that you are giving us a full namespace.
We need to:
A) Give a better error message in all commands. Instead of Could not determine where to locate the new class "App\Security\SuperAuth".
, we need to suggest that the user type in the full namespace, because obviously, App\
is not used by them.
B) We probably need to make the App\
root prefix configurable.
from maker-bundle.
Should we do a configuration file ?
from maker-bundle.
@weaverryan Oh, I didn't know that. Thank you for advice.
However not all commands ask class name. For example, make:command
asks command name and doesn't ask class.
I think it would be better if a user does not need to type the full class name.
@LeJeanbono I think so. Would you like to do that?
from maker-bundle.
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!
from maker-bundle.
Is any news about repository in Make:entity?
I can do PR if needed.
from maker-bundle.
@helariL You can use absolute path (https://github.com/symfony/maker-bundle/blob/master/src/Generator.php#L107)
make:controller \\Controller\\CustomController
from maker-bundle.
@eugenekurasov yes that works really well when generating controllers etc. but try the same thing with make:entity ๐
from maker-bundle.
@helariL make:entity has problem with absolute path.
I created issue for make:entity, but then closed.
from maker-bundle.
Closing as fixed by #173.
from maker-bundle.
If you are using 3.4 you need to place the maker config in
app/config/config_dev.yml
from maker-bundle.
For People looking for answer:
It works! To clarify use config similar to this:
config/packages/doctrine.yaml
doctrine: orm: mappings: YourAcme: is_bundle: false type: annotation dir: '%kernel.project_dir%/src/Entity' prefix: 'YourAcme\Entity' alias: YourAcmeconfig/packages/dev/maker.yaml
maker: root_namespace: YourAcme
Hi, but it only works for 1 specific custom folder, in this case, YourAcme.
What if I want to have multiple custom folders? (e.g YourAcme2, YourAcme3 etc)
I will then have to change the root_namespace manually every time I want to create entity/repository for that specific folder. Is that right?
from maker-bundle.
What if I want to have multiple custom folders? (e.g YourAcme2, YourAcme3 etc) I will then have to change the root_namespace manually every time I want to create entity/repository for that specific folder. Is that right?
No. See #133 (comment)
You can set the full class name like:
bin/console make:entity '\YourAcme2\Entity\SomeEntity'
from maker-bundle.
Related Issues (20)
- [make:entity] Cannot create an entity called "Locale" HOT 2
- Make:entity requires Mercure too soon HOT 1
- [make:entity] addGetter on boolean field that starts with "is" HOT 1
- [make:entity] `generate()` call to `is_string()` appears to always evaluate to `false`
- Missing ? in symfony console make:entity? HOT 9
- Critical error: ClassSourceManipulator HOT 4
- [make:entity] Exception in DoctrineHelper.php HOT 2
- Why is the registration confirmation link (verify-email-bundle) not working in Symfony 6 ? HOT 8
- [make:auth] V1.59 - Deprecated classes causes deprecated message on each page HOT 1
- [make:entity] no more autocompletion on repository methods HOT 1
- Use final classes
- Deprecation : symfony/maker-bundle v1.59.0 HOT 1
- PHPStan - User::getPassword()
- PHPStan - ResetPasswordRequest::getUser()
- [make:crud] Add support for dynamic CSRF id with Expression in `#[IsCsrfTokenValid]`
- [make:crud] Allow `EntityValueResolver` to return a list of entities
- [make:registration-form] Add `hash_property_path` option to `PasswordType` HOT 1
- [make:reset-password] Add `hash_property_path` option to `PasswordType` HOT 1
- [make:entity] Entity Names Should Be Allowed to Have Digits (i.e. v1) HOT 1
- [make:entity] default value
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from maker-bundle.