1. バンドル作成
Symfony2でコマンドラインから名前を引数にコマンドを実行したらデータベースにその名前と日付を登録する
アプリケーションを作成して行きます。
まずは、バンドルの作成を行います。
バンドルの作成は、symfony2のgenerate:bundle コマンドを使用します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
$ php app/console generate:bundle --namespace=My/DBCommand Welcome to the Symfony2 bundle generator Your application code must be written in bundles. This command helps you generate them easily. Each bundle is hosted under a namespace (like Acme/Bundle/BlogBundle). The namespace should begin with a "vendor" name like your company name, your project name, or your client name, followed by one or more optional category sub-namespaces, and it should end with the bundle name itself (which must have Bundle as a suffix). See http://symfony.com/doc/current/cookbook/bundles/best_practices.html#index-1 for more details on bundle naming conventions. Use / instead of \ for the namespace delimiter to avoid any problem. Bundle namespace [My/DBCommand]: The namespace must end with Bundle. Bundle namespace [My/DBCommand]: $ php app/console generate:bundle --namespace=My/DBCommandBundle Welcome to the Symfony2 bundle generator Your application code must be written in bundles. This command helps you generate them easily. Each bundle is hosted under a namespace (like Acme/Bundle/BlogBundle). The namespace should begin with a "vendor" name like your company name, your project name, or your client name, followed by one or more optional category sub-namespaces, and it should end with the bundle name itself (which must have Bundle as a suffix). See http://symfony.com/doc/current/cookbook/bundles/best_practices.html#index-1 for more details on bundle naming conventions. Use / instead of \ for the namespace delimiter to avoid any problem. Bundle namespace [My/DBCommandBundle]: In your code, a bundle is often referenced by its name. It can be the concatenation of all namespace parts but it's really up to you to come up with a unique name (a good practice is to start with the vendor name). Based on the namespace, we suggest MyDBCommandBundle. Bundle name [MyDBCommandBundle]: The bundle can be generated anywhere. The suggested default directory uses the standard conventions. Target directory [/home/hogehoge/public_html/symfony2/src]: Determine the format to use for the generated configuration. Configuration format (yml, xml, php, or annotation) [annotation]: To help you get started faster, the command can generate some code snippets for you. Do you want to generate the whole directory structure [no]? Summary before generation You are going to generate a "My\DBCommandBundle\MyDBCommandBundle" bundle in "/home/hogehoge/public_html/symfony2/src/" using the "annotation" format. Do you confirm generation [yes]? Bundle generation Generating the bundle code: OK Checking that the bundle is autoloaded: OK Confirm automatic update of your Kernel [yes]? Enabling the bundle inside the Kernel: OK Confirm automatic update of the Routing [yes]? Importing the bundle routing resource: OK You can now start using the generated code! |