Created
December 10, 2012 13:37
-
-
Save nouphet/4250606 to your computer and use it in GitHub Desktop.
Symfony2 でアプリを作る基礎 ref: http://qiita.com/items/f71e62aeed013a82e7d6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd /Applications/MAMP/htdocs | |
$ mkdir myblog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ wget "http://symfony.com/download?v=Symfony_Standard_Vendors_2.1.4.tgz" | |
$ mv download?v=Symfony_Standard_Vendors_2.1.4.tgz Symfony_Standard_Vendors_2.1.4.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ tree src/ | |
src/ | |
└── Nouphet | |
└── Bundle | |
└── MyblogBundle | |
├── Controller | |
│ └── DefaultController.php | |
├── DependencyInjection | |
│ ├── Configuration.php | |
│ └── NouphetMyblogExtension.php | |
├── NouphetMyblogBundle.php | |
├── Resources | |
│ ├── config | |
│ │ └── services.xml | |
│ └── views | |
│ └── Default | |
│ └── index.html.twig | |
└── Tests | |
└── Controller | |
└── DefaultControllerTest.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open http://localhost/myblog/Symfony/web/app_dev.php/hello/nouphet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hello nouphet! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./app/console doctrine:generate:entity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./app/console doctrine:generate: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: NouphetMyblogBundle:Post | |
Determine the format to use for the mapping information. | |
Configuration format (yml, xml, php, or annotation) [annotation]: | |
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, blob, guid. | |
New field name (press <return> to stop adding fields): title | |
Field type [string]: | |
Field length [255]: | |
New field name (press <return> to stop adding fields): body | |
Field type [string]: text | |
New field name (press <return> to stop adding fields): | |
Do you want to generate an empty repository class [no]? | |
Summary before generation | |
You are going to generate a "NouphetMyblogBundle:Post" Doctrine2 entity | |
using the "annotation" format. | |
Do you confirm generation [yes]? | |
Entity generation | |
Generating the entity code: OK | |
You can now start using the generated code! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./app/console doctrine:schema:update --dump-sql | |
CREATE TABLE Post (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) NOT NULL, body LONGTEXT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./app/console doctrine:schema:update --dump-sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./app/console doctrine:schema:update --force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ tar zxvf Symfony_Standard_Vendors_2.1.4.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./app/console doctrine:schema:update --force | |
Updating database schema... | |
Database schema updated successfully! "1" queries were executed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./app/console doctrine:generate:crud |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./app/console doctrine:schema:update --force | |
Updating database schema... | |
Database schema updated successfully! "1" queries were executed | |
nouphet@NouphetMacBookAir.local:/Applications/MAMP/htdocs/myblog/Symfony[master] | |
$ ./app/console doctrine:generate:crud | |
Welcome to the Doctrine2 CRUD generator | |
This command helps you generate CRUD controllers and templates. | |
First, you need to give the entity for which you want to generate a CRUD. | |
You can give an entity that does not exist yet and the wizard will help | |
you defining it. | |
You must use the shortcut notation like AcmeBlogBundle:Post. | |
The Entity shortcut name: NouphetMyblogBundle:Post | |
By default, the generator creates two actions: list and show. | |
You can also ask it to generate "write" actions: new, update, and delete. | |
Do you want to generate the "write" actions [no]? yes | |
Determine the format to use for the generated CRUD. | |
Configuration format (yml, xml, php, or annotation) [annotation]: | |
Determine the routes prefix (all the routes will be "mounted" under this | |
prefix: /prefix/, /prefix/new, ...). | |
Routes prefix [/post]: | |
Summary before generation | |
You are going to generate a CRUD controller for "NouphetMyblogBundle:Post" | |
using the "annotation" format. | |
Do you confirm generation [yes]? | |
CRUD generation | |
Generating the CRUD code: OK | |
Generating the Form code: OK | |
You can now start using the generated code! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ open http://localhost/myblog/Symfony/web/app_dev.php/post/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./app/console --shell | |
_____ __ ___ | |
/ ____| / _| |__ \ | |
| (___ _ _ _ __ ___ | |_ ___ _ __ _ _ ) | | |
\___ \| | | | '_ ` _ \| _/ _ \| '_ \| | | | / / | |
____) | |_| | | | | | | || (_) | | | | |_| |/ /_ | |
|_____/ \__, |_| |_| |_|_| \___/|_| |_|\__, |____| | |
__/ | __/ | | |
|___/ |___/ | |
Welcome to the Symfony shell (2.1.2 - app/dev/debug). | |
At the prompt, type help for some help, | |
or list to get a list of available commands. | |
To exit the shell, type ^D. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ll | |
total 6536 | |
drwxr-xr-x 12 nouphet admin 408 11 29 21:04 Symfony | |
-rw-r--r-- 1 nouphet admin 3342513 12 4 02:37 Symfony_Standard_Vendors_2.1.4.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd Symfony | |
wget https://raw.github.com/symfony/symfony-standard/master/.gitignore | |
git init | |
git add . | |
git commit -m "first commit" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open http://localhost/myblog/Symfony/web/app_dev.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./app/console doctrine:database:create |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./app/console generate:bundle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./app/console generate:bundle | |
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: Nouphet/Bundle/MyblogBundle | |
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 NouphetMyblogBundle. | |
Bundle name [NouphetMyblogBundle]: | |
The bundle can be generated anywhere. The suggested default directory uses | |
the standard conventions. | |
Target directory [/Applications/MAMP/htdocs/myblog/Symfony/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 "Nouphet\Bundle\MyblogBundle\NouphetMyblogBundle" bundle | |
in "/Applications/MAMP/htdocs/myblog/Symfony/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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 database_name: myblog | |
6 database_user: root | |
7 database_password: root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 * @ORM\Table(name="post") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment