{"id":56,"date":"2015-06-07T14:59:00","date_gmt":"2015-06-07T05:59:00","guid":{"rendered":"https:\/\/jikoman.sin-cos.com\/blog\/?p=56"},"modified":"2015-06-07T14:59:00","modified_gmt":"2015-06-07T05:59:00","slug":"11-yii_7","status":"publish","type":"post","link":"https:\/\/jikoman.sin-cos.com\/blog\/2015\/06\/11-yii_7\/","title":{"rendered":"\u30b5\u30a4\u30c8\u6539\u88c5\u3078\u306e\u9053(12) \u300cYii2\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u4e0a\u7d1a\u7de8\u300d"},"content":{"rendered":"<p>\u6628\u65e5\u306fBasic\u306a\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u304c\u3001\u4eca\u65e5\u306fAdvanced\u306a\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u307f\u308b\u3002<br \/>\n<a href=\"https:\/\/github.com\/yiisoft\/yii2-app-advanced\/blob\/master\/docs\/guide-ja\/start-installation.md\">\u3053\u3061\u3089<\/a>\u3092\u53c2\u8003\u306b\u3001\u6628\u65e5\u3068\u9055\u3046\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3002<\/p>\n<p>$ composer create-project &#8211;prefer-dist yiisoft\/yii2-app-advanced yii-advanced<br \/>\nInstalling yiisoft\/yii2-app-advanced (2.0.4)<br \/>\n&#8211; Installing yiisoft\/yii2-app-advanced (2.0.4)<br \/>\nDownloading: 100%         <br \/>\nCreated project in yii<br \/>\nLoading composer repositories with package information<br \/>\nInstalling dependencies (including require-dev)<br \/>\n&#8211; Installing yiisoft\/yii2-composer (2.0.3)               <br \/>\nLoading from cache<br \/>\n&#8211; Installing ezyang\/htmlpurifier (v4.6.0)<br \/>\nLoading from cache<br \/>\n&#8211; Installing cebe\/markdown (1.1.0)<br \/>\nLoading from cache<br \/>\n&#8211; Installing bower-asset\/jquery (2.1.4)<br \/>\nLoading from cache<br \/>\n&#8211; Installing bower-asset\/jquery.inputmask (3.1.63)<br \/>\nLoading from cache<br \/>\n&#8211; Installing bower-asset\/punycode (v1.3.2)<br \/>\nLoading from cache<br \/>\n&#8211; Installing bower-asset\/yii2-pjax (v2.0.4)<br \/>\nLoading from cache<br \/>\n&#8211; Installing yiisoft\/yii2 (2.0.4)<br \/>\nLoading from cache<br \/>\n&#8211; Installing swiftmailer\/swiftmailer (v5.4.1)<br \/>\nDownloading: 100%         <br \/>\n&#8211; Installing yiisoft\/yii2-swiftmailer (2.0.4)<br \/>\nLoading from cache<br \/>\n&#8211; Installing yiisoft\/yii2-codeception (2.0.4)<br \/>\nLoading from cache<br \/>\n&#8211; Installing bower-asset\/bootstrap (v3.3.4)<br \/>\nLoading from cache<br \/>\n&#8211; Installing yiisoft\/yii2-bootstrap (2.0.4)<br \/>\nLoading from cache<br \/>\n&#8211; Installing yiisoft\/yii2-debug (2.0.4)<br \/>\nLoading from cache<br \/>\n&#8211; Installing bower-asset\/typeahead.js (v0.10.5)<br \/>\nLoading from cache<br \/>\n&#8211; Installing phpspec\/php-diff (v1.0.2)<br \/>\nLoading from cache<br \/>\n&#8211; Installing yiisoft\/yii2-gii (2.0.4)<br \/>\nLoading from cache<br \/>\n&#8211; Installing fzaninotto\/faker (v1.5.0)<br \/>\nLoading from cache<br \/>\n&#8211; Installing yiisoft\/yii2-faker (2.0.3)<br \/>\nLoading from cache<br \/>\nfzaninotto\/faker suggests installing ext-intl (*)<br \/>\nWriting lock file<br \/>\nGenerating autoload files<\/p>\n<p>\u6b21\u306b\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u521d\u671f\u5316\u3002\u56e0\u307f\u306b\u958b\u767a\u74b0\u5883\u3067\u306e\u521d\u671f\u5316\u3002<\/p>\n<div class=\"p1\">\n$ php yii-advanced\/init<\/div>\n<div class=\"p1\">\nYii Application Initialization Tool v1.0<\/div>\n<div class=\"p2\">\n<\/div>\n<div class=\"p1\">\nWhich environment do you want the application to be initialized in?<\/div>\n<div class=\"p2\">\n<\/div>\n<div class=\"p1\">\n&nbsp; [0] Development<\/div>\n<div class=\"p1\">\n&nbsp; [1] Production<\/div>\n<div class=\"p2\">\n<\/div>\n<div class=\"p1\">\n&nbsp; Your choice [0-1, or &#8220;q&#8221; to quit] 0<\/div>\n<div class=\"p2\">\n<\/div>\n<div class=\"p1\">\n&nbsp; Initialize the application under &#8216;Development&#8217; environment? [yes|no] yes<\/div>\n<div class=\"p2\">\n<\/div>\n<div class=\"p1\">\n&nbsp; Start initialization &#8230;<\/div>\n<div class=\"p2\">\n<\/div>\n<div class=\"p1\">\n&nbsp;&nbsp; generate backend\/config\/main-local.php<\/div>\n<div class=\"p1\">\n&nbsp;&nbsp; generate backend\/config\/params-local.php<\/div>\n<div class=\"p1\">\n&nbsp;&nbsp; generate backend\/web\/index-test.php<\/div>\n<div class=\"p1\">\n&nbsp;&nbsp; generate backend\/web\/index.php<\/div>\n<div class=\"p1\">\n&nbsp;&nbsp; generate common\/config\/main-local.php<\/div>\n<div class=\"p1\">\n&nbsp;&nbsp; generate common\/config\/params-local.php<\/div>\n<div class=\"p1\">\n&nbsp;&nbsp; generate console\/config\/main-local.php<\/div>\n<div class=\"p1\">\n&nbsp;&nbsp; generate console\/config\/params-local.php<\/div>\n<div class=\"p1\">\n&nbsp;&nbsp; generate frontend\/config\/main-local.php<\/div>\n<div class=\"p1\">\n&nbsp;&nbsp; generate frontend\/config\/params-local.php<\/div>\n<div class=\"p1\">\n&nbsp;&nbsp; generate frontend\/web\/index-test.php<\/div>\n<div class=\"p1\">\n&nbsp;&nbsp; generate frontend\/web\/index.php<\/div>\n<div class=\"p1\">\n&nbsp;&nbsp; generate yii<\/div>\n<div class=\"p1\">\n&nbsp;&nbsp; generate cookie validation key in backend\/config\/main-local.php<\/div>\n<div class=\"p1\">\n&nbsp;&nbsp; generate cookie validation key in frontend\/config\/main-local.php<\/div>\n<div class=\"p1\">\n&nbsp; &nbsp; &nbsp; chmod 0777 backend\/runtime<\/div>\n<div class=\"p1\">\n&nbsp; &nbsp; &nbsp; chmod 0777 backend\/web\/assets<\/div>\n<div class=\"p1\">\n&nbsp; &nbsp; &nbsp; chmod 0777 frontend\/runtime<\/div>\n<div class=\"p1\">\n&nbsp; &nbsp; &nbsp; chmod 0777 frontend\/web\/assets<\/div>\n<div class=\"p1\">\n&nbsp; &nbsp; &nbsp; chmod 0755 yii<\/div>\n<div class=\"p1\">\n&nbsp; &nbsp; &nbsp; chmod 0755 tests\/codeception\/bin\/yii<\/div>\n<div class=\"p2\">\n<\/div>\n<div class=\"p1\">\n&nbsp; &#8230; initialization completed.<\/div>\n<div class=\"p2\">\n<\/div>\n<p>\u3042\u3068\u306f\u3001MySQL\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4f5c\u6210\u3057\u3001\u305d\u306e\u5185\u5bb9\u3067PHP\u30d5\u30a1\u30a4\u30eb\u3092\u66f4\u65b0\u3002<\/p>\n<p>$ vi yii-advanced\/common\/config\/main-local.php<\/p>\n<div class=\"p1\">\n<\/div>\n<div class=\"p1\">\nreturn [<\/div>\n<div class=\"p1\">\n&nbsp; &nbsp; &#8216;components&#8217; =&gt; [<\/div>\n<div class=\"p1\">\n&nbsp; &nbsp; &nbsp; &nbsp; &#8216;db&#8217; =&gt; [<\/div>\n<div class=\"p1\">\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8216;class&#8217; =&gt; &#8216;yiidbConnection&#8217;,<\/div>\n<div class=\"p1\">\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8216;dsn&#8217; =&gt; &#8216;mysql:host=127.0.0.1;port=8889;dbname=yii&#8217;,<\/div>\n<div class=\"p1\">\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8216;username&#8217; =&gt; &#8216;yii&#8217;,<\/div>\n<div class=\"p1\">\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8216;password&#8217; =&gt; &#8216;yii&#8217;,<\/div>\n<div class=\"p1\">\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8216;charset&#8217; =&gt; &#8216;utf8&#8217;,<\/div>\n<div class=\"p1\">\n&nbsp; &nbsp; &nbsp; &nbsp; ],<\/div>\n<div class=\"p1\">\n&nbsp; &nbsp; &nbsp; &nbsp; &#8216;mailer&#8217; =&gt; [<\/div>\n<div class=\"p1\">\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8216;class&#8217; =&gt; &#8216;yiiswiftmailerMailer&#8217;,<\/div>\n<div class=\"p1\">\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8216;viewPath&#8217; =&gt; &#8216;@common\/mail&#8217;,<\/div>\n<div class=\"p1\">\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ send all mails to a file by default. You have to set<\/div>\n<div class=\"p1\">\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ &#8216;useFileTransport&#8217; to false and configure a transport<\/div>\n<div class=\"p1\">\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ for the mailer to send real emails.<\/div>\n<div class=\"p1\">\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8216;useFileTransport&#8217; =&gt; true,<\/div>\n<div class=\"p1\">\n&nbsp; &nbsp; &nbsp; &nbsp; ],<\/div>\n<div class=\"p1\">\n&nbsp; &nbsp; ],<\/div>\n<p><\/p>\n<div class=\"p1\">\n];<\/div>\n<div class=\"p1\">\n<\/div>\n<p>\u4eca\u56de\u306f\u3001MAMP\u3092\u5229\u7528\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u30dd\u30fc\u30c8\u304c8889\u3068\u306a\u3063\u3066\u3044\u308b\u3002<br \/>\n\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u540d\u306f\u3001yii\u3002<br \/>\n\u30e6\u30fc\u30b6\u3082yii\u3002<\/p>\n<p>\u3042\u3068\u3001host\u306flocalhost\u3060\u3068\u3001migration\u6642\u306b\u6b21\u306e\u69d8\u306a\u30a8\u30e9\u30fc\u306b\u306a\u308b\u305f\u3081\u3001127.0.0.1\u306b\u5909\u66f4\u3057\u3066\u304a\u304f\u3002<\/p>\n<p>Exception &#8216;yiidbException&#8217; with message &#8216;SQLSTATE[HY000] [2002] No such file or directory&#8217;<\/p>\n<p>in yii\/vendor\/yiisoft\/yii2\/db\/Connection.php:534<\/p>\n<p>\u60c5\u5831\u3092\u5143\u306b\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u521d\u671f\u69cb\u6210\u3092\u884c\u3063\u3066\u3082\u3089\u3046\u3002<\/p>\n<div class=\"p1\">\n$ php yii-advanced\/yii migrate<\/div>\n<div class=\"p1\">\nYii Migration Tool (based on Yii v2.0.4)<\/div>\n<div class=\"p2\">\n<\/div>\n<div class=\"p3\">\nCreating migration history table &#8220;migration&#8221;&#8230;Done.<\/div>\n<div class=\"p3\">\nTotal 1 new migration to be applied:<\/div>\n<div class=\"p1\">\n m130524_201442_init<\/div>\n<div class=\"p2\">\n<\/div>\n<div class=\"p1\">\nApply the above migration? (yes|no) [no]:yes<\/div>\n<div class=\"p3\">\n*** applying m130524_201442_init<\/div>\n<div class=\"p1\">\n&nbsp; &nbsp; &gt; create table {{%user}} &#8230; done (time: 0.019s)<\/div>\n<div class=\"p4\">\n*** applied m130524_201442_init (time: 0.025s)<\/div>\n<div class=\"p2\">\n<\/div>\n<div class=\"p2\">\n<\/div>\n<p>Migrated up successfully.<\/p>\n<p>\u3053\u308c\u3067\u6b21\u306eURL\u3067\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3001\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u306e\u30da\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u308b\u3002<\/p>\n<p>http:\/\/localhost:8888\/yii-advanced\/frontend\/web\/index.php<br \/>\nhttp:\/\/localhost:8888\/yii-advanced\/backend\/web\/index.php<\/p>\n<p>\u843d\u3068\u3057\u7a74\u3044\u3063\u3071\u3044\u3002\u75b2\u308c\u308b\u3088\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6628\u65e5\u306fBasic\u306a\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u304c\u3001\u4eca\u65e5\u306fAdvanced\u306a\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u307f\u308b\u3002 \u3053\u3061\u3089\u3092\u53c2\u8003\u306b\u3001\u6628\u65e5\u3068\u9055\u3046\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3002 $ composer create-project &#038;#821 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[130],"tags":[],"class_list":["post-56","post","type-post","status-publish","format-standard","hentry","category-130"],"_links":{"self":[{"href":"https:\/\/jikoman.sin-cos.com\/blog\/wp-json\/wp\/v2\/posts\/56","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jikoman.sin-cos.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jikoman.sin-cos.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jikoman.sin-cos.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jikoman.sin-cos.com\/blog\/wp-json\/wp\/v2\/comments?post=56"}],"version-history":[{"count":0,"href":"https:\/\/jikoman.sin-cos.com\/blog\/wp-json\/wp\/v2\/posts\/56\/revisions"}],"wp:attachment":[{"href":"https:\/\/jikoman.sin-cos.com\/blog\/wp-json\/wp\/v2\/media?parent=56"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jikoman.sin-cos.com\/blog\/wp-json\/wp\/v2\/categories?post=56"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jikoman.sin-cos.com\/blog\/wp-json\/wp\/v2\/tags?post=56"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}