{"id":5006,"date":"2021-08-09T08:34:25","date_gmt":"2021-08-09T08:34:25","guid":{"rendered":"https:\/\/www.bearloga.space\/?page_id=5006"},"modified":"2021-08-09T08:34:26","modified_gmt":"2021-08-09T08:34:26","slug":"yii-konfiguraczii","status":"publish","type":"page","link":"https:\/\/www.bearloga.space\/en\/yii-konfiguraczii\/","title":{"rendered":"Yii \u2014 \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438\u043b\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445.&nbsp;\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043e\u0431\u044b\u0447\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442 \u0438\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.&nbsp;\u041e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0442\u0430\u043a\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php\n   $config = [\n      'class' =&gt; 'yii\\db\\Connection',\n      'dsn' =&gt; 'mysql:host = localhost;dbname = helloworld',\n      'username' =&gt; 'vladimir',\n      'password' =&gt; '12345',\n      'charset' =&gt; 'utf8',\n   ];\n   $db = Yii::createObject($config);\n?&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u041c\u0435\u0442\u043e\u0434&nbsp;<strong>Yii :: createObject ()<\/strong>&nbsp;\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043b\u0430\u0441\u0441\u0430, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0424\u043e\u0440\u043c\u0430\u0442 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u2014<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[\n   \/\/a fully qualified class name for the object being created\n   'class' =&gt; 'ClassName',\n   \/\/initial values for the named property\n   'propertyName' =&gt; 'propertyValue',\n   \/\/specifies what handlers should be attached to the object's events\n   'on eventName' =&gt; $eventHandler,\n   \/\/specifies what behaviors should be attached to the object\n   'as behaviorName' =&gt; $behaviorConfig,\n]<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0424\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u2014<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php\n   $params = require(__DIR__ . '\/params.php');\n   $config = [\n      'id' =&gt; 'basic',\n      'basePath' =&gt; dirname(__DIR__),\n      'bootstrap' =&gt; ['log'],\n      'components' =&gt; [\n         'request' =&gt; [\n            \/\/ !!! insert a secret key in the following (if it is empty) - this \n               \/\/is required by cookie validation\n            'cookieValidationKey' =&gt; 'ymoaYrebZHa8gURuolioHGlK8fLXCKjO',\n         ],\n         'cache' =&gt; [\n            'class' =&gt; 'yii\\caching\\FileCache',\n         ],\n         'user' =&gt; [\n            'identityClass' =&gt; 'app\\models\\User',\n            'enableAutoLogin' =&gt; true,\n         ],\n         'errorHandler' =&gt; [\n            'errorAction' =&gt; 'site\/error',\n         ],\n         'mailer' =&gt; [\n            'class' =&gt; 'yii\\swiftmailer\\Mailer',\n            \/\/ send all mails to a file by default. You have to set\n            \/\/ 'useFileTransport' to false and configure a transport\n            \/\/ for the mailer to send real emails.\n            'useFileTransport' =&gt; true,\n         ],\n         'log' =&gt; [\n            'traceLevel' =&gt; YII_DEBUG ? 3 : 0,\n            'targets' =&gt; [\n               [\n                  'class' =&gt; 'yii\\log\\FileTarget',\n                  'levels' =&gt; ['error', 'warning'],\n               ],\n            ],\n         ],\n         'urlManager' =&gt; [\n            \/\/'showScriptName' =&gt; false,\n            \/\/'enablePrettyUrl' =&gt; true,\n            \/\/'enableStrictParsing' =&gt; true,\n            \/\/'suffix' =&gt; '\/'\n         ],\n         'db' =&gt; require(__DIR__ . '\/db.php'),\n      ],\n      'modules' =&gt; [\n         'hello' =&gt; [\n            'class' =&gt; 'app\\modules\\hello\\Hello',\n         ],\n      ],\n      'params' =&gt; $params,\n   ];\n   if (YII_ENV_DEV) {\n      \/\/ configuration adjustments for 'dev' environment\n      $config['bootstrap'][] = 'debug';\n      $config['modules']['debug'] = [\n         'class' =&gt; 'yii\\debug\\Module',\n      ];\n      $config['bootstrap'][] = 'gii';\n      $config['modules']['gii'] = [\n         'class' =&gt; 'yii\\gii\\Module',\n      ];\n   }\n   return $config;\n?&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u0444\u0430\u0439\u043b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043c\u044b \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0438\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430.&nbsp;\u042d\u0442\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043c\u044b \u0443\u0436\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0435\u0433\u043e \u0432 \u0444\u0430\u0439\u043b\u0435&nbsp;<strong>index.php<\/strong>&nbsp;\u2014<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php\n   \/\/defining global constans\n   defined('YII_DEBUG') or define('YII_DEBUG', true);\n   defined('YII_ENV') or define('YII_ENV', 'dev');\n   \/\/register composer autoloader\n   require(__DIR__ . '\/..\/vendor\/autoload.php');\n   \/\/include yii files\n   require(__DIR__ . '\/..\/vendor\/yiisoft\/yii2\/Yii.php');\n   \/\/load application config\n   $config = require(__DIR__ . '\/..\/config\/web.php');\n   \/\/create, config, and process request\n   (new yii\\web\\Application($config))-&gt;run();\n?&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u041c\u043d\u043e\u0433\u0438\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u044b \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043a\u043e\u0434\u0435.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php\n   NavBar::begin([\n      'brandLabel' =&gt; 'My Company',\n      'brandUrl' =&gt; Yii::$app-&gt;homeUrl,\n      'options' =&gt; [\n         'class' =&gt; 'navbar-inverse navbar-fixed-top',\n      ],\n   ]);\n   echo Nav::widget([\n      'options' =&gt; ['class' =&gt; 'navbar-nav navbar-right'],\n      'items' =&gt; [\n         ['label' =&gt; 'Home', 'url' =&gt; ['\/site\/index']],\n         ['label' =&gt; 'About', 'url' =&gt; ['\/site\/about']],\n         ['label' =&gt; 'Contact', 'url' =&gt; ['\/site\/contact']],\n         Yii::$app-&gt;user-&gt;isGuest ?\n         ['label' =&gt; 'Login', 'url' =&gt; ['\/site\/login']] :\n         [\n            'label' =&gt; 'Logout (' . Yii::$app-&gt;user-&gt;identity-&gt;username . ')',\n            'url' =&gt; ['\/site\/logout'],\n            'linkOptions' =&gt; ['data-method' =&gt; 'post']\n         ],\n      ],\n   ]);\n   NavBar::end();\n?&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u041a\u043e\u0433\u0434\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043b\u043e\u0436\u043d\u0430, \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 PHP, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432.&nbsp;\u0412\u0437\u0433\u043b\u044f\u043d\u0438\u0442\u0435 \u043d\u0430 \u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438&nbsp;<strong>config \/ console.php<\/strong>&nbsp;\u2014<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php\n   Yii::setAlias('@tests', dirname(__DIR__) . '\/tests');\n\n   $params = require(__DIR__ . '\/params.php');\n   $db = require(__DIR__ . '\/db.php');\n\n   return [\n      'id' =&gt; 'basic-console',\n      'basePath' =&gt; dirname(__DIR__),\n      'bootstrap' =&gt; ['log', 'gii'],\n      'controllerNamespace' =&gt; 'app\\commands',\n      'modules' =&gt; [\n         'gii' =&gt; 'yii\\gii\\Module',\n      ],\n      'components' =&gt; [\n         'cache' =&gt; [\n            'class' =&gt; 'yii\\caching\\FileCache',\n         ],\n         'log' =&gt; [\n            'targets' =&gt; [\n               [\n                  'class' =&gt; 'yii\\log\\FileTarget',\n                  'levels' =&gt; ['error', 'warning'],\n               ],\n            ],\n         ],\n         'db' =&gt; $db,\n      ],\n      'params' =&gt; $params,\n   ];\n?&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u0432\u044b\u0437\u0432\u0430\u0432 \u043c\u0435\u0442\u043e\u0434&nbsp;<strong>Yii :: $ container-&gt; set ()<\/strong>&nbsp;.&nbsp;\u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043a\u043e \u0432\u0441\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430\u043c \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c&nbsp;<strong>Yii :: createObject ()<\/strong>&nbsp;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0441&nbsp;<strong>yii \\ widgets \\ LinkPager<\/strong>&nbsp;, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u043f\u0435\u0439\u0434\u0436\u0435\u0440\u044b \u0441\u0441\u044b\u043b\u043e\u043a \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u043b\u0438 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u0442\u0440\u0435\u0445 \u043a\u043d\u043e\u043f\u043e\u043a, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438\u043b\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445.&nbsp;\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043e\u0431\u044b\u0447\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442 \u0438\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.&nbsp;\u041e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0442\u0430\u043a\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[156],"tags":[],"class_list":["post-5006","page","type-page","status-publish","hentry","category-yii"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/pages\/5006","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/comments?post=5006"}],"version-history":[{"count":1,"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/pages\/5006\/revisions"}],"predecessor-version":[{"id":5007,"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/pages\/5006\/revisions\/5007"}],"wp:attachment":[{"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/media?parent=5006"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/categories?post=5006"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/tags?post=5006"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}