{"id":4806,"date":"2019-09-22T09:28:16","date_gmt":"2019-09-22T09:28:16","guid":{"rendered":"http:\/\/myprojects.advchaweb.com\/?p=4806"},"modified":"2019-09-22T10:00:06","modified_gmt":"2019-09-22T10:00:06","slug":"yii2","status":"publish","type":"post","link":"https:\/\/myprojects.advchaweb.com\/index.php\/2019\/09\/22\/yii2\/","title":{"rendered":"Yii2"},"content":{"rendered":"<p>Ref: https:\/\/www.yiiframework.com\/<br \/>\nhttps:\/\/www.yiiframework.com\/doc\/guide\/2.0\/en\/start-installation<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"tA5vUvLodx\"><p><a href=\"https:\/\/www.osradar.com\/install-yii-php-framework-debian-9-ubuntu\/\">How to install Yii PHP Framework on Debian 9 and Ubuntu 18.04?<\/a><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"https:\/\/www.osradar.com\/install-yii-php-framework-debian-9-ubuntu\/embed\/#?secret=tA5vUvLodx\" data-secret=\"tA5vUvLodx\" width=\"600\" height=\"338\" title=\"&#8220;How to install Yii PHP Framework on Debian 9 and Ubuntu 18.04?&#8221; &#8212; OSRadar Open Source - Technology\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<p>Create a Yii2 project &#8216;yii2-kickstart&#8217; via composer:<\/p>\n<pre class=\"lang:default decode:true\">composer create-project --prefer-dist --no-dev yiisoft\/yii2-app-basic yii2-kickstart<\/pre>\n<p>Go to the project dir then modify composer.json to add &#8216;replace&#8217; like this:<\/p>\n<pre class=\"lang:default decode:true \">{\r\n    \"name\": \"yiisoft\/yii2-app-basic\",\r\n    ...\r\n    \"replace\": {\r\n\t\"bower-asset\/jquery\": \"&gt;=1.11.0\",\r\n\t\"bower-asset\/inputmask\": \"&gt;=3.2.0\",\r\n\t\"bower-asset\/punycode\": \"&gt;=1.3.0\",\r\n\t\"bower-asset\/yii2-pjax\": \"&gt;=2.0.0\"\r\n    },\r\n    \"repositories\": [\r\n        ...\r\n    ]\r\n}<\/pre>\n<p>If I don&#8217;t do this, i&#8217;ll get this error:<\/p>\n<pre class=\"lang:default decode:true \">Exception 'yii\\base\\InvalidConfigException' with message 'Failed to instantiate component or class \"yii\\gii\\Module\".'\r\n\r\nin \/home\/teddy\/Documents\/works\/yii2-kickstart\/vendor\/yiisoft\/yii2\/di\/Container.php:433\r\n\r\nStack trace:\r\n#0 \/home\/teddy\/Documents\/works\/yii2-kickstart\/vendor\/yiisoft\/yii2\/di\/Container.php(365): yii\\di\\Container-&gt;getDependencies('yii\\\\gii\\\\Module')\r\n#1 \/home\/teddy\/Documents\/works\/yii2-kickstart\/vendor\/yiisoft\/yii2\/di\/Container.php(156): yii\\di\\Container-&gt;build('yii\\\\gii\\\\Module', Array, Array)\r\n#2 \/home\/teddy\/Documents\/works\/yii2-kickstart\/vendor\/yiisoft\/yii2\/BaseYii.php(349): yii\\di\\Container-&gt;get('yii\\\\gii\\\\Module', Array, Array)\r\n#3 \/home\/teddy\/Documents\/works\/yii2-kickstart\/vendor\/yiisoft\/yii2\/base\/Module.php(427): yii\\BaseYii::createObject(Array, Array)\r\n#4 \/home\/teddy\/Documents\/works\/yii2-kickstart\/vendor\/yiisoft\/yii2\/base\/Application.php(315): yii\\base\\Module-&gt;getModule('gii')\r\n#5 \/home\/teddy\/Documents\/works\/yii2-kickstart\/vendor\/yiisoft\/yii2\/base\/Application.php(273): yii\\base\\Application-&gt;bootstrap()\r\n#6 \/home\/teddy\/Documents\/works\/yii2-kickstart\/vendor\/yiisoft\/yii2\/console\/Application.php(124): yii\\base\\Application-&gt;init()\r\n#7 \/home\/teddy\/Documents\/works\/yii2-kickstart\/vendor\/yiisoft\/yii2\/base\/BaseObject.php(109): yii\\console\\Application-&gt;init()\r\n#8 \/home\/teddy\/Documents\/works\/yii2-kickstart\/vendor\/yiisoft\/yii2\/base\/Application.php(206): yii\\base\\BaseObject-&gt;__construct(Array)\r\n#9 \/home\/teddy\/Documents\/works\/yii2-kickstart\/vendor\/yiisoft\/yii2\/console\/Application.php(89): yii\\base\\Application-&gt;__construct(Array)\r\n#10 \/home\/teddy\/Documents\/works\/yii2-kickstart\/yii(19): yii\\console\\Application-&gt;__construct(Array)\r\n#11 {main}<\/pre>\n<p>Then run &#8216;composer update&#8217;<br \/>\nThen run &#8216;php yii serve&#8217;. it&#8217;ll use port 8080<br \/>\nIf the port 8080 is already used, you can use another port like 888:<\/p>\n<pre class=\"lang:default decode:true\">php yii serve --port=8888<\/pre>\n<p>Then open it on your browser: http:\/\/localhost:8888\/<br \/>\nBUT I GOT THIS ERROR ON THE PAGE<\/p>\n<pre class=\"lang:default decode:true\">Invalid Argument \u2013 yii\\base\\InvalidArgumentException\r\nThe file or directory to be published does not exist: {ROOT}\/vendor\/bower-asset\/jquery\/dist<\/pre>\n<p>SO I REMOVE &#8216;replace&#8217; AND THE VALUES IN {} IN composer.json<br \/>\nThen run &#8216;composer update&#8217; again.<br \/>\nStart the server again: php yii serve &#8211;port=8888<br \/>\nOpen it on the browser: http:\/\/localhost:8888\/<br \/>\nNOW IT&#8217;S WORKING FINE!<a href=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2019\/09\/yii2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-4811\" src=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2019\/09\/yii2-1024x546.png\" alt=\"\" width=\"840\" height=\"448\" srcset=\"https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2019\/09\/yii2-1024x546.png 1024w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2019\/09\/yii2-300x160.png 300w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2019\/09\/yii2-768x410.png 768w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2019\/09\/yii2-1200x640.png 1200w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2019\/09\/yii2.png 1366w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ref: https:\/\/www.yiiframework.com\/ https:\/\/www.yiiframework.com\/doc\/guide\/2.0\/en\/start-installation How to install Yii PHP Framework on Debian 9 and Ubuntu 18.04? Create a Yii2 project &#8216;yii2-kickstart&#8217; via composer: composer create-project &#8211;prefer-dist &#8211;no-dev yiisoft\/yii2-app-basic yii2-kickstart Go to the project dir then modify composer.json to add &#8216;replace&#8217; like this: { &#8220;name&#8221;: &#8220;yiisoft\/yii2-app-basic&#8221;, &#8230; &#8220;replace&#8221;: { &#8220;bower-asset\/jquery&#8221;: &#8220;&gt;=1.11.0&#8221;, &#8220;bower-asset\/inputmask&#8221;: &#8220;&gt;=3.2.0&#8221;, &#8220;bower-asset\/punycode&#8221;: &#8220;&gt;=1.3.0&#8221;, &#8220;bower-asset\/yii2-pjax&#8221;: &#8220;&gt;=2.0.0&#8221; &hellip; <a href=\"https:\/\/myprojects.advchaweb.com\/index.php\/2019\/09\/22\/yii2\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Yii2&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105],"tags":[],"class_list":["post-4806","post","type-post","status-publish","format-standard","hentry","category-yii2"],"_links":{"self":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/4806","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/comments?post=4806"}],"version-history":[{"count":6,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/4806\/revisions"}],"predecessor-version":[{"id":4813,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/4806\/revisions\/4813"}],"wp:attachment":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/media?parent=4806"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/categories?post=4806"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/tags?post=4806"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}