{"id":18728,"date":"2015-12-07T02:01:21","date_gmt":"2015-12-06T16:01:21","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=18728"},"modified":"2015-12-07T05:46:48","modified_gmt":"2015-12-06T19:46:48","slug":"yii-mvc-php-framework-hello-world-content-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/yii-mvc-php-framework-hello-world-content-tutorial\/","title":{"rendered":"Yii MVC PHP Framework Hello World Content Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Yii\/\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"Yii MVC PHP Framework Hello World Content Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Yii\/yii2_hello_world-54of.jpg\" title=\"Yii MVC PHP Framework Hello World Content Tutorial\"  id=\"xilrb\" onmouseover=\" this.src=this.src.replace('-46of.jpg','-47of.xjpg').replace('-47of.jpg','-55of.xjpg').replace('-55of.jpg','-54of.xjpg').replace('-39of.jpg','-46of.xjpg').replace('-55of.jpg','-35of.xjpg').replace('-35of.jpg','-36of.xjpg').replace('-36of.jpg','-37of.xjpg').replace('-37of.jpg','-38of.xjpg').replace('-38of.jpg','-39of.xjpg').replace('.x','.'); \"  \/><\/a><p class=\"wp-caption-text\">Yii MVC PHP Framework Hello World Content Tutorial<\/p><\/div>\n<p>Yesterday, with <a target=_blank title='Yii MVC PHP Framework Hello World Tutorial' href='#ympfhwt'>Yii MVC PHP Framework Hello World Tutorial<\/a> as shown below, it was a primer tutorial mainly concerned with the setup and installation of a Hello World scenario regarding &#8230;<\/p>\n<blockquote>\n<blockquote><p>\nYii is an open source, object-oriented, component-based MVC PHP web application framework.  Yii is pronounced as &#8220;Yee&#8221; or [ji:] and in Chinese it means &#8220;simple and evolutionary&#8221; and it can be acronym for &#8220;Yes It Is!&#8221;.\n<\/p><\/blockquote>\n<p>The <a target=_blank title='MVC information via Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Model%E2%80%93view%E2%80%93controller'>MVC<\/a> stands for Model View Controller &#8230; (from Wikipedia again) &#8230;<\/p>\n<blockquote><p>\nModel\u2013view\u2013controller (MVC) is a software architectural pattern mostly for implementing user interfaces.\n<\/p><\/blockquote>\n<\/blockquote>\n<p> &#8230; to refresh your mind take a look at <a href=\"#\" onmouseover=\"this.style.backgroundColor='green'; document.getElementById('zxli9').style.display='inline'; \" onclick=\"this.style.backgroundColor='green'; document.getElementById('zxli9').style.display='inline'; \" style=\"background-color: green;\">\u2139<img decoding=\"async\" id=\"zxli9\" style=\"display: none;\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Yii\/yii2_hello_world-46of.jpg\"><\/a>, whereas today, we show some early steps with Yii use that use MVC (without the Model) to change the content, and therefore, the appearance of our local MAMP Apache web server&#8217;s Hello World website &#8230; and you&#8217;ll be pleased to know the word &#8220;Hello&#8221; makes an appearance &#8230; no, <a target=_blank title='Hello' href='https:\/\/www.youtube.com\/watch?v=84RxK4N1wfE'><strike>Lionel<\/strike><\/a>.<\/p>\n<p>Along the way we use Apache <i>.htaccess<\/i> methods making use of <i>mod_rewrite<\/i> module, which we hope, if you are following this, you are using.<\/p>\n<p>Again, we have to thank the incredible advice on great advice of <a target=_blank href='http:\/\/code.tutsplus.com\/tutorials\/how-to-program-with-yii2-getting-started--cms-22440' title='Yii Hello World useful link'>How to Program with Yii2: Getting Started &#8211; Envato Tuts+ Code Tutorial<\/a> to keep us on the straight and narrow.<\/p>\n<p>So, what do we do today, after yesterday&#8217;s installing and configuration with Yii, regarding content?<\/p>\n<ol>\n<li>we change ~\/Sites\/hello\/config\/web.php (add into components array) &#8230;<br \/>\n<code><br \/>\n  'urlManager' =&gt; [<br \/>\n          'showScriptName' =&gt; false,<br \/>\n          'enablePrettyUrl' =&gt; true<br \/>\n                  ],<br \/>\n<\/code>  &#8230; and add a new ~\/Sites\/hello\/web\/.htaccess (in the same directory as index.php (of the website)) &#8230;<br \/>\n<code><br \/>\nRewriteEngine on<br \/>\n<br \/>\n# If a directory or a file exists, use it directly<br \/>\nRewriteCond %{REQUEST_FILENAME} !-f<br \/>\nRewriteCond %{REQUEST_FILENAME} !-d<br \/>\n# Otherwise forward it to index.php<br \/>\nRewriteRule . index.php<br \/>\n<\/code> &#8230; via (advice of) Turning on Pretty URLs section of <a target=_blank href='http:\/\/code.tutsplus.com\/tutorials\/how-to-program-with-yii2-getting-started--cms-22440' title='Yii Hello World useful link'>How to Program with Yii2: Getting Started &#8211; Envato Tuts+ Code Tutorial<\/a> &#8230;<br \/>\n&#8230; <a href=\"#\" onmouseover=\"this.style.backgroundColor='green'; document.getElementById('zxli0').style.display='inline'; \" onclick=\"this.style.backgroundColor='green'; document.getElementById('zxli0').style.display='inline'; \" style=\"background-color: green;\">\u2139<img decoding=\"async\" id=\"zxli0\" style=\"display: none;\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Yii\/yii2_hello_world-47of.jpg\"><\/a><\/li>\n<li>point your web browser at &#8230;<br \/>\n<code>http:\/\/localhost:8888\/hello\/web\/site\/about<\/code> &#8230; <a href=\"#\" onmouseover=\"this.style.backgroundColor='green'; document.getElementById('zxli4').style.display='inline'; \" onclick=\"this.style.backgroundColor='green'; document.getElementById('zxli4').style.display='inline'; \" style=\"background-color: green;\">\u2139<img decoding=\"async\" id=\"zxli4\" style=\"display: none;\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Yii\/yii2_hello_world-55of.jpg\"><\/a><\/li>\n<li>we change ~\/Sites\/hello\/controller\/SiteController.php (add in the PHP public function RE: mvC) &#8230;<br \/>\n<code><br \/>\npublic function actionSay($target = 'World') {<br \/>\n    return $this-&gt;render('say', ['target' =&gt; $target]);<br \/>\n}    <\/code>  &#8230; and add a new ~\/Sites\/hello\/views\/site\/say.php (RE: mVc) &#8230;<br \/>\n<code><br \/>\n&lt;?php<br \/>\nuse yii\\helpers\\Html;<br \/>\n?&gt;<br \/>\n&lt;h1&gt;Hello &lt;?= Html::encode($target) ?&gt;&lt;\/h1&gt;<br \/>\n&lt;p&gt;Welcome to your Yii 2 demonstration application.&lt;\/p&gt;<br \/>\n<\/code> &#8230; via (advice of) Building the Say Hello World! Action section of <a target=_blank href='http:\/\/code.tutsplus.com\/tutorials\/how-to-program-with-yii2-getting-started--cms-22440' title='Yii Hello World useful link'>How to Program with Yii2: Getting Started &#8211; Envato Tuts+ Code Tutorial<\/a> &#8230;<br \/>\n&#8230; <a href=\"#\" onmouseover=\"this.style.backgroundColor='green'; document.getElementById('zxli6').style.display='inline'; \" onclick=\"this.style.backgroundColor='green'; document.getElementById('zxli6').style.display='inline'; \" style=\"background-color: green;\">\u2139<img decoding=\"async\" id=\"zxli6\" style=\"display: none;\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Yii\/yii2_hello_world-55of.jpg\"><\/a><\/li>\n<li>point your web browser at &#8230;<br \/>\n<code>http:\/\/localhost:8888\/hello\/web\/site\/say?target=Tuts%20Readers<\/code> &#8230; <a href=\"#\" onmouseover=\"this.style.backgroundColor='green'; document.getElementById('zxli8').style.display='inline'; \" onclick=\"this.style.backgroundColor='green'; document.getElementById('zxli8').style.display='inline'; \" style=\"background-color: green;\">\u2139<img decoding=\"async\" id=\"zxli8\" style=\"display: none;\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Yii\/yii2_hello_world-54of.jpg\"><\/a><\/li>\n<\/ol>\n<p>Here&#8217;s a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Yii\/\" title='click picture'>slideshow<\/a> of highlights of yesterday&#8217;s (setup and configuration and install) and today&#8217;s (content considerations for) a Hello World website created using the Yii 2 MVC PHP framework.<\/p>\n<hr>\n<p id='ympfhwt'>Previous <a target=_blank title='Yii MVC PHP Framework Hello World Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/yii-mvc-php-framework-hello-world-tutorial\/'>Yii MVC PHP Framework Hello World Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Yii\/\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"Yii MVC PHP Framework Hello World Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Yii\/yii2_hello_world-39of.jpg\" title=\"Yii MVC PHP Framework Hello World Primer Tutorial\"  id=\"xilrb\" onmouseover=\" this.src=this.src.replace('-39of.jpg','-35of.xjpg').replace('-35of.jpg','-36of.xjpg').replace('-36of.jpg','-37of.xjpg').replace('-37of.jpg','-38of.xjpg').replace('-38of.jpg','-39of.xjpg').replace('.x','.'); \"  \/><\/a><p class=\"wp-caption-text\">Yii MVC PHP Framework Hello World Tutorial<\/p><\/div>\n<p>Today&#8217;s tutorial is a Hello World tutorial for <a target=_blank title='Yii landing page' href='http:\/\/www.yiiframework.com\/'>Yii<\/a>, to quote <a target=_blank title='Yii information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Yii'>Wikipedia<\/a> &#8230;<\/p>\n<blockquote><p>\nYii is an open source, object-oriented, component-based MVC PHP web application framework.  Yii is pronounced as &#8220;Yee&#8221; or [ji:] and in Chinese it means &#8220;simple and evolutionary&#8221; and it can be acronym for &#8220;Yes It Is!&#8221;.\n<\/p><\/blockquote>\n<p>The <a target=_blank title='MVC information via Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Model%E2%80%93view%E2%80%93controller'>MVC<\/a> stands for Model View Controller &#8230; (from Wikipedia again) &#8230;<\/p>\n<blockquote><p>\nModel\u2013view\u2013controller (MVC) is a software architectural pattern mostly for implementing user interfaces.\n<\/p><\/blockquote>\n<p>It makes a fair bit of difference what version you talk about with Yii, and we are talking about Yii 2 today.<\/p>\n<p>You can get up and going with a Hello World level of Yii usage really quickly (especially with the great advice of <a target=_blank href='http:\/\/code.tutsplus.com\/tutorials\/how-to-program-with-yii2-getting-started--cms-22440' title='Yii Hello World useful link'>How to Program with Yii2: Getting Started &#8211; Envato Tuts+ Code Tutorial<\/a> &#8230; thanks), and we can say, basically that the major steps for us, integrating it with <a target=_blank title='MAMP Apache web server for Mac landing page' href='http:\/\/mamp.info'>MAMP<\/a> (Mac Apache local web server) and a Linux operating system involved &#8230;<\/p>\n<ol>\n<li>installing <a target=_blank title='Tool for dependency management in PHP' href='https:\/\/getcomposer.org\/'>composer<\/a>, a tool for dependency management in PHP, via &#8230;<br \/>\n<code><br \/>\ncurl -sS https:\/\/getcomposer.org\/installer | sudo php -- --install-dir=\/usr\/bin<br \/>\ncomposer global require \"fxp\/composer-asset-plugin:~1.1.1\"<br \/>\ncomposer require yiisoft\/yii2<br \/>\nsudo ln -s \/usr\/bin\/composer.phar \/usr\/bin\/composer<\/code><br \/>\n&#8230; <a href=\"#\" onmouseover=\"this.style.backgroundColor='green'; document.getElementById('xli0').style.display='inline'; \" onclick=\"this.style.backgroundColor='green'; document.getElementById('xli0').style.display='inline'; \" style=\"background-color: green;\">\u2139<img decoding=\"async\" id=\"xli0\" style=\"display: none;\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Yii\/yii2_hello_world-35of.jpg\"><\/a> &#8230; that can also be found on the <a target=_blank href='https:\/\/github.com\/' title='GitHib landing page'>GitHub<\/a> source repository<\/li>\n<li>composer setup specific to Hello World project &#8230;<br \/>\n<code><br \/>\ncd ~\/Sites<br \/>\ncomposer global require \"fxp\/composer-asset-plugin:1.0.0-beta2\"<br \/>\ncomposer create-project --prefer-dist yiisoft\/yii2-app-basic hello<\/code><br \/>\n&#8230; <a href=\"#\" onmouseover=\"this.style.backgroundColor='green'; document.getElementById('xli1').style.display='inline'; \" onclick=\"this.style.backgroundColor='green'; document.getElementById('xli1').style.display='inline'; \" style=\"background-color: green;\">\u2139<img decoding=\"async\" id=\"xli1\" style=\"display: none;\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Yii\/yii2_hello_world-36of.jpg\"><\/a> &#8230; in addition we found that we needed to &#8230;<br \/>\n<code><br \/>\nmkdir ~\/Sites\/hello\/vendor\/bower\/bootstrap<br \/>\nmkdir ~\/Sites\/hello\/vendor\/bower\/bootstrap\/dist<br \/>\nmkdir ~\/Sites\/hello\/vendor\/bower\/jquery<br \/>\nmkdir ~\/Sites\/hello\/vendor\/bower\/jquery\/dist<\/code><br \/>\n &#8230;  <a href=\"#\" onmouseover=\"this.style.backgroundColor='green'; document.getElementById('xli2').style.display='inline'; \" onclick=\"this.style.backgroundColor='green'; document.getElementById('xli2').style.display='inline'; \" style=\"background-color: green;\">\u2139<img decoding=\"async\" id=\"xli2\" style=\"display: none;\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Yii\/yii2_hello_world-38of.jpg\"><\/a><\/li>\n<li>create software to help out MAMP via &#8230;<br \/>\n<code><br \/>\ncd \/Applications\/MAMP\/htdocs<br \/>\nln -s ~\/Sites\/hello\/ \/Applications\/MAMP\/htdocs\/hello<\/code><br \/>\n &#8230;  <a href=\"#\" onmouseover=\"this.style.backgroundColor='green'; document.getElementById('xli3').style.display='inline'; \" onclick=\"this.style.backgroundColor='green'; document.getElementById('xli3').style.display='inline'; \" style=\"background-color: green;\">\u2139<img decoding=\"async\" id=\"xli3\" style=\"display: none;\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Yii\/yii2_hello_world-37of.jpg\"><\/a><\/li>\n<li>point your web browser at &#8230;<br \/>\n<code>http:\/\/localhost:8888\/hello\/web<\/code> &#8230; <a href=\"#\" onmouseover=\"this.style.backgroundColor='green'; document.getElementById('xli4').style.display='inline'; \" onclick=\"this.style.backgroundColor='green'; document.getElementById('xli4').style.display='inline'; \" style=\"background-color: green;\">\u2139<img decoding=\"async\" id=\"xli4\" style=\"display: none;\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Yii\/yii2_hello_world-39of.jpg\"><\/a><\/li>\n<\/ol>\n<p>You can do great organizational and fast and guaranteed and consistent PHP web work using Yii Framework.  Just imagine a <a target=_blank title='CRUD information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Create,_read,_update_and_delete'>CRUD<\/a> idea you have, and Yii could be a great option for you. Here&#8217;s a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Yii\/\" title='click picture'>slideshow<\/a> of highlights of today&#8217;s Hello World website create using the Yii 2 MVC PHP framework.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d18707' onclick='var dv=document.getElementById(\"d18707\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/mvc\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d18707' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d18728' onclick='var dv=document.getElementById(\"d18728\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/hello-world\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d18728' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Yesterday, with Yii MVC PHP Framework Hello World Tutorial as shown below, it was a primer tutorial mainly concerned with the setup and installation of a Hello World scenario regarding &#8230; Yii is an open source, object-oriented, component-based MVC PHP &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/yii-mvc-php-framework-hello-world-content-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/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":[12,37],"tags":[42,1751,249,462,495,558,611,664,707,714,723,744,824,932,1165,1404,1411,1421],"class_list":["post-18728","post","type-post","status-publish","format-standard","hentry","category-elearning","category-tutorials","tag-htaccess","tag-composer","tag-configuration","tag-framework","tag-github","tag-hello-world","tag-install","tag-json","tag-linux","tag-local-web-server","tag-mac","tag-mamp","tag-mvc","tag-php","tag-soft-link","tag-web-browser","tag-web-server","tag-website"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/18728"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=18728"}],"version-history":[{"count":4,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/18728\/revisions"}],"predecessor-version":[{"id":18732,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/18728\/revisions\/18732"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=18728"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=18728"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=18728"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}