GitBashを起動して、カレントディレクトリをxamppのhtdocsに移動。
$ cd c:/xampp/htdocs
そして、yii2の上級テンプレートを作成。
$ composer create-project –prefer-dist yiisoft/yii2-app-advanced
Installing yiisoft/yii2-app-advanced (2.0.4)
– Installing yiisoft/yii2-app-advanced (2.0.4)
Downloading: 100%
Created project in C:xampphtdocsyii2-app-advanced
Loading composer repositories with package information
Installing dependencies (including require-dev)
– Installing yiisoft/yii2-composer (2.0.3)
Loading from cache
– Installing ezyang/htmlpurifier (v4.6.0)
Loading from cache
– Installing cebe/markdown (1.1.0)
Loading from cache
– Installing bower-asset/jquery (2.1.4)
Loading from cache
– Installing bower-asset/jquery.inputmask (3.1.63)
Loading from cache
– Installing bower-asset/punycode (v1.3.2)
Loading from cache
– Installing bower-asset/yii2-pjax (v2.0.4)
Loading from cache
– Installing yiisoft/yii2 (2.0.4)
Loading from cache
– Installing swiftmailer/swiftmailer (v5.4.1)
Loading from cache
– Installing yiisoft/yii2-swiftmailer (2.0.4)
Loading from cache
– Installing yiisoft/yii2-codeception (2.0.4)
Loading from cache
– Installing bower-asset/bootstrap (v3.3.5)
Downloading: 100%
– Installing yiisoft/yii2-bootstrap (2.0.4)
Loading from cache
– Installing yiisoft/yii2-debug (2.0.4)
Loading from cache
– Installing bower-asset/typeahead.js (v0.10.5)
Loading from cache
– Installing phpspec/php-diff (v1.0.2)
Loading from cache
– Installing yiisoft/yii2-gii (2.0.4)
Loading from cache
– Installing fzaninotto/faker (v1.5.0)
Loading from cache
– Installing yiisoft/yii2-faker (2.0.3)
Loading from cache
fzaninotto/faker suggests installing ext-intl (*)
Writing lock file
Generating autoload files
あれ、もう終わり?
上級テンプレートなので、あとは初期化して、
$ php yii2-app-advanced/initYii Application Initialization Tool v1.0
Which environment do you want the application to be initialized in?
[0] Development
[1] Production
Your choice [0-1, or “q” to quit] 0
Initialize the application under ‘Development’ environment? [yes|no] yes
Start initialization …
generate backend/config/main-local.php
generate backend/config/params-local.php
generate backend/web/index-test.php
generate backend/web/index.php
generate common/config/main-local.php
generate common/config/params-local.php
generate console/config/main-local.php
generate console/config/params-local.php
generate frontend/config/main-local.php
generate frontend/config/params-local.php
generate frontend/web/index-test.php
generate frontend/web/index.php
generate yii
generate cookie validation key in backend/config/main-local.php
generate cookie validation key in frontend/config/main-local.php
chmod 0777 backend/runtime
chmod 0777 backend/web/assets
chmod 0777 frontend/runtime
chmod 0777 frontend/web/assets
chmod 0755 yii
chmod 0755 tests/codeception/bin/yii
… initialization completed.
ちなみに開発環境としての初期化ね。
次に、MySQLデータベース上に、ユーザーとデータベースを作成し、次のファイルをユーザ名とデータベース名に合わせて編集。
c:/xampp/htdocs/yii2-app-advanced/common/config/main-local.php
return [
‘components’ => [
‘db’ => [
‘class’ => ‘yiidbConnection’,
‘dsn’ => ‘mysql:host=localhost;dbname=yii’,
‘username’ => ‘yii’,
‘password’ => ‘yii’,
‘charset’ => ‘utf8’,
],
‘mailer’ => [
‘class’ => ‘yiiswiftmailerMailer’,
‘viewPath’ => ‘@common/mail’,
// send all mails to a file by default. You have to set
// ‘useFileTransport’ to false and configure a transport
// for the mailer to send real emails.
‘useFileTransport’ => true,
],
],
];
$ php yii2-app-advanced/yii migrate
Yii Migration Tool (based on Yii v2.0.4)
Creating migration history table “migration”…Done.
Total 1 new migration to be applied:
m130524_201442_init
Apply the above migration? (yes|no) [no]:yes
*** applying m130524_201442_init
> create table {{%user}} … done (time: 0.313s)
*** applied m130524_201442_init (time: 0.348s)
Migrated up successfully.