Reputation: 886
I am familiarising myself with Symfony3, and getting failure running the CRUD generator. My terminal output below:
➜ keys php bin/console generate:doctrine:entity
Welcome to the Doctrine2 entity generator
This command helps you generate Doctrine2 entities.
First, you need to give the entity name you want to generate.
You must use the shortcut notation like AcmeBlogBundle:Post.
The Entity shortcut name: keys:passcodes
Bundle "keys" does not exist.
The Entity shortcut name:
➜ keys php bin/console generate:bundle --namespace=keys/Passcodes
Welcome to the Symfony bundle generator!
Are you planning on sharing this bundle across multiple applications? [no]:
Your application code must be written in bundles. This command helps
you generate them easily.
Give your bundle a descriptive name, like BlogBundle.
Bundle name [keys/Passcodes]:
The namespace must end with Bundle.
Bundle name [keys/Passcodes]: PasscodeBundle
Bundles are usually generated into the src/ directory. Unless you're
doing something custom, hit enter to keep this default!
Target Directory [src/]:
What format do you want to use for your generated configuration?
Configuration format (annotation, yml, xml, php) [annotation]: php
Bundle generation
> Generating a sample bundle skeleton into app/../src/PasscodeBundle
created ./app/../src/PasscodeBundle/
created ./app/../src/PasscodeBundle/PasscodeBundle.php
created ./app/../src/PasscodeBundle/Controller/
created ./app/../src/PasscodeBundle/Controller/DefaultController.php
created ./app/../tests/PasscodeBundle/Controller/
created ./app/../tests/PasscodeBundle/Controller/DefaultControllerTest.php
created ./app/../src/PasscodeBundle/Resources/views/Default/
created ./app/../src/PasscodeBundle/Resources/views/Default/index.html.twig
created ./app/../src/PasscodeBundle/Resources/config/
created ./app/../src/PasscodeBundle/Resources/config/services.php
created ./app/../src/PasscodeBundle/Resources/config/routing.php
> Checking that the bundle is autoloaded
> Enabling the bundle inside app/AppKernel.php
updated ./app/AppKernel.php
> Importing the bundle's routes from the app/config/routing.yml file
updated ./app/config/routing.yml
> Importing the bundle's services.php from the app/config/config.yml file
updated ./app/config/config.yml
Everything is OK! Now get to work :).
➜ keys php bin/console generate:doctrine:entity
Welcome to the Doctrine2 entity generator
This command helps you generate Doctrine2 entities.
First, you need to give the entity name you want to generate.
You must use the shortcut notation like AcmeBlogBundle:Post.
The Entity shortcut name: PasscodeBundle
The entity name isn't valid ("PasscodeBundle" given, expecting something like AcmeBlogBundle:Blog/Post)
The Entity shortcut name: PasscodeBundle:Passcodes
Determine the format to use for the mapping information.
Configuration format (yml, xml, php, or annotation) [annotation]: php
Instead of starting with a blank entity, you can add some fields now.
Note that the primary key will be added automatically (named id).
Available types: array, simple_array, json_array, object,
boolean, integer, smallint, bigint, string, text, datetime, datetimetz,
date, time, decimal, float, binary, blob, guid.
New field name (press <return> to stop adding fields): site
Field type [string]:
Field length [255]:
Is nullable [false]: true
Unique [false]:
New field name (press <return> to stop adding fields): email
Field type [string]:
Field length [255]:
Is nullable [false]: true
Unique [false]:
New field name (press <return> to stop adding fields): username
Field type [string]:
Field length [255]:
Is nullable [false]: true
Unique [false]:
New field name (press <return> to stop adding fields): passcode
Field type [string]:
Field length [255]:
Is nullable [false]: true
Unique [false]:
New field name (press <return> to stop adding fields): notes
Field type [string]: text
Is nullable [false]: true
Unique [false]:
New field name (press <return> to stop adding fields):
Entity generation
created ./src/PasscodeBundle/Entity/
created ./src/PasscodeBundle/Entity/Passcodes.php
created ./src/PasscodeBundle/Resources/config/doctrine/
created ./src/PasscodeBundle/Resources/config/doctrine/Passcodes.orm.php
> Generating entity class src/PasscodeBundle/Entity/Passcodes.php: OK!
> Generating repository class src/PasscodeBundle/Repository/PasscodesRepository.php: OK!
> Generating mapping file src/PasscodeBundle/Resources/config/doctrine/Passcodes.orm.php: OK!
Everything is OK! Now get to work :).
➜ keys php bin/console generate:doctrine:crud
Welcome to the Doctrine2 CRUD generator
This command helps you generate CRUD controllers and templates.
First, give the name of the existing entity for which you want to generate a CRUD
(use the shortcut notation like AcmeBlogBundle:Post)
The Entity shortcut name:
➜ keys php bin/console generate:doctrine:crud
Welcome to the Doctrine2 CRUD generator
This command helps you generate CRUD controllers and templates.
First, give the name of the existing entity for which you want to generate a CRUD
(use the shortcut notation like AcmeBlogBundle:Post)
The Entity shortcut name: PasscodeBundle:Passcodes
[RuntimeException]
Entity "Passcodes" does not exist in the "PasscodeBundle" bundle. You may h
ave mistyped the bundle name or maybe the entity doesn't exist yet (create
it first with the "doctrine:generate:entity" command).
doctrine:generate:crud [--entity ENTITY] [--route-prefix ROUTE-PREFIX] [--with-write] [--format FORMAT] [--overwrite] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> [<entity>]
➜ keys php bin/console generate:doctrine:crud
Welcome to the Doctrine2 CRUD generator
This command helps you generate CRUD controllers and templates.
First, give the name of the existing entity for which you want to generate a CRUD
(use the shortcut notation like AcmeBlogBundle:Post)
The Entity shortcut name: PasscodeBundle:
The entity name isn't valid ("PasscodeBundle:" given, expecting something like AcmeBlogBundle:Blog/Post)
The Entity shortcut name: PasscodeBundle:Passcode
[RuntimeException]
Entity "Passcode" does not exist in the "PasscodeBundle" bundle. You may ha
ve mistyped the bundle name or maybe the entity doesn't exist yet (create i
t first with the "doctrine:generate:entity" command).
doctrine:generate:crud [--entity ENTITY] [--route-prefix ROUTE-PREFIX] [--with-write] [--format FORMAT] [--overwrite] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> [<entity>]
➜ keys php bin/console doctrine:schema:update
No Metadata Classes to process.
➜ keys php bin/console doctrine:generate:form
[Symfony\Component\Console\Exception\RuntimeException]
Not enough arguments (missing: "entity").
doctrine:generate:form [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> <entity>
➜ keys php bin/console doctrine:generate:form PasscodeBundle:Passcodes
[Doctrine\ORM\ORMException]
Unknown Entity namespace alias 'PasscodeBundle'.
doctrine:generate:form [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> <entity>
➜ keys php bin/console generate:doctrine:crud
Welcome to the Doctrine2 CRUD generator
This command helps you generate CRUD controllers and templates.
First, give the name of the existing entity for which you want to generate a CRUD
(use the shortcut notation like AcmeBlogBundle:Post)
The Entity shortcut name: PasscodeBundle:Passcodes
[RuntimeException]
Entity "Passcodes" does not exist in the "PasscodeBundle" bundle. You may h
ave mistyped the bundle name or maybe the entity doesn't exist yet (create
it first with the "doctrine:generate:entity" command).
doctrine:generate:crud [--entity ENTITY] [--route-prefix ROUTE-PREFIX] [--with-write] [--format FORMAT] [--overwrite] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> [<entity>]
Any idea what I am doing wrong? As you can see above, I referenced and tried some things from Symfony3 : Generate crud doesn't work
Upvotes: 1
Views: 2218
Reputation: 17166
This seems to be an issue when using php
for the Entity's configuration format in bin/console doctrine:generate:entity
. Unfortunately just deleting the entity class and re-running the command is not enough. Since this seems to be a new project I recommend starting from scratch:
symfony new keys
Then update your settings, e.g. database settings in parameters.yml. You don't have to create a bundle as you can put everything into the default AppBundle
.
bin/console doctrine:generate:entity
> AppBundle:Passcode
Then choose annotation
format and type all your field requirements as you did before.
Now you should be able to generate the crud:
bin/console doctrine:generate:crud
> AppBundle:Passcode
Here you can use whatever configuration format you like. When you use AppBundle you have to use yml
as that is the current format and the generator does not like mixing styles. If you have your own bundle you can use whatever configuration format you like.
Upvotes: 2