{"id":4740,"date":"2013-11-06T22:18:47","date_gmt":"2013-11-06T13:18:47","guid":{"rendered":"http:\/\/www.webcyou.com\/?p=4740"},"modified":"2013-11-06T22:18:47","modified_gmt":"2013-11-06T13:18:47","slug":"%e3%80%90%e4%bf%9d%e5%ad%98%e7%89%88%e3%80%91mvc%e3%83%a2%e3%83%87%e3%83%ab%e3%81%aephp%e3%82%a2%e3%83%97%e3%83%aa%e3%82%b1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e4%bd%9c%e6%88%90-vagrant-smarty-ph","status":"publish","type":"post","link":"https:\/\/www.webcyou.com\/?p=4740","title":{"rendered":"\u3010\u4fdd\u5b58\u7248\u3011MVC\u30e2\u30c7\u30eb\u306ePHP\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u4f5c\u6210 (vagrant + Smarty + PHP)"},"content":{"rendered":"<p>\u4eca\u56de\u306fMVC\u30e2\u30c7\u30eb\u306ePHP\u30a2\u30d7\u30ea\u4f5c\u6210\u306b\u3064\u3044\u3066\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>MVC\u306b\u95a2\u3057\u3066\u306f\u3082\u3046\u3059\u3063\u304b\u308a\u304a\u99b4\u67d3\u307f\u304b\u3068\u601d\u308f\u308c\u307e\u3059\u304c\u3001\u8efd\u304f\u8aac\u660e\u3092\u3001<\/p>\n<p><strong>\u30fbModel\u00a0\u30e2\u30c7\u30eb<\/strong><\/p>\n<p><strong>\u30fbView\u00a0\u30d3\u30e5\u30fc<\/strong><\/p>\n<p><strong>\u30fbController\u00a0\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9<\/strong><\/p>\n<p>\u3068\u3001\uff13\u3064\u306e\u8981\u7d20\u3067\u8a2d\u8a08\u3067\u5b9f\u88c5\u3055\u308c\u308b\u65b9\u5f0f\u3067\u3059\u3002<\/p>\n<p>\u305d\u308c\u305e\u308c\u306e\u6982\u8981\u3092\u8aac\u660e\u3059\u308b\u3068\u3001Model\u306f\u60c5\u5831\u3084\u30e1\u30a4\u30f3\u306e\u51e6\u7406\u3092\u884c\u3046\u5f79\u5272\u3001View\u306f\u753b\u9762\u306b\u8868\u793a\u3055\u305b\u308b\u5f79\u5272\u3001Controller\u306f\u30e6\u30fc\u30b6\u30fc\u306e\u5165\u529b\u3084\u3001\u4f55\u3089\u304b\u306e\u51e6\u7406\u304c\u5fc5\u8981\u306a\u5834\u5408\u306fModel\u306b\u4f9d\u983c\u3057\u3001\u51fa\u529b\u304c\u5fc5\u8981\u306a\u5834\u5408\u306fView\u306b\u4f9d\u983c\u3059\u308b\u4e2d\u9593\u7684\u306a\u7acb\u5834\u3092\u3082\u3064\u5f79\u5272\u3002<\/p>\n<p>\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3089\u306e\u8a2d\u8a08\u3092\u7528\u3044\u3066\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u3067\u3042\u308bSmarty\u3092\u4f7f\u3044MVC\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u69cb\u7bc9\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>Smarty\u306e\u4f7f\u7528\u65b9\u6cd5\u7b49\u306b\u95a2\u3057\u3066\u306f<\/p>\n<h3><a href=\"https:\/\/www.webcyou.com\/?p=3914\">PHP \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3 Smarty \u4f7f\u7528\u65b9\u6cd5<\/a><\/h3>\n<p>\u3084\u3001\u516c\u5f0f\u30b5\u30a4\u30c8\u3067\u3042\u308b\u3053\u3061\u3089\u3092\u53c2\u7167\u3057\u3066\u9802\u3051\u308c\u3070\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p><strong>Smarty<\/strong><\/p>\n<p><a href=\"http:\/\/www.smarty.net\/docsv2\/ja\/\" target=\"_blank\">http:\/\/www.smarty.net\/docsv2\/ja\/<\/a><\/p>\n<p>Smarty + MVC\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u4f5c\u6210\u3092\u884c\u3046\u305f\u3081\u306b\u306f\u3001<\/p>\n<p>Model\u304c\u60c5\u5831\u3001\u51e6\u7406\u3092\u884c\u3044\u3001Controller\u304c\u30a4\u30d9\u30f3\u30c8\u3092\u611f\u77e5\u3057\u3001View\u304c\u8868\u793a\u3055\u305b\u308c\u308b\u69d8\u306b\u305d\u308c\u305e\u308c\u5206\u96e2\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u300c\u308f\u3056\u308f\u3056\u306a\u3093\u3067\u305d\u3093\u306a\u4e8b\u3092\u3002\u3002\u300d\u3068\u601d\u308f\u308c\u304c\u3061\u3067\u3059\u304c\u3001\u5927\u898f\u6a21\u306a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3068\u306a\u308b\u3068\u5206\u96e2\u3057\u305f\u3053\u3068\u306b\u3088\u3063\u3066\u6539\u4fee\u7b49\u3082\u5bb9\u6613\u306b\u884c\u3063\u3066\u884c\u304f\u3053\u3068\u304c\u53ef\u80fd\u3068\u306a\u3063\u3066\u304d\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306f\u66f4\u306b\u300chttp:\/\/hoge.jp\/?hoge=hoge\u300d\u306e\u69d8\u306bget\u3067\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u5206\u5c90\u3067\u306f\u306a\u304f\u3001<\/p>\n<p>\u300chttp:\/\/hoge.jp\/hoge\/hoge\u300d\u306e\u69d8\u306b\u300c\/\u300d\u3067\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u533a\u5207\u308b\u65b9\u6cd5\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<h4>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u69cb\u9020<\/h4>\n<p>\u4eca\u56de\u306f\u5206\u308a\u6613\u304f\u30eb\u30fc\u30c8\u76f4\u4e0b\u306b\u7f6e\u3044\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\/mvctest\r\n\/smarty<\/pre>\n<p>mvctest\u306b\u300cindex.php\u300d\u3092\u914d\u7f6e\u3002\u3053\u3053\u3092\u8d77\u70b9\u306b\u8272\u3005\u3068\u51e6\u7406\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<p>\u3055\u3089\u306b\u6307\u4ee4\u3092\u884c\u3046\u300cDispatcher.php\u300d\u3068\u8a2d\u5b9a\u3092\u884c\u3046\u300cutil.php\u300d\u3092\u7f6e\u304d\u307e\u3059\u3002<\/p>\n<p>\u66f4\u306b\u30b5\u30fc\u30d0\u30fc\u306e\u8a2d\u5b9a\u3092\u884c\u3046.htaccess\u3092\u914d\u7f6e\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/389e30720eb52ccd006f74d92ea9a628.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/389e30720eb52ccd006f74d92ea9a628.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-11-06 21.22.04\" width=\"175\" height=\"143\" class=\"alignnone size-full wp-image-4742\" \/><\/a><\/p>\n<p>\u66f4\u306b\u300ccontrollers\u300d\u300cmodel\u300d\u300cview\u300d\u306e\u5165\u3063\u305f\u300ctest\u300d\u3068\u3044\u3046\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u7f6e\u304d\u307e\u3057\u305f\u30fb<\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/d419cdd45c1c4d28fcc57dc7913d1bbd.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/d419cdd45c1c4d28fcc57dc7913d1bbd.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-11-06 21.23.12\" width=\"142\" height=\"82\" class=\"alignnone size-full wp-image-4741\" \/><\/a><\/p>\n<p>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u69cb\u9020\u306f<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nmvctest - .htaccess\r\n\u00a0 \u00a0 \u00a0 \u00a0 -\u00a0index.php\u00a0 \r\n\u00a0 \u00a0\u00a0 \u00a0 \u00a0- util.php\r\n        -\u00a0Dispatcher.php\r\n        | -\u00a0controllers\r\n \u00a0 \u00a0 \u00a0 \u00a0| -\u00a0model\r\n\u00a0\u00a0 \u00a0 \u00a0 \u00a0| -\u00a0view\r\nsmarty\r\n<\/pre>\n<p>\u3068\u306a\u3063\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<h4>.htaccess<\/h4>\n<p>\u307e\u305a\u3001\u30b5\u30fc\u30d0\u30fc\u306e\u8a2d\u5b9a\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nOptions +FollowSymLinks&lt;br \/&gt;RewriteEngine On\r\nRewriteCond %{REQUEST_FILENAME} !-d\r\nRewriteCond %{REQUEST_FILENAME} !-f\r\nRewriteRule ^(.*)$ \/mvctest\/ &#x5B;QSA,L]\r\n<\/pre>\n<p>\u3053\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u3066\u3001\u30d5\u30a1\u30a4\u30eb\u304c\u306a\u3044\u5834\u5408\u3067\u3082\u30b5\u30fc\u30d0\u30fc\u30a8\u30e9\u30fc\u3092\u51fa\u3055\u306a\u3044\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>.htaccess\u3092\u8a2d\u5b9a\u3059\u308b\u5834\u5408\u3001Apache\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3067\u3042\u308b httpd.conf \u306e<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&lt;Directory \/&gt;\r\n Options FollowSymLinks\r\n AllowOverride None\r\n&lt;\/Directory&gt;<\/pre>\n<p>\u3060\u3068\u53cd\u6620\u3055\u308c\u306a\u3044\u306e\u3067\u3001<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&lt;Directory \/&gt;\r\n  Options FollowSymLinks\r\n  AllowOverride All\r\n&lt;\/Directory&gt;<\/pre>\n<p>\u306b\u5909\u66f4\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<h4>index.php<\/h4>\n<p>\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u8d77\u70b9\u306bphp\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3093\u3067\u3044\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\nini_set('display_errors', 1);\r\n\r\nrequire_once 'Dispatcher.php';\r\nrequire_once 'util.php';\r\n\r\n$dispatcher = new Dispatcher();\r\nIncludePathSetting($dispatcher);\r\n\r\n\/\/apache\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u30eb\u30fc\u30c8\u304b\u3089\u4f55\u968e\u5c64\u76ee\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306bMVC\u30a2\u30d7\u30ea\u3092\u914d\u5099\u3059\u308b\u304b\u3002\r\n\/\/\u30eb\u30fc\u30c8\u30920\u3068\u3059\u308b\u3068\u3001mvctest\/ \u914d\u4e0b\u306f1\u968e\u5c64\u76ee\u306b\u5f53\u305f\u308b\u306e\u3067\u30011\u3068\u3059\u308b\u3002\r\n$dispatcher-&gt;setPramLevel(1);\r\n$dispatcher-&gt;dispatch();\r\n\r\n?&gt;<\/pre>\n<p>setPramLevel\u3067\u4f55\u968e\u5c64\u306b\u914d\u7f6e\u3057\u3066\u3042\u308b\u304b\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<h4>Dispatcher.php<\/h4>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&lt;?php\r\nclass Dispatcher\r\n{\r\n    private $sysRoot;\r\n    \/\/URL\u306e\u968e\u5c64\u8a2d\u5b9a\u3002\u3069\u306e\u968e\u5c64\u304b\u3089\u3092\u30d1\u30e9\u30e1\u30fc\u30bf\u3068\u3057\u3066\u89e3\u91c8\u3059\u308b\u304b\u3002\r\n    \/\/ \/\u76f4\u4e0b\u306b\u7f6e\u304f\u306a\u30890, \/test\/\u4ee5\u4e0b\u306b\u7f6e\u304f\u306a\u30891, \/test\/hoge\/\u4ee5\u4e0b\u306b\u7f6e\u304f\u306a\u30892\r\n    private $paramLevel=1; \r\n\r\n    public function setSystemRoot($path)\r\n    {\r\n        $this-&gt;sysRoot = rtrim($path, '\/');\r\n    }\r\n\r\n    \/**\r\n     * URL\u306e\u968e\u5c64\u8a2d\u5b9a\u3002\u3069\u306e\u968e\u5c64\u304b\u3089\u3092\u30d1\u30e9\u30e1\u30fc\u30bf\u3068\u3057\u3066\u89e3\u91c8\u3059\u308b\u304b\u3002\r\n     * @param int $iLevel\r\n     *\/\r\n    public function setPramLevel($iLevel) {\r\n        $this-&gt;paramLevel=$iLevel;\r\n    }\r\n\r\n    public function dispatch()\r\n    {\r\n        $params_tmp = array();\r\n        \/\/?\u3067\u5206\u5272\u3002GET\u30d1\u30e9\u30fc\u30bf\u3092\u7121\u8996\u3059\u308b\u305f\u3081\r\n        $params_tmp = explode('?', $_SERVER&#x5B;'REQUEST_URI']);\r\n        \/\/ \u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u53d6\u5f97\uff08\u672b\u5c3e,\u5148\u982d\u306e \/ \u306f\u524a\u9664\uff09\r\n        $params_tmp&#x5B;0] = ereg_replace('\/?$', '', $params_tmp&#x5B;0]);\r\n        $params_tmp&#x5B;0] = ereg_replace('^\/*', '', $params_tmp&#x5B;0]);\r\n        $params = array();\r\n        if ('' != $params_tmp&#x5B;0]) {\r\n            \/\/ \u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u3092 \/ \u3067\u5206\u5272\r\n            $params = explode('\/', $params_tmp&#x5B;0]);\r\n        }\r\n        \r\n        \/\/ \uff11\u756a\u76ee\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u3092\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3068\u3057\u3066\u53d6\u5f97\r\n        $controller = &quot;index&quot;;\r\n        if ($this-&gt;paramLevel &lt; count($params)) {\r\n            $controller = $params&#x5B;$this-&gt;paramLevel];\r\n        }\r\n\r\n        \/\/ \u30d1\u30e9\u30e1\u30fc\u30bf\u3088\u308a\u53d6\u5f97\u3057\u305f\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u540d\u306b\u3088\u308a\u30af\u30e9\u30b9\u632f\u5206\u3051\r\n        $className = ucfirst(strtolower($controller)) . 'Controller';\r\n\r\n        \/\/ \u30af\u30e9\u30b9\u30d5\u30a1\u30a4\u30eb\u8aad\u8fbc\r\n        require_once $this-&gt;sysRoot . '\/controllers\/' . $className . '.php';\r\n\r\n        $url =&quot;\/&quot;;\r\n        for ($i = 0; $i &lt; $this-&gt;paramLevel; $i++) {\r\n            $url = $url . $params&#x5B;$i] . &quot;\/&quot;;\r\n        }\r\n        \/\/ \u30af\u30e9\u30b9\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u751f\u6210\r\n        $controllerInstance = new $className($url);\r\n        \r\n         \/\/ 2\u756a\u76ee\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u3092\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3068\u3057\u3066\u53d6\u5f97\r\n         $action= 'index';\r\n         \r\n         if ( ($this-&gt;paramLevel + 1) &lt; count($params)) {\r\n         $action= $params&#x5B;($this-&gt;paramLevel + 1)];\r\n         } \r\n        \/\/ \u30a2\u30af\u30b7\u30e7\u30f3\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u884c\r\n        $actionMethod = $action . 'Action';\r\n        $controllerInstance-&gt;$actionMethod();       \r\n    }\r\n}\r\n?&gt;<\/pre>\n<p>url\u3092\u53d6\u5f97\u3057\u3001\u8a72\u5f53\u3059\u308bcontroller\u3092\u547c\u3073\u51fa\u3057\u3001action\u3092\u5b9f\u884c\u3055\u305b\u308b\u30d5\u30a1\u30a4\u30eb\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<h4>util.php<\/h4>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&lt;?php\r\nfunction IncludePathSetting($dispatcher){\r\n    $path = '\/vagrant\/smarty\/libs\/';\r\n    \/\/$path .= PATH_SEPARATOR . '\/vagrant\/smarty\/libs\/ \u3068\u306f\u5225\u306b\u30a4\u30f3\u30af\u30eb\u30fc\u30c9\u3059\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3042\u308c\u3070\u6307\u5b9a\/';\r\n    $dispatcher-&gt;setSystemRoot('\/vagrant\/mvctest\/test\/');        \r\n    set_include_path(get_include_path() . PATH_SEPARATOR . $path); \r\n}\r\n?&gt;<\/pre>\n<p>\u8a2d\u5b9a\u3092\u884c\u3046\u30d5\u30a1\u30a4\u30eb\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u8a72\u5f53\u3059\u308b\u30d1\u30b9\u306b\u5909\u66f4\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h4>controllers<\/h4>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&lt;?php\r\nrequire_once( 'test\/model\/HogeModel.php' );\r\nrequire_once('Smarty.class.php');\r\n\r\nclass IndexController\r\n{\r\n    \/\/\u30ea\u30af\u30a8\u30b9\u30c8\r\n    private $request;\r\n    \/\/\u30e2\u30c7\u30eb\r\n    private $model;\r\n    \/\/\u30d3\u30e5\u30fc(Smarty\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9)\r\n    private $view;\r\n    \/\/\u30d3\u30e5\u30fc\u3067\u8868\u793a\u3059\u308bURL\r\n    private $url;\r\n\r\n    \/\/ \u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\r\n    public function __construct($url)\r\n    {\r\n        \/\/ \u30ea\u30af\u30a8\u30b9\u30c8\r\n        \/\/$this-&gt;request = new Request();\r\n        \/\/\u30e2\u30c7\u30eb\u3092\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5316(\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30681:1\u306e\u30d1\u30bf\u30fc\u30f3)\r\n        $this-&gt;model = new HogeModel();\r\n        \/\/\u30d3\u30e5\u30fc\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5316\r\n        $this-&gt;view = new Smarty();\r\n        \/\/Smarty\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u8a2d\u5b9a(\u30ad\u30e3\u30c3\u30b7\u30e5\u3084\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u7f6e\u304d\u5834\u306a\u3069)\r\n        $this-&gt;view-&gt;template_dir = &quot;test\/view\/templates&quot;;\r\n        $this-&gt;view-&gt;compile_dir = &quot;test\/view\/templates_c&quot;;\r\n        $this-&gt;view-&gt;cache_dir =&quot;test\/view\/cache&quot;;\r\n        \/\/Smarty\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u30bb\u30c3\u30c8\u3059\u308b\u30d1\u30b9\r\n        $this-&gt;url = $url;\r\n        \/\/HTML\u304b\u3089\u53c2\u7167\u3059\u3079\u304d\u5916\u90e8\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9\u8a2d\u5b9a(URL\u3092\/\u533a\u5207\u308a\u306b\u3059\u308b\u3068\u30d1\u30b9\u304c\u5909\u308f\u308b\u305f\u3081)\r\n        $this-&gt;view-&gt;assign(&quot;url&quot;,$this-&gt;url);\r\n    }\r\n\r\n    public function indexAction()\r\n    {\r\n        \r\n        \/\/http:\/\/localhost:8080\/mvctest\/ \u30a2\u30af\u30bb\u30b9\u6642\u306e\u51e6\u7406\r\n        \/\/\u30e2\u30c7\u30eb($this-&gt;model )\u306e\u4efb\u610f\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u884c\u3002\r\n        \/\/\u753b\u9762\u8868\u793a\r\n        $this-&gt;view-&gt;display(&quot;hoge_index.tpl&quot;);\r\n    }\r\n}\r\n?&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p>\/mvctest\/\u3092\u30a2\u30af\u30bb\u30b9\u3057\u305f\u969b\u306b\u547c\u3073\u51fa\u3055\u308c\u308bcontroller\u30af\u30e9\u30b9\u3067\u3042\u308b\u300cIndexController\u300d\u306e\u30d5\u30a1\u30a4\u30eb\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\/mvctest\/hoge\u3092\u30a2\u30af\u30bb\u30b9\u3057\u305f\u969b\u3001\u5b9f\u884c\u3059\u308b\u3088\u3046\u306b\u3059\u308b\u306b\u306f\u3001index\u540c\u69d8<\/p>\n<p>HogeController.php\u3092\u4f5c\u6210\u3057\u3001class HogeController\u3001public function indexAction\u3092\u4f5c\u6210\u3059\u308c\u3070\u00a0\/mvctest\/hoge\u306e\u547c\u3073\u51fa\u3057\u5148\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\/mvctest\/hoge\/hogege \u306f\u4e0a\u8a18\u306econtroller\u306bpublic function hogegeAction\u3092\u8ffd\u52a0\u3059\u308b\u5f62\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<h4>Model<\/h4>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\nclass HogeModel\r\n{\r\n   \/\/\u5404\u51e6\u7406\u6bce\u306b\u30e1\u30bd\u30c3\u30c9\u3092\u4f5c\u6210\u3002\r\n}\r\n?&gt;\r\n<\/pre>\n<p>Model\u306b\u95a2\u3057\u3066\u306f\u3001\u4eca\u56de\u7279\u306b\u8a18\u8ff0\u3057\u3066\u304a\u308a\u307e\u305b\u3093\u3002<\/p>\n<h4>view<\/h4>\n<p>view\u306e\u4e2d\u8eab\u306f\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u306esmarty\u304c\u5b9f\u884c\u51fa\u6765\u308b\u3088\u3046\u306b\u300ccache\u300d\u300ctemplates\u300d\u300ctemplates\u300d\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/6665932b517c997845508af31a7e1adf.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/6665932b517c997845508af31a7e1adf.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-11-06 21.50.08\" width=\"148\" height=\"81\" class=\"alignnone size-full wp-image-4743\" \/><\/a><\/p>\n<p>templates\u5185\u306b tpl\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306f\u3001\u6700\u521d\u306b\u8868\u793a\u3055\u308c\u308b\u300choge_index.tpl\u300d\u3068\u3001\u300choge_disp.tpl\u300d\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<\/p>\n<p><strong>hoge_index.tpl<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&lt;p&gt;index\u30c6\u30b9\u30c8&lt;\/p&gt;<\/pre>\n<p><strong>hoge_disp.tpl<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&lt;p&gt;\u30c6\u30b9\u30c8\u3042\u3042\u3042\u3042\u3042\u3042\u3042&lt;\/p&gt;<\/pre>\n<p>\u3068\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<\/p>\n<h4>\u691c\u8a3c<\/h4>\n<p>\u3053\u3053\u307e\u3067\u3067\u3001\u4e00\u901a\u308a\u5b9f\u884c\u51fa\u6765\u308b\u307e\u3067\u306b\u306a\u308a\u307e\u3057\u305f\u306e\u3067\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<p><strong>http:\/\/localhost:8080\/mvctest\/ \u306b\u30a2\u30af\u30bb\u30b9\u3002<\/strong><\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/3c07ed19c39fa177414a6872d30699d1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/3c07ed19c39fa177414a6872d30699d1.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-11-06 21.56.08\" width=\"329\" height=\"162\" class=\"alignnone size-full wp-image-4744\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/3c07ed19c39fa177414a6872d30699d1.png 329w, https:\/\/www.webcyou.com\/wp-content\/uploads\/3c07ed19c39fa177414a6872d30699d1-300x147.png 300w\" sizes=\"auto, (max-width: 329px) 100vw, 329px\" \/><\/a><\/p>\n<p><strong>http:\/\/localhost:8080\/mvctest\/hoge \u306b\u30a2\u30af\u30bb\u30b9\u3002<\/strong><\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/836e241771bfb4eb34b26b3554e42785.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/836e241771bfb4eb34b26b3554e42785.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-11-06 21.56.18\" width=\"349\" height=\"150\" class=\"alignnone size-full wp-image-4745\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/836e241771bfb4eb34b26b3554e42785.png 349w, https:\/\/www.webcyou.com\/wp-content\/uploads\/836e241771bfb4eb34b26b3554e42785-300x128.png 300w\" sizes=\"auto, (max-width: 349px) 100vw, 349px\" \/><\/a><\/p>\n<p>\u3068\u305d\u308c\u305e\u308c\u306econtroller\u304c\u5b9f\u884c\u3055\u308c\u3001view\u304c\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u306e\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u305f\u3060\uff11\u70b9\u3001\u5b58\u5728\u3057\u306a\u3044url\u3092\u53e9\u304f\u3068\u3001controller\u304c\u5b9f\u884c\u3057\u30a8\u30e9\u30fc\u304c\u5410\u304d\u51fa\u3055\u308c\u3066\u3057\u307e\u3046\u306e\u3067\u3001\u4f8b\u5916\u51e6\u7406\u7b49\u306e\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/0b3eb15a0414f527351f5eb85f56fb5c.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/0b3eb15a0414f527351f5eb85f56fb5c.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-11-06 21.57.52\" width=\"385\" height=\"120\" class=\"alignnone size-full wp-image-4746\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/0b3eb15a0414f527351f5eb85f56fb5c.png 385w, https:\/\/www.webcyou.com\/wp-content\/uploads\/0b3eb15a0414f527351f5eb85f56fb5c-300x93.png 300w\" sizes=\"auto, (max-width: 385px) 100vw, 385px\" \/><\/a><\/p>\n<p>\u3068\u3001\u4e00\u65e6\u306f\u3053\u3053\u3067\u7d42\u308f\u3089\u305b\u3066\u9802\u304d\u307e\u3059\u3002<\/p>\n<p>\u6b21\u56de\u3001\u4f8b\u5916\u51e6\u7406\u3092\u5165\u308c\u305f\u306e\u3092\u7d39\u4ecb\u51fa\u6765\u308c\u3070\u306a\u3002\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u4eca\u56de\u3001\u3053\u308c\u3089\u306f\u3001<\/p>\n<p><a href=\"http:\/\/jehupc.exblog.jp\/19260662\/\" target=\"_blank\">http:\/\/jehupc.exblog.jp\/19260662\/<\/a><\/p>\n<p>\u3084\u3001<\/p>\n<p><a href=\"http:\/\/www.objective-php.net\" target=\"_blank\">http:\/\/www.objective-php.net<\/a><\/p>\n<p>\u3092\u53c2\u8003\u306b\u3055\u305b\u3066\u9802\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u826f\u8cea\u306a\u60c5\u5831\u3092\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u56de\u306fMVC\u30e2\u30c7\u30eb\u306ePHP\u30a2\u30d7\u30ea\u4f5c\u6210\u306b\u3064\u3044\u3066\u3068\u306a\u308a\u307e\u3059\u3002 MVC\u306b\u95a2\u3057\u3066\u306f\u3082\u3046\u3059\u3063\u304b\u308a\u304a\u99b4\u67d3\u307f\u304b\u3068\u601d\u308f\u308c\u307e\u3059\u304c\u3001\u8efd\u304f\u8aac\u660e\u3092\u3001 \u30fbModel\u00a0\u30e2\u30c7\u30eb \u30fbView\u00a0\u30d3\u30e5\u30fc \u30fbController\u00a0\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9 \u3068\u3001\uff13\u3064\u306e\u8981\u7d20 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[59,168,176,37,107,180,173,78,114,118],"class_list":["post-4740","post","type-post","status-publish","format-standard","hentry","category-php","tag-android-sdk","tag-html","tag-html5","tag-iphone-","tag-mamp","tag-mysql","tag-php","tag-78","tag-114","tag-118"],"_links":{"self":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/4740","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4740"}],"version-history":[{"count":1,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/4740\/revisions"}],"predecessor-version":[{"id":4747,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/4740\/revisions\/4747"}],"wp:attachment":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4740"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4740"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}