{"id":283488,"date":"2017-03-19T16:45:43","date_gmt":"2017-03-19T13:45:43","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=283488"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=283488","title":{"rendered":"\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0430\u0439\u0442\u0430 \u043d\u0430 Yii 2 (\u0431\u043b\u043e\u0433\u0430, basic) \u2014 \u0427\u0430\u0441\u0442\u044c 1"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d8a\/b34\/9e9\/d8ab349e9df8c9cfa142955afeafa919.jpg\" alt=\"image\"\/><\/p>\n<p>  \u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u042f \u043f\u043e\u043f\u044b\u0442\u0430\u044e\u0441\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0431\u043b\u043e\u0433\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Yii 2(basic) \u0432 \u0446\u0435\u043b\u044f\u0445 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u041f\u043e\u0447\u0435\u043c\u0443 basic? \u041f\u043e \u043c\u043e\u0435\u043c\u0443 \u043e\u043f\u044b\u0442\u0443 basic \u0432\u0435\u0440\u0441\u0438\u044f \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041f\u0435\u0440\u0435\u0434 \u043d\u0430\u0447\u0430\u043b\u043e\u043c \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u041f\u041e:<\/p>\n<ul>\n<li>web-c\u0435\u0440\u0432\u0435\u0440 c \u043c\u043e\u0434\u0443\u043b\u0435\u043c PHP \u0438 SQL \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0441\u0431\u043e\u0440\u043a\u0443 web-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 <a href=\"https:\/\/www.apachefriends.org\/ru\/download.html\">XAMPP<\/a>, \u043e\u043d \u043f\u0440\u043e\u0441\u0442 \u0432 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438, \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f..;<\/li>\n<li><a href=\"http:\/\/www.yiiframework.com\/download\/\">Basic \u0432\u0435\u0440\u0441\u0438\u044f Yii 2<\/a>. \u0414\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 Yii 2, \u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e <a href=\"https:\/\/ru.wikipedia.org\/wiki\/Composer\">Composer<\/a>(\u043f\u0430\u043a\u0435\u0442\u043d\u044b\u0439 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440). \u041e\u0432\u043b\u0430\u0434\u0435\u0432\u0430\u044f Composer-\u043e\u043c, \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u0432\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u0446\u0435\u043b\u0443\u044e \u043a\u0443\u0447\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 yii, \u043d\u043e \u0438 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c \u041f\u041e. \u0422.\u043a. Composer \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 yii \u0441 GitHub, <a href=\"http:\/\/sauron.org.ua\/post\/947\">Composer \u043f\u0440\u043e\u0441\u0438\u0442 token github<\/a>, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0430\u043a\u043a\u0430\u0443\u043d \u043d\u0430 GitHub, \u044d\u0442\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e.<\/li>\n<\/ul>\n<p>  \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438:<\/p>\n<ul>\n<li>\u0437\u043d\u0430\u043d\u0438\u0435 PHP \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u041e\u041e\u041f;<\/li>\n<li>\u0431\u0430\u0437\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u043d\u0438\u0435 SQL;<\/li>\n<li>\u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f IDE, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e PhpStorm;<\/li>\n<li>\u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/Model-View-Controller\">\u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u043c MVC<\/a>, \u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435\u043c Yii 2 \u0432\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u044f\u0437\u0430\u043d\u044b \u0437\u043d\u0430\u0442\u044c \u0447\u0442\u043e \u044d\u0442\u043e \u0442\u0430\u043a\u043e\u0435;<\/li>\n<li>\u044f \u0442\u0430\u043a\u0436\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 <a href=\"https:\/\/nix-tips.ru\/yii2-api-guides\/guide-ru-start-workflow.html\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439<\/a>, \u0441\u0430\u043c\u044b\u043c \u0432\u0430\u0436\u043d\u044b\u043c \u0431\u0443\u0434\u0435\u0442 <b>\u00ab\u041f\u0435\u0440\u0432\u043e\u0435 \u0417\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u043e\u00bb<\/b> \u0438 <b>\u00ab\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u00bb<\/b>, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435.<\/li>\n<\/ul>\n<p>  <\/p>\n<h2><strong>1) \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0411\u0414 \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446<\/strong><\/h2>\n<p>  \u0418\u0442\u0430\u043a, \u0432\u044b \u0442\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 Yii 2 basic, \u0432\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f.<br \/>  \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043d\u0430\u0447\u0430\u0442\u044c \u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0411\u0414, \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c MySQL \u0438 phpMyAdmin.<\/p>\n<p>  Yii \u043d\u0443\u0436\u043d\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0411\u0414, \u0437\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u043e\u0434\u0438\u043d \u0438\u0437 \u0444\u0430\u0439\u043b\u043e\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0432 <b>basic\\config\\db.php<\/b>:<\/p>\n<pre><code class=\"php\">return [     'class' =&gt; 'yii\\db\\Connection', \/\/ \u041a\u043b\u0430\u0441\u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f     'dsn' =&gt; 'mysql:host=localhost;dbname=yii2basic', \/\/ \u0418\u043c\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, URL     'username' =&gt; 'root', \/\/ \u041b\u043e\u0433\u0438\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u044d\u0442\u043e\u0439 \u0414\u0411     'password' =&gt; '', \/\/ \u041f\u0430\u0440\u043e\u043b\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u044d\u0442\u043e\u0439 \u0414\u0411     'charset' =&gt; 'utf8', \/\/ \u041a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0430 ]; <\/code><\/pre>\n<p>  \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442 \u0441 \u0442\u0435\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u044b. \u042d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u043c yii\\db\\Connection (\u0442\u043e\u0436\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445) \u0434\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c\/\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0411\u0414:<\/p>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u0431\u043b\u0438\u0446:<\/p>\n<ul>\n<li>\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f <b>\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439<\/b>, \u0442.\u043a. \u0432 basic \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f\/\u0432\u0445\u043e\u0434 \u0447\u0435\u0440\u0435\u0437 \u0411\u0414;<\/li>\n<li>\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f <b>\u0441\u0442\u0430\u0442\u0435\u0439<\/b> \u0432 \u0431\u043b\u043e\u0433\u0435.<\/li>\n<\/ul>\n<p>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0411\u0414 \u044f \u0431\u0443\u0434\u0443 \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/nix-tips.ru\/yii2-api-guides\/guide-ru-db-migrations.html\">\u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438<\/a>, \u044d\u0442\u043e \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u043e \u0434\u043b\u044f \u0432\u0430\u0441 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u043f\u043b\u043e\u0445\u043e\u0439 \u043e\u043f\u044b\u0442. \u041e \u0442\u043e\u043c \u00ab\u0437\u0430\u0447\u0435\u043c\u00bb \u043d\u0443\u0436\u043d\u044b \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u0432\u0441\u0435 \u0432 \u0442\u043e\u0439 \u0436\u0435 <a href=\"https:\/\/nix-tips.ru\/yii2-api-guides\/guide-ru-db-migrations.html\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043f\u043e \u044d\u0442\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435<\/a>.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0439\u0442\u0438 \u0432 <b>\u041a\u043e\u043c\u0430\u043d\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443<\/b> \u0438 \u0441\u043c\u0435\u043d\u0438\u0442\u044c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u043d\u0430 \u043f\u0430\u043f\u043a\u0443 \u0441 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c, \u0432 \u044d\u0442\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0444\u0430\u0439\u043b yii.bat, \u043e\u043d \u0442\u043e \u043d\u0430\u043c \u0438 \u043d\u0443\u0436\u0435\u043d.<\/p>\n<p>  \u0414\u043b\u044f \u0441\u043c\u0435\u043d\u044b \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0432\u0432\u043e\u0434\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"php\">cd C:\\xampp\\htdocs\\Yii2St\\basic <\/code><\/pre>\n<p>  (\u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e)<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b user \u0438 post(\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u0435\u0439).<\/p>\n<p>  \u0412\u0432\u043e\u0434\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u043e\u0441\u043b\u0435 cd:<\/p>\n<pre><code class=\"php\">yii migrate\/create create_post_table <\/code><\/pre>\n<p>  (\u0414\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b post)<\/p>\n<pre><code class=\"php\">yii migrate\/create create_user_table <\/code><\/pre>\n<p>  (\u0414\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b user)<\/p>\n<p>  Yii \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043f\u0430\u043f\u043a\u0443 migrations \u0435\u0441\u043b\u0438 \u0435\u0435 \u043d\u0435\u0442. \u0422\u0435\u043f\u0435\u0440\u044c \u0442\u0430\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f 2 \u0444\u0430\u0439\u043b\u0430 \u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u043b\u044f \u0434\u0432\u0443\u0445 \u0432\u044b\u0448\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439.<\/p>\n<p>  \u0417\u0430\u0439\u0434\u0435\u043c \u0432<br \/>  <b>basic\\migrations\\m170304_160410_create_user_table<\/b>.<br \/>  \u0412\u043d\u043e\u0441\u0438\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u00abup\u00bb, \u0434\u0435\u043b\u0430\u0435\u043c \u0442\u0430\u043a\u0443\u044e \u0436\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043a\u0430\u043a \u0432 \u0432\u0435\u0440\u0441\u0438\u0438 advanced:<\/p>\n<pre><code class=\"php\">    public function up() \/\/\u0421\u043e\u0431\u044b\u0442\u044b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b     {         $tableOptions = null;          if ($this-&gt;db-&gt;driverName === 'mysql') {             $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';         }         $this-&gt;createTable('user', [             'id' =&gt; $this-&gt;primaryKey(),             'username' =&gt; $this-&gt;string()-&gt;notNull()-&gt;unique(),             'auth_key' =&gt; $this-&gt;string(32)-&gt;notNull(),             'password_hash' =&gt; $this-&gt;string()-&gt;notNull(),             'password_reset_token' =&gt; $this-&gt;string()-&gt;unique(),             'email' =&gt; $this-&gt;string()-&gt;notNull()-&gt;unique(),             'status' =&gt; $this-&gt;smallInteger()-&gt;notNull()-&gt;defaultValue(10),             'created_at' =&gt; $this-&gt;integer()-&gt;notNull(),             'updated_at' =&gt; $this-&gt;integer()-&gt;notNull(),         ], $tableOptions);     } <\/code><\/pre>\n<p>  \u0414\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u0435\u043d \u0435\u0441\u043b\u0438 \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435 SQL \u0438 PHP \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u041e\u041e\u041f.<\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0432\u043d\u043e\u0441\u0438\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438 \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u0435\u0439 \u0432 <b>basic\\migrations\\m170304_160323_create_post_table<\/b>:<\/p>\n<pre><code class=\"php\">    public function up()     {         $tableOptions = null;          if ($this-&gt;db-&gt;driverName === 'mysql') {             $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';         }         $this-&gt;createTable('post', [             'id' =&gt; $this-&gt;primaryKey(),             'author' =&gt; $this-&gt;string()-&gt;notNull(), \/\/\u0410\u0432\u0442\u043e\u0440             'date' =&gt; $this-&gt;integer(32)-&gt;notNull(),             'category_id' =&gt; $this-&gt;integer()-&gt;notNull(), \/\/\u041d\u043e\u043c\u0435\u0440 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438             'text' =&gt; $this-&gt;string(20000)-&gt;unique(),             'title' =&gt; $this-&gt;string()-&gt;notNull()-&gt;unique(), \/\/ \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438             'abridgment' =&gt; $this-&gt;string(767)-&gt;notNull(), \/\/ \u0421\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442             'activity' =&gt; $this-&gt;integer()-&gt;notNull()-&gt;defaultValue(0), \/\/ \u0410\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u0438         ], $tableOptions);     } <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438:<\/p>\n<pre><code class=\"php\">yii migrate<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e\u0449\u0435, \u044d\u0442\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043c\u0435\u0442\u043e\u0434\u044b up \u0432 \u043a\u043b\u0430\u0441\u0441\u0430\u0445 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 + \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\/\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 &#8216;migration&#8217;, \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0440\u0443\u0433\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 down \u0432 \u043a\u043b\u0430\u0441\u0441\u0430\u0445 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439(\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e).<\/p>\n<p>  \u0422\u0430\u0431\u043b\u0438\u0446\u044b \u0433\u043e\u0442\u043e\u0432\u044b.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/7ac\/0e9\/4c8\/7ac0e94c898c51d00ba23b08db52d717.jpg\" alt=\"image\"\/><\/p>\n<h2>2) \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438\/\u0432\u0445\u043e\u0434\u0430 \u0447\u0435\u0440\u0435\u0437 \u0414\u0411<\/h2>\n<p>  \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438\/\u0432\u0445\u043e\u0434\u0430 \u0447\u0435\u0440\u0435\u0437 \u0414\u0411 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f:<\/p>\n<ul>\n<li>\u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c User (models\/User.php);<\/li>\n<li>\u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 (+models\/SignupForm.php);<\/li>\n<li>\u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 (controllers\/SiteController.php);<\/li>\n<li> \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u0438\u0434 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 (views\/site\/signup.php);<\/li>\n<li>\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044e \u0432 \u043d\u0430\u0432\u0431\u0430\u0440 (views\/layouts\/main.php).<\/li>\n<\/ul>\n<p>  (\u041e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 <a href=\"https:\/\/nix-tips.ru\/yii2-api-guides\/guide-ru-security-authentication.html\">User \u0438 IdentityInterface<\/a>)<\/p>\n<p>  \u0412 Yii \u0435\u0441\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f User, \u043e\u043d \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0442\u0430\u0442\u0443\u0441\u043e\u043c \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"php\">Yii::$app-&gt;user-&gt;isGuest; \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 true, \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d Yii::$app-&gt;user-&gt;logout(); \/\/ \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u043b\u043e\u0433\u0430\u0443\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f Yii::$app-&gt;user-&gt;identity-&gt;username \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 username \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \/\/ \u0438 \u0442.\u0434. <\/code><\/pre>\n<p>  \u041e\u043d \u0442\u0440\u0435\u0431\u0443\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u0432\u044b \u0443\u043a\u0430\u0437\u0430\u043b\u0438 <b>identity class<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"php\">$config = [     ...     'components' =&gt; [      ....         'user' =&gt; [             'identityClass' =&gt; 'app\\models\\User', \/\/ \u042d\u0442\u0430 \u043c\u043e\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c User         ],      ....     ]     ...   ]; <\/code><\/pre>\n<p>  \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438, \u043a\u043b\u0430\u0441\u0441 User \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c IdentityInterface, \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043f\u0438\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434<\/p>\n<p>  <b>basic\\models\\User<\/b>:<\/p>\n<pre><code class=\"php\">namespace app\\models;  use Yii; use yii\\base\\NotSupportedException; use yii\\db\\ActiveRecord; use yii\\web\\IdentityInterface;  class User extends ActiveRecord implements IdentityInterface {     \/\/ \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0441 \u0411\u0414, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440     const STATUS_DELETED = 0; \/\/ \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0417\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d(\u0423\u0434\u0430\u043b\u0435\u043d)     const STATUS_ACTIVE = 10; \/\/ \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0410\u043a\u0442\u0438\u0432\u0435\u043d     const STATUS_ADMIN = 1; \/\/ \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0410\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440          \/\/ \u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430     public static function findIdentity($id)     {         return static::findOne(['id' =&gt; $id, 'status' =&gt; self::STATUS_ACTIVE]);     }      public static function findIdentityByAccessToken($token, $type = null)     {         throw new NotSupportedException('&quot;findIdentityByAccessToken&quot; is not implemented.');     }      public static function findByUsername($username)     {         return static::findOne(['username' =&gt; $username, 'status' =&gt; self::STATUS_ACTIVE]);     }      public function getId()     {         return $this-&gt;getPrimaryKey();     }      public function getAuthKey()     {         return $this-&gt;auth_key;     }      public function validateAuthKey($authKey)     {         return $this-&gt;getAuthKey() === $authKey;     }      public function validatePassword($password)     {         return Yii::$app-&gt;security-&gt;validatePassword($password, $this-&gt;password_hash);     }      public function setPassword($password)     {         $this-&gt;password_hash = Yii::$app-&gt;security-&gt;generatePasswordHash($password);     }      public function generateAuthKey()     {         $this-&gt;auth_key = Yii::$app-&gt;security-&gt;generateRandomString();     } } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u044c <\/p>\n<p>  <b>basic\\models\\SignupForm.php<\/b>:<br \/>  (\u041e \u043c\u0435\u0442\u043e\u0434\u0435 <a href=\"https:\/\/nix-tips.ru\/yii2-api-guides\/guide-ru-input-validation.html\">validate() \u0438 rules<\/a>)<\/p>\n<pre><code class=\"php\">namespace app\\models;  use Yii; use yii\\base\\Model;  class SignupForm extends Model {      public $username;     public $email;     public $password;      public function rules() \/\/ \u042d\u0442\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438: \u0444\u043e\u0440\u043c\u044b \u0432\u0432\u043e\u0434\u0430, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 validate()     {         return [             ['username', 'trim'], \/\/ \u043e\u0431\u0440\u0435\u0437\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u0435\u043b\u044b \u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432 null \u0435\u0441\u043b\u0438 \u043d\u0435\u0447\u0435\u0433\u043e \u043d\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f             ['username', 'required'], \/\/ 'username' \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f             ['username', 'unique', 'targetClass' =&gt; '\\app\\models\\User', 'message' =&gt; 'This username has already been taken.'], \/\/ 'username' \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \\app\\models\\User(\u0442\u043e \u0435\u0441\u0442\u044c \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 user(\u0432\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c ActivityRecords) \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u0430)              ['username', 'string', 'min' =&gt; 2, 'max' =&gt; 255], \/\/ 'username' \u044d\u0442\u043e string \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u0442 2 \u0434\u043e 255 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432             ['email', 'trim'],             ['email', 'required'],             ['email', 'email'],             ['email', 'string', 'max' =&gt; 255],             ['email', 'unique', 'targetClass' =&gt; '\\app\\models\\User', 'message' =&gt; 'This email address has already been taken.'],             ['password', 'required'],             ['password', 'string', 'min' =&gt; 6],         ];     }      public function attributeLabels() \/\/ \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438     {         return [             'username' =&gt; '\u041b\u043e\u0433\u0438\u043d',             'email' =&gt; '\u042d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u0430\u044f \u043f\u043e\u0447\u0442\u0430',             'password' =&gt; '\u041f\u0430\u0440\u043e\u043b\u044c',         ];     }      public function signup() \/\/ \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f     {          if (!$this-&gt;validate()) { \/\/ \u0415\u0441\u043b\u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u0432\u0435\u0440\u043d\u0443\u043b\u0430 false \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c null             return null;         }         $user = new User(); \/\/ \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 User         $user-&gt;username = $this-&gt;username; \/\/ \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430         $user-&gt;email = $this-&gt;email;         $user-&gt;setPassword($this-&gt;password);         $user-&gt;generateAuthKey();         $user-&gt;created_at() = time();         return $user-&gt;save() ? $user : null; \/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443(\u043c\u0435\u0442\u043e\u0434 ActivityRecord) user \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043d\u0435 \u0440\u0430\u0432\u043d\u0430 null     } } <\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432 \u043c\u043e\u0434\u0435\u043b\u044c <br \/>  <b>basic\\controllers\\SiteController.php<\/b>:<\/p>\n<pre><code class=\"php\">    \/\/....     public function actionSignup()     {         $model = new SignupForm(); \/\/ \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0444\u0430\u0439\u043b\u0430: use app\\models\\SignupForm; \u0438\u043b\u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c 'new SignupForm()' \u043d\u0430 '\\app\\models\\SignupForm()'          if ($model-&gt;load(Yii::$app-&gt;request-&gt;post())) { \/\/ \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c, \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c post \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u0447\u0435\u0440\u0435\u0437 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 load \u043a\u043b\u0430\u0441\u0441\u0430 Model             if ($user = $model-&gt;signup()) { \/\/ \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f                 if (Yii::$app-&gt;getUser()-&gt;login($user)) { \/\/ \u041b\u043e\u0433\u0438\u043d\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0435\u0441\u043b\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u0430                     return $this-&gt;goHome(); \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443                 }             }         }          return $this-&gt;render('signup', [ \/\/ \u041f\u0440\u043e\u0441\u0442\u043e \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043c \u0432\u0438\u0434 \u0435\u0441\u043b\u0438 \u043e\u0434\u0438\u043d \u0438\u0437 if \u0432\u0435\u0440\u043d\u0443\u043b false             'model' =&gt; $model,         ]);     }   \/\/.... <\/code><\/pre>\n<p>   \u0414\u0430\u043b\u0435\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u0438\u0434 signup \u0434\u043b\u044f \u0432\u0432\u043e\u0434\u0430 \u0444\u043e\u0440\u043c\u044b <br \/>  <b>basic\\views\\site\\signup.php<\/b>:<\/p>\n<pre><code class=\"php\">use yii\\helpers\\Html; use yii\\bootstrap\\ActiveForm;  $this-&gt;title = &#039;\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f&#039;; $this-&gt;params[&#039;breadcrumbs&#039;][] = ; \/\/ &lt;-- \u041d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044f ?&gt; &lt;div class=&quot;site-signup&quot;&gt;     &lt;h1&gt;&lt;?= Html::encode($this-&gt;title) ?&gt;&lt;\/h1&gt;     &lt;p&gt;\u041f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u0444\u043e\u0440\u043c\u044b \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438:&lt;\/p&gt;     &lt;div class=&quot;row&quot;&gt;         &lt;div class=&quot;col-lg-5&quot;&gt;              &lt;?php $form = ActiveForm::begin([&#039;id&#039; =&gt; &#039;form-signup&#039;]); ?&gt;             &lt;?= $form-&gt;field($model, &#039;username&#039;)-&gt;textInput([&#039;autofocus&#039; =&gt; true]) ?&gt;             &lt;?= $form-&gt;field($model, &#039;email&#039;) ?&gt;             &lt;?= $form-&gt;field($model, &#039;password&#039;)-&gt;passwordInput() ?&gt;             &lt;div class=&quot;form-group&quot;&gt;                 &lt;?= Html::submitButton(&#039;Signup&#039;, [&#039;class&#039; =&gt; &#039;btn btn-primary&#039;, &#039;name&#039; =&gt; &#039;signup-button&#039;]) ?&gt;             &lt;\/div&gt;             &lt;?php ActiveForm::end(); ?&gt;          &lt;\/div&gt;     &lt;\/div&gt; &lt;\/div&gt; <\/code><\/pre>\n<p>  \u0418\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u043d\u0430\u0432\u0431\u0430\u0440<br \/>  <b>basic\\views\\layouts<\/b><\/p>\n<pre><code class=\"php\">\/\/ \u0418\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 NavBar::begin(), \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044f NavBar::end()     NavBar::begin([         'brandLabel' =&gt; 'My Company', \/\/ \u041d\u0430\u0434\u043f\u0438\u0441\u044c \u0441\u043b\u0435\u0432\u0430         'brandUrl' =&gt; Yii::$app-&gt;homeUrl, \/\/ Url \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0443\u043a\u0430\u0437 \u0432 \u0433\u0438\u043f\u0435\u0440\u0441\u0441\u044b\u043b\u043a\u0435 \u043d\u0430 \u043d\u0430\u0434\u043f\u0438\u0441\u0438         'options' =&gt; [             'class' =&gt; 'navbar-inverse navbar-fixed-top', \/\/ \u041a\u043b\u0430\u0441\u0441 bootstrap class=&quot;navbar-inverse navbar-fixed-top&quot; \u0432 HTML         ],     ]);      $menuItems = [ \/\/ \u0422\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u0432\u0441\u0435\u0433\u0434\u0430         ['label' =&gt; '\u0413\u043b\u0430\u0432\u043d\u0430\u044f', 'url' =&gt; ['\/site\/index']],         ['label' =&gt; '\u041a\u043e\u043d\u0442\u0430\u043a\u0442', 'url' =&gt; ['\/site\/contact']],     ];      if(Yii::$app-&gt;user-&gt;isGuest) \/\/ \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d     {         $menuItems[] = ['label' =&gt; '\u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u0441\u044f', 'url' =&gt; ['\/site\/signup']];         $menuItems[] = ['label' =&gt; '\u0412\u043e\u0439\u0442\u0438', 'url' =&gt; ['\/site\/login']];     }     else     {         $menuItems[] = ['label' =&gt; '\u0421\u0442\u0430\u0442\u044c\u0438', 'url' =&gt; ['\/post']];         $menuItems[] = '&lt;li&gt;'             . Html::beginForm(['\/site\/logout'], 'post') \/\/ \u0424\u043e\u0440\u043c\u0430 \u043b\u043e\u0433\u0430\u0443\u0442\u0430, \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u0438\u0434\u0436\u0435\u0442 ActiveForm             . Html::submitButton(                 '\u0412\u044b\u0439\u0442\u0438 (' . Yii::$app-&gt;user-&gt;identity-&gt;username . ')',                 ['class' =&gt; 'btn btn-link logout']             )             . Html::endForm()             . '&lt;\/li&gt;';     }      echo Nav::widget([ \/\/ \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043c\u0435\u0442\u043e\u0434\u0430         'options' =&gt; ['class' =&gt; 'navbar-nav navbar-right'],         'items' =&gt; $menuItems \/\/ \u042d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u0435\u043d\u044e     ]);     NavBar::end(); <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434:<br \/>  <b>basic\\config\\web.php<\/b>:<\/p>\n<pre><code class=\"php\">return [     'id' =&gt; 'basic',     'basePath' =&gt; dirname(__DIR__),     \/\/ ...     'language' =&gt; 'ru-RU', \/\/ &lt;- \u042d\u0442\u0443 \u0441\u0442\u0440\u043e\u043a\u0443!     \/\/ ... ] <\/code><\/pre>\n<p>  <a href=\"https:\/\/nix-tips.ru\/yii2-api-guides\/guide-ru-tutorial-i18n.html\">\u041e \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/a><\/p>\n<h2>3) \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c <a href=\"https:\/\/ru.wikipedia.org\/wiki\/CRUD\">CRUD<\/a> \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u0435\u0439<\/h2>\n<p>  CRUD \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c, \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e. \u0421\u0430\u043c\u044b\u043c \u0431\u044b\u0441\u0442\u0440\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f CRUD \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <a href=\"https:\/\/nix-tips.ru\/yii2-api-guides\/guide-ru-start-gii.html\">gii<\/a>. Gii \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u0434, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<p>  \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043f\u043e url \u0441 \u0442\u0430\u043a\u0438\u043c get <b>?r=gii<\/b><br \/>  \u0414\u043b\u044f CRUD \u043d\u0430 \u043d\u0443\u0436\u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u044c, \u044f \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e \u043d\u043e\u0432\u0443\u044e:<\/p>\n<p>  (\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u0432\u0435\u0434\u044f \u043a\u0443\u0440\u0441\u043e\u0440 \u043d\u0430 \u043b\u0435\u0439\u0431\u043b \u0444\u043e\u0440\u043c\u044b)<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/pp.userapi.com\/c637124\/v637124642\/35ff9\/jPtAC7HzSNc.jpg\" alt=\"image\"\/><\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0444\u043e\u0440\u043c\u044b \u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0441\u0430\u043c CRUD:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/pp.userapi.com\/c637124\/v637124642\/35ff9\/jPtAC7HzSNc.jpg\" alt=\"image\"\/><\/p>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c CRUD \u043c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u0442\u0430\u043a\u043e\u0439 get <b>?r=post<\/b><\/p>\n<p>  <b>P.S.<\/b> \u041a\u043e\u043d\u0435\u0446 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438.<br \/>  <b>P.P.S.<\/b> \u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f, \u0441\u0443\u0434\u0438\u0442\u0435 \u0441\u0442\u0440\u043e\u0433\u043e.<br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/324300\/\"> https:\/\/habrahabr.ru\/post\/324300\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d8a\/b34\/9e9\/d8ab349e9df8c9cfa142955afeafa919.jpg\" alt=\"image\"\/><\/p>\n<p>  \u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u042f \u043f\u043e\u043f\u044b\u0442\u0430\u044e\u0441\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0431\u043b\u043e\u0433\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Yii 2(basic) \u0432 \u0446\u0435\u043b\u044f\u0445 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u041f\u043e\u0447\u0435\u043c\u0443 basic? \u041f\u043e \u043c\u043e\u0435\u043c\u0443 \u043e\u043f\u044b\u0442\u0443 basic \u0432\u0435\u0440\u0441\u0438\u044f \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-283488","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/283488","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=283488"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/283488\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=283488"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=283488"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=283488"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}