{"id":1405,"date":"2021-06-19T23:17:45","date_gmt":"2021-06-19T14:17:45","guid":{"rendered":"https:\/\/417.run\/?p=1405"},"modified":"2021-10-15T00:00:12","modified_gmt":"2021-10-14T15:00:12","slug":"cakephp4-const","status":"publish","type":"post","link":"https:\/\/417.run\/pg\/php\/cakephp4\/cakephp4-const\/","title":{"rendered":"CakePHP4\u3067\u5b9a\u6570\u3092\u5b9a\u7fa9\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>cakephp4\u3067\u5b9a\u6570\u5b9a\u7fa9\u3092\u3069\u3046\u3059\u3079\u304d\u306a\u306e\u304b\u306a\u3068\u8003\u3048\u305f\u3068\u304d\u306b\u3001<br \/>\n\u516c\u5f0f\u306b\u8a18\u8f09\u304c\u3042\u3063\u305f\u306e\u3067\u3001\u305d\u308c\u3092\u4eca\u56de\u306f\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_17 counter-hierarchy counter-decimal ez-toc-grey\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\">\u76ee\u6b21<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class=\"ez-toc-list ez-toc-list-level-1\"><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/417.run\/pg\/php\/cakephp4\/cakephp4-const\/#%E5%AE%9A%E6%95%B0%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%82%92%E4%BD%9C%E6%88%90\" title=\"\u5b9a\u6570\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\">\u5b9a\u6570\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/417.run\/pg\/php\/cakephp4\/cakephp4-const\/#%E5%AE%9A%E6%95%B0%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%82%92%E8%AA%AD%E3%81%BF%E8%BE%BC%E3%82%80\" title=\"\u5b9a\u6570\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3080\">\u5b9a\u6570\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3080<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/417.run\/pg\/php\/cakephp4\/cakephp4-const\/#%E5%AE%9A%E6%95%B0%E3%81%AE%E5%91%BC%E3%81%B3%E5%87%BA%E3%81%97%E6%96%B9\" title=\"\u5b9a\u6570\u306e\u547c\u3073\u51fa\u3057\u65b9\">\u5b9a\u6570\u306e\u547c\u3073\u51fa\u3057\u65b9<\/a><ul class=\"ez-toc-list-level-3\"><li class=\"ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/417.run\/pg\/php\/cakephp4\/cakephp4-const\/#%E7%B5%90%E6%9E%9C\" title=\"\u7d50\u679c\">\u7d50\u679c<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/417.run\/pg\/php\/cakephp4\/cakephp4-const\/#%E7%89%B9%E5%AE%9A%E3%81%AE%E5%A0%B4%E6%89%80%E3%81%A7Configure%E3%82%92%E6%9B%B8%E3%81%8D%E3%81%9F%E3%81%84%E5%A0%B4%E5%90%88\" title=\"\u7279\u5b9a\u306e\u5834\u6240\u3067Configure\u3092\u66f8\u304d\u305f\u3044\u5834\u5408\">\u7279\u5b9a\u306e\u5834\u6240\u3067Configure\u3092\u66f8\u304d\u305f\u3044\u5834\u5408<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"%E5%AE%9A%E6%95%B0%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%82%92%E4%BD%9C%E6%88%90\"><\/span>\u5b9a\u6570\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u307e\u305aconfig\u306bconst.php\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u308a\u307e\u3059\u3002\u540d\u524d\u306f\u4f55\u3067\u3082\u3088\u3044\u3067\u3059\u3002<br \/>\nconfig\/const.php<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\n\/\/ define\u306e\u5834\u5408\ndefine(&#039;OKOME&#039;, &#039;\u767d\u7c73&#039;);\n\n\/\/ Configure\u306e\u5834\u5408\nreturn [\n    &#039;test1&#039; =&gt; [\n        &#039;test2&#039; =&gt; &#039;\u304a\u7c73&#039;,\n    ],\n    &#039;test3&#039; =&gt; &#039;\u6fc0\u304a\u7c73&#039;,\n];<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"%E5%AE%9A%E6%95%B0%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%82%92%E8%AA%AD%E3%81%BF%E8%BE%BC%E3%82%80\"><\/span>\u5b9a\u6570\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3080<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>config\/bootstrap.php<\/p>\n<pre><code class=\"language-php\">\/*\n * Read configuration file and inject configuration into various\n * CakePHP classes.\n *\n * By default there is only one configuration file. It is often a good\n * idea to create multiple configuration files, and separate the configuration\n * that changes from configuration that does not. This makes deployment simpler.\n *\/\ntry {\n    Configure::config(&#039;default&#039;, new PhpConfig());\n    Configure::load(&#039;app&#039;, &#039;default&#039;, false);\n\n    \/\/ \u5b9a\u6570\u5b9a\u7fa9\u30d5\u30a1\u30a4\u30eb\u3092\u8ffd\u52a0\n    Configure::load(&#039;const&#039;, &#039;default&#039;);\n\n} catch (\\Exception $e) {\n    exit($e-&gt;getMessage() . &quot;\\n&quot;);\n}<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"%E5%AE%9A%E6%95%B0%E3%81%AE%E5%91%BC%E3%81%B3%E5%87%BA%E3%81%97%E6%96%B9\"><\/span>\u5b9a\u6570\u306e\u547c\u3073\u51fa\u3057\u65b9<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<pre><code class=\"language-php\">echo OKOME;\necho Configure::read(test1.test2);\necho Configure::read(test3);<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"%E7%B5%90%E6%9E%9C\"><\/span>\u7d50\u679c<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre><code>\u767d\u7c73\n\u304a\u7c73\n\u6fc0\u304a\u7c73<\/code><\/pre>\n<p>\u5f15\u6570\u306a\u3057\u3067\u547c\u3076\u3068\u914d\u5217\u3068\u3057\u3066\u5168\u90e8\u53d6\u5f97\u3055\u308c\u308b<\/p>\n<pre><code class=\"language-php\">Configure::read()<\/code><\/pre>\n<a href=\"https:\/\/book.cakephp.org\/4\/ja\/development\/configuration.html#id3\" target=\"_blank\" rel=\"external noopener noreferrer\">CakePHP\u516c\u5f0f<\/a>\n<h2><span class=\"ez-toc-section\" id=\"%E7%89%B9%E5%AE%9A%E3%81%AE%E5%A0%B4%E6%89%80%E3%81%A7Configure%E3%82%92%E6%9B%B8%E3%81%8D%E3%81%9F%E3%81%84%E5%A0%B4%E5%90%88\"><\/span>\u7279\u5b9a\u306e\u5834\u6240\u3067Configure\u3092\u66f8\u304d\u305f\u3044\u5834\u5408<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<pre><code class=\"language-php\">Configure::write(&#039;test1&#039;, [\n    [\n        &#039;test2&#039; =&gt; &#039;\u304a\u7c73&#039;,\n    ],\n    &#039;test3&#039; =&gt; &#039;\u6fc0\u304a\u7c73&#039;,\n]);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>cakephp4\u3067\u5b9a\u6570\u5b9a\u7fa9\u3092\u3069\u3046\u3059\u3079\u304d\u306a\u306e\u304b\u306a\u3068\u8003\u3048\u305f\u3068\u304d\u306b\u3001 \u516c\u5f0f\u306b\u8a18\u8f09\u304c\u3042\u3063\u305f\u306e\u3067\u3001\u305d\u308c\u3092\u4eca\u56de\u306f\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002 \u76ee\u6b21 \u5b9a\u6570\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u5b9a\u6570\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3080\u5b9a\u6570\u306e\u547c\u3073\u51fa\u3057\u65b9\u7d50\u679c\u7279\u5b9a\u306e\u5834\u6240\u3067Configure\u3092\u66f8\u304d\u305f &#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[58],"tags":[],"class_list":{"0":"post-1405","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-cakephp4","7":"nothumb"},"_links":{"self":[{"href":"https:\/\/417.run\/wp-json\/wp\/v2\/posts\/1405"}],"collection":[{"href":"https:\/\/417.run\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/417.run\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/417.run\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/417.run\/wp-json\/wp\/v2\/comments?post=1405"}],"version-history":[{"count":8,"href":"https:\/\/417.run\/wp-json\/wp\/v2\/posts\/1405\/revisions"}],"predecessor-version":[{"id":1832,"href":"https:\/\/417.run\/wp-json\/wp\/v2\/posts\/1405\/revisions\/1832"}],"wp:attachment":[{"href":"https:\/\/417.run\/wp-json\/wp\/v2\/media?parent=1405"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/417.run\/wp-json\/wp\/v2\/categories?post=1405"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/417.run\/wp-json\/wp\/v2\/tags?post=1405"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}