CRUD命令行失败

时间:2017-03-28 17:19:06

标签: symfony

我熟悉Symfony3,并且无法运行CRUD生成器。我的终端输出如下:



➜  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>]
&#13;
&#13;
&#13;

知道我做错了什么吗?如您所见,我引用并尝试了Symfony3 : Generate crud doesn't work

中的一些内容

1 个答案:

答案 0 :(得分:2)

php中使用bin/console doctrine:generate:entity作为实体配置格式时,这似乎是一个问题。不幸的是,仅删除实体类并重新运行命令是不够的。由于这似乎是一个新项目,我建议从头开始:

symfony new keys

然后更新您的设置,例如parameters.yml中的数据库设置。您不必创建捆绑包,因为您可以将所有内容放入默认的AppBundle

bin/console doctrine:generate:entity

> AppBundle:Passcode

然后选择annotation格式,并像之前一样输入所有字段要求。

现在你应该能够生成crud:

bin/console doctrine:generate:crud

> AppBundle:Passcode

您可以在这里使用您喜欢的任何配置格式。当您使用AppBundle时,您必须使用yml,因为这是当前格式,而生成器不喜欢混合样式。如果您有自己的捆绑包,则可以使用您喜欢的任何配置格式。