{"id":178737,"date":"2013-05-05T13:38:03","date_gmt":"2013-05-05T09:38:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=178737"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=178737","title":{"rendered":"<span class=\"post_title\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e CRUD-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Yii2<\/span>"},"content":{"rendered":"<div class=\"content html_format\">\n<h4>Disclaimer<\/h4>\n<p>  \u042d\u0442\u043e\u0442 \u0443\u0440\u043e\u043a \u043f\u043e\u043c\u043e\u0436\u0435\u043c \u0432\u0430\u043c \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 Yii2. \u0412 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 Yii2 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043d\u0435 \u0433\u043e\u0442\u043e\u0432 \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0430. \u042f \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445.<\/p>\n<h4>\u041d\u0430\u0447\u043d\u0451\u043c<\/h4>\n<p>  \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0430\u0432\u0442\u043e\u0440\u044b Yii Framework \u0430\u043d\u043e\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e\u0435 \u043f\u0440\u0435\u0432\u044c\u044e Yii2. \u041c\u0435\u0436\u0434\u0443 Yii1 \u0438 Yii2 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<\/p>\n<p>  \u042d\u0442\u043e\u0442 \u0443\u0440\u043e\u043a \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0431\u043b\u043e\u0433\u0430 \u043d\u0430 Yii2. \u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c Yii2, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f, \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f, \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0442\u043e\u0432.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u044f \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f:<\/p>\n<ul>\n<li>\u0412\u0435\u0431\u0441\u0435\u0440\u0432\u0435\u0440, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 Apache \u0438\u043b\u0438 Nginx. \u042f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Nginx. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Apache \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u0432\u043e\u043b\u043d\u0443\u0439\u0442\u0435\u0441\u044c \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0442 \u043f\u043e\u0431\u043b\u0438\u0437\u043e\u0441\u0442\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0441 Nginx.<\/li>\n<li>\u0421\u0435\u0432\u0435\u0440 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u042f \u0432\u044b\u0431\u0440\u0430\u043b MySQL 5.5<\/li>\n<li>\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u043d\u0438\u044f PHP. \u042f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0442\u044c \u0432\u0441\u0451 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u043e \u0447\u0435\u043c \u043b\u0443\u0447\u0448\u0435 \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435 PHP, \u0442\u0435\u043c \u043f\u0440\u043e\u0449\u0435 \u0432\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435.<\/li>\n<li>\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u043d\u0438\u044f Yii \u0438\u043b\u0438 MVC. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u043e\u043f\u044b\u0442\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 MVC, \u0442\u043e \u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0432\u0430\u043c <a href=\"http:\/\/www.yiiframework.com\/doc\/guide\/1.1\/en\/basics.mvc\">\u043f\u0440\u043e\u0447\u0435\u0441\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u044b MVC<\/a>. \u0412\u044b <em>\u043c\u043e\u0436\u0435\u0442\u0435<\/em> \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0443\u0440\u043e\u043a \u0438 \u0431\u0435\u0437 \u0437\u043d\u0430\u043d\u0438\u044f MVC, \u043d\u043e \u0432\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043b\u0435\u0433\u0447\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0435, \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u044e\u0441\u044c \u0432 \u0442\u0435\u043c\u0435 MVC.<\/li>\n<\/ul>\n<p>  \u0412\u043f\u0435\u0440\u0451\u0434!<br \/>  <a name=\"habracut\"><\/a><br \/>  \u042f \u0431\u0443\u0434\u0443 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c, \u0447\u0442\u043e \u0443 \u0432\u0430\u0441 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0432\u0435\u0431\u0441\u0435\u0440\u0432\u0435\u0440. \u0412 \u0443\u0440\u043e\u043a\u0435 \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0443\u0442\u0438 \u0438 \u0430\u0434\u0440\u0435\u0441\u0430:<\/p>\n<ul>\n<li>\/var\/www\/yii2 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 DocumentRoot<\/li>\n<li>yii2.erianna.com \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0434\u0440\u0435\u0441\u0430 \u0445\u043e\u0441\u0442\u0438\u043d\u0433\u0430<\/li>\n<\/ul>\n<p>  \u0422\u0430\u043a\u0436\u0435, \u0432 \u043a\u043e\u043d\u0446\u0435 \u0443\u0440\u043e\u043a\u0430 \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0441 \u0432\u0430\u043c\u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043d\u0430 <a href=\"http:\/\/yii2.erianna.com\">yii2.erianna.com<\/a>.<\/p>\n<h4>\u0421\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c Yii2<\/h4>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u043e\u043f\u0438\u044e Yii2 \u0441 Github \u043c\u043e\u0436\u043d\u043e \u043b\u0438\u0431\u043e \u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439, \u043b\u0438\u0431\u043e \u0441\u043a\u0430\u0447\u0430\u0432 \u0430\u0440\u0445\u0438\u0432.<\/p>\n<pre>git clone git@github.com:yiisoft\/yii2.git \/dir\/to\/yii2<\/pre>\n<p>  \u043b\u0438\u0431\u043e<\/p>\n<pre>wget https:\/\/github.com\/yiisoft\/yii2\/archive\/master.zip unzip master.zip \/dir\/to\/yii2<\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0438 Yii2, \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 \u043f\u0430\u043f\u043a\u0443 <strong>\/dir\/to\/yii2\/framework<\/strong><\/p>\n<pre>cd \/dir\/to\/yii2\/framework<\/pre>\n<p>  \u0418 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043e\u0442\u0432\u0435\u0442\u0438\u0432 Yes \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441.<\/p>\n<pre>php yiic.php app\/create \/var\/www\/yii2 yes<\/pre>\n<p>  \u042d\u0442\u043e \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 Yii 1.x. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 \/var\/www\/yii2. \u0412\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043e\u0434\u043d\u0443 \u043f\u0430\u043f\u043a\u0443 \u0438 \u043e\u0434\u0438\u043d \u0444\u0430\u0439\u043b.<\/p>\n<pre>$ ls -l total 8 -rwxrwxrwx 1 user www-data  265 May  4 09:30 index.php drwxrwsr-x 5 user www-data 4096 May  4 09:07 protected <\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0430\u0448 \u0441\u0430\u0439\u0442, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u043d\u0435\u0441\u0442\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0432 \u0444\u0430\u0439\u043b index.php. \u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0442\u0430\u043c \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u043e\u0440\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b \u0434\u043e \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u043b\u0438\u0437\u0430 Yii2, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0431\u043e\u043b\u0435\u0435 \u0434\u0440\u0443\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0432 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435.<\/p>\n<p>  \u0418\u0437\u043c\u0435\u043d\u0438\u0442\u0435 index.php \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"php\">&lt;?php define('YII_DEBUG', true);   \/\/ Change this to your actual Yii path require '\/path\/to\/yii2\/framework\/yii.php';   \/\/ Change __DIR__ to __FILE__ so we can load our config file $config = require dirname(__FILE__).'\/protected\/config\/main.php'; $config['basePath'] = dirname(__FILE__).'\/protected';   $app = new \\yii\\web\\Application($config); $app-&gt;run();<\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438:<\/p>\n<pre><code class=\"php\">\/\/ Change this to your actual Yii path require '\/path\/to\/yii2\/framework\/yii.php';<\/code><\/pre>\n<p>  \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 framework\/yii.php. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043e\u043d \u043b\u0435\u0436\u0438\u0442 \u0432 \u0442\u043e\u0439 \u0436\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0442\u0430\u043a \u0438 \u0431\u044b\u0432\u0430\u0435\u0442, \u043d\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0442\u043e\u0447\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u043a Yii2.<\/p>\n<pre><code class=\"php\">$config = require dirname(__FILE__).'\/protected\/config\/main.php'; $config['basePath'] = dirname(__FILE__).'\/protected';<\/code><\/pre>\n<p>  \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043c\u044b \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u043f\u0443\u0442\u044c \u043a \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c\u0443 \u0444\u0430\u0439\u043b\u0443, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b <strong>__FILE__<\/strong> \u0432\u043c\u0435\u0441\u0442\u043e <strong>__DIR__<\/strong>. \u042d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e\u0431\u044b \u0431\u044b \u0432\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0433\u043b\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c\u0441\u044f. <\/p>\n<p>  \u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c \u043a\u0430\u043a \u043c\u044b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c, \u0432\u0430\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u043a\u043e\u0435-\u0447\u0442\u043e \u043d\u043e\u0432\u043e\u0435 \u0432 Yii \u2014 <strong>Namespaces<\/strong><\/p>\n<pre><code class=\"php\">$app = new \\yii\\web\\Application($config);<\/code><\/pre>\n<p>  \u0421\u043c\u044b\u0441\u043b \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432 \u0438\u043c\u0451\u043d \u0432 \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u0438 \u043a\u043e\u0434\u0430 \u0432 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0435\u0434\u0438\u043d\u0438\u0446\u044b, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043a\u043e\u0434\u043e\u0432\u044b\u043c\u0438 \u0431\u0430\u0437\u0430\u043c\u0438. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430, \u043e\u0431\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f <strong>Foo<\/strong> \u0438 \u043e\u0431\u0430 \u0438\u043c\u0435\u044e\u0442 \u043c\u0435\u0442\u043e\u0434 <strong>Bar<\/strong>. \u0415\u0441\u043b\u0438 \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430\u0445 \u0438\u043c\u0451\u043d, \u0442\u043e \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0438\u0445 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430 \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439.<\/p>\n<pre><code class=\"php\">$foo = new \\namespace\\Foo; $foo2 = new \\namespace2\\Foo;<\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0451\u043d \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439 \u0432 \u043a\u043e\u0434\u0435. \u042f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0432\u0430\u043c <a href=\"http:\/\/www.php.net\/manual\/en\/language.namespaces.rationale.php\">\u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043e \u043d\u0438\u0445<\/a>, \u0442\u0430\u043a \u043a\u0430\u043a Yii2 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d \u043d\u0430 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043f\u0435\u0440\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435! \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043d\u0430 \u0430\u0434\u0440\u0435\u0441, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0443 \u0432\u0430\u0441 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d yii2 \u0438 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/www.erianna.com\/uploads\/c4ca4238a0b923820dcc509a6f75849b.png\" alt=\"c4ca4238a0b923820dcc509a6f75849b.png\"\/><br \/>  \u0412\u0430\u0448\u0435 \u043f\u0435\u0440\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 Yii2!<\/p>\n<p>  \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0438 \u043e\u0442 Yii 1.x, \u0431\u0430\u0437\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 Yii2 \u043d\u0435 \u0442\u0430\u043a\u043e\u0435 \u0432\u043e\u0441\u0445\u0438\u0449\u0430\u044e\u0449\u0435\u0435. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0443\u0447\u0438\u043c \u0435\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435.<\/p>\n<p>  \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043e\u0442\u043a\u0440\u043e\u0435\u043c \u0444\u0430\u0439\u043b <strong>\/protected\/views\/layout\/main.php<\/strong> \u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435:<\/p>\n<pre><code class=\"php\">&lt;?php use yii\\helpers\\Html as Html; ?&gt; &lt;!doctype html&gt; &lt;html lang=&quot;&lt;?php \\Yii::$app-&gt;language?&gt;&quot;&gt;     &lt;head&gt;         &lt;meta charset=&quot;utf-8&quot; \/&gt;         &lt;title&gt;&lt;?php echo Html::encode(\\Yii::$app-&gt;name); ?&gt;&lt;\/title&gt;         &lt;link href=&quot;\/\/netdna.bootstrapcdn.com\/twitter-bootstrap\/2.3.1\/css\/bootstrap-combined.min.css&quot; rel=&quot;stylesheet&quot;&gt;         &lt;script src=&quot;\/\/netdna.bootstrapcdn.com\/twitter-bootstrap\/2.3.1\/js\/bootstrap.min.js&quot;&gt;&lt;\/script&gt;     &lt;\/head&gt;     &lt;body&gt;         &lt;div class=&quot;container&quot;&gt;             &lt;div class=&quot;navbar navbar-inverse&quot;&gt;                 &lt;div class=&quot;container&quot;&gt;                     &lt;div class=&quot;navbar-inner&quot;&gt;                         &lt;a class=&quot;brand&quot; href=&quot;\/&quot;&gt;&lt;?php echo Html::encode(\\Yii::$app-&gt;name); ?&gt;&lt;\/a&gt;                     &lt;\/div&gt;                 &lt;\/div&gt;             &lt;\/div&gt;             &lt;div class=&quot;content&quot;&gt;                 &lt;?php echo $content?&gt;             &lt;\/div&gt;         &lt;\/div&gt;     &lt;\/body&gt; &lt;\/html&gt;<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443. \u0412\u0438\u0434\u0438\u0442\u0435? \u0420\u0430\u0437\u0432\u0435 \u043d\u0435 \u0432\u0441\u0451 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043b\u0443\u0447\u0448\u0435 \u0441 Twitter Bootstrap? \u041e\u043f\u044f\u0442\u044c \u0436\u0435, \u043d\u0435 \u0442\u0430\u043a \u0438 \u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c \u043c\u0435\u0436\u0434\u0443 Yii1 \u0438 Yii2. \u0423 \u0432\u0430\u0441 \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0435\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f $content \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u0432\u043e view. \u041e\u0434\u043d\u0430\u043a\u043e, <strong>Yii::app()<\/strong> \u0437\u0430\u043c\u0435\u043d\u0438\u043b\u0438 \u043d\u0430 <strong>Yii::$app<\/strong>. \u0418 \u043d\u0430\u043f\u043e\u043c\u043d\u044e \u0435\u0449\u0451 \u0440\u0430\u0437 \u2014 \u0432\u0441\u0451 \u0432 Yii2 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043e \u043f\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430\u043c \u0438\u043c\u0451\u043d, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0430\u0436\u043d\u043e \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a\u043e \u0432\u0441\u0435\u043c\u0443 \u043f\u043e \u0438\u0445 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0443 \u0438\u043c\u0451\u043d, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u00ab\u0441\u044b\u0440\u044b\u0435\u00bb \u043a\u043b\u0430\u0441\u0441\u044b.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u0439\u043c\u0451\u043c\u0441\u044f \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u043c \u043a\u043e\u0434\u0438\u043d\u0433\u043e\u043c!<\/p>\n<h4>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043b\u0438\u0448\u044c \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 <strong>Posts<\/strong>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u043e\u0441\u0442\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043b\u043e\u0433\u0430.<\/p>\n<h5>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/h5>\n<p>  \u0412\u043e\u0439\u0434\u0438\u0442\u0435 \u0432 MySQL \u0438 \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c yii2. \u0417\u0430\u0442\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b:<\/p>\n<pre><code class=\"sql\">DROP TABLE IF EXISTS `posts`; CREATE TABLE IF NOT EXISTS `posts` (   `id` int(11) NOT NULL,   `title` varchar(255) NOT NULL,   `content` text NOT NULL,   `created` datetime NOT NULL,   `updated` datetime NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;  ALTER TABLE `posts` ADD PRIMARY KEY(`id`);  INSERT INTO `yii2`.`posts` (`id`, `title`, `content`, `created`, `updated`) VALUES ('1', 'Example Title', 'New Post', NOW(), NOW());<\/code><\/pre>\n<p>  <\/p>\n<h5>\u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433<\/h5>\n<p>  \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 \u043f\u0430\u043f\u043a\u0443 <strong>\/var\/www\/yii2\/protected\/<\/strong> \u0438 \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0444\u0430\u0439\u043b <strong>config.php<\/strong> \u0432 \u043b\u044e\u0431\u0438\u043c\u043e\u043c \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435. \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u0432\u0441\u0451 \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043d\u0430 \u044d\u0442\u043e:<\/p>\n<pre><code class=\"php\">&lt;?php return array( 'id' =&gt; 'webapp', 'name' =&gt; 'My Web Application',   'components' =&gt; array(         \/\/ uncomment the following to use a MySQL database         'db' =&gt; array(                 'class' =&gt; 'yii\\db\\Connection',                 'dsn' =&gt; 'mysql:host=localhost;dbname=yii2',                 'username' =&gt; 'yii2',                  'password' =&gt; '&lt;password&gt;',                 ),                 'cache' =&gt; array(                         'class' =&gt; 'yii\\caching\\DummyCache',                 ),         ), );<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 Yii, \u0442\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u0435 <em>\u0441\u0438\u043b\u044c\u043d\u043e\u0435<\/em> \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u0435\u0445 \u043c\u043e\u043d\u0441\u0442\u0440\u0443\u043e\u0437\u043d\u044b\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b Yii1. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c \u043f\u0440\u0435\u0436\u043d\u0435\u0439, \u044d\u0442\u043e \u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h5>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043c\u043e\u0434\u0435\u043b\u044c Post<\/h5>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043d\u043e\u0432\u0443\u044e \u043f\u0430\u043f\u043a\u0443 <strong>models<\/strong> \u0432 \u043f\u0430\u043f\u043a\u0435 protected, \u0430 \u0437\u0430\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0432 \u043d\u0435\u0439 \u0444\u0430\u0439\u043b <strong>Post.php<\/strong> \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043a\u043e\u0434\u043e\u043c.<\/p>\n<pre><code class=\"php\">&lt;?php namespace app\\models; class Post extends \\yii\\db\\ActiveRecord {     \/**      * Returns the static model of the specified AR class.      * @param string $className active record class name.      * @return Comments the static model class      *\/     public static function model($className=__CLASS__)     {         return parent::model($className);     }       \/**      * @return string the associated database table name      *\/     public static function tableName()     {         return 'posts';     }       \/**      * @return array primary key of the table      **\/          public static function primaryKey()     {         return array('id');     }       \/**      * @return array customized attribute labels (name=&gt;label)      *\/     public function attributeLabels()     {         return array(             'id' =&gt; 'ID',             'title' =&gt; 'Title',             'content' =&gt; 'Content',             'created' =&gt; 'Created',             'updated' =&gt; 'Updated',         );     } }<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 Yii1, \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0447\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c \u0432 ActiveRecord (\u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435), \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>primaryKey<\/strong> \u0438 <strong>tableName<\/strong> \u0442\u0435\u043f\u0435\u0440\u044c \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438. \u0412\u0441\u0451 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u0435\u0436\u043d\u0438\u043c. \u041f\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0447\u0430\u0441\u0442\u0438, ActiveRecord \u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c \u043d\u0435\u0442\u0440\u043e\u043d\u0443\u0442\u043e\u0439.<\/p>\n<p>  \u0421\u0430\u043c\u043e\u0439 \u0432\u0430\u0436\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e \u043a\u043b\u0430\u0441\u0441\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0451\u043d <strong>app\\models<\/strong>. \u042d\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442 Yii \u043a\u0430\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b.<\/p>\n<p>  \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0438 \u043e\u0442 Yii1, \u0433\u0434\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0438\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430, Yii2 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 \u0442\u0438\u043f \u0430\u0432\u0442\u043e\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0444\u0430\u0439\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0442 \u0432\u0430\u0441 \u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0435\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043c\u0435\u0434\u043b\u0438\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 (\u041f\u043e\u043f\u044b\u0442\u043a\u0438 \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \\yii\\framework\\web\\Html \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 CHtml \u043c\u043e\u0433\u0443\u0442 \u0443\u0442\u043e\u043c\u0438\u0442\u044c), \u043d\u043e \u0432 \u0442\u043e\u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u0441\u0434\u0435\u043b\u0430\u0435\u0442 Yii2 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u043f\u043e \u0442\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435, \u0447\u0442\u043e \u0430\u0432\u0442\u043e\u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u0441\u043a\u0430\u0442\u044c \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0443, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043e\u0434\u0438\u043d \u043a\u043b\u0430\u0441\u0441. \u041f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u0432 \u0442\u0435\u043e\u0440\u0438\u0438.<\/p>\n<h4>CRUD!<\/h4>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u044b \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043b\u0438 \u043c\u043e\u0434\u0435\u043b\u044c Post \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0451\u043d, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0447\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c CRUD-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<h5>\u041f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u0432\u0441\u0435\u0433\u043e<\/h5>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0431\u043d\u043e\u0432\u0438\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 index, \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0432\u0438\u0434\u0435\u0442\u044c \u0432\u0441\u0451. \u042f \u043b\u044e\u0431\u043b\u044e \u0432\u0438\u0434\u0435\u0442\u044c \u0432\u0441\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043f\u0440\u044f\u043c\u043e \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0447\u043d\u0451\u043c \u0441 \u044d\u0442\u043e\u0433\u043e. \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0444\u0430\u0439\u043b <strong>controllers\/SiteController.php<\/strong> \u0438 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 index \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435:<\/p>\n<pre><code class=\"php\">public function actionIndex() {     $post = new Post;     $data = $post-&gt;find()-&gt;all();     echo $this-&gt;render('index', array(         'data' =&gt; $data     )); }<\/code><\/pre>\n<p>  \u041e\u0442\u043c\u0435\u0447\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0435\u0449\u0435\u0439. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, <strong>::model()-&gt;<\/strong> \u0438\u0441\u0447\u0435\u0437\u043b\u043e. \u0414\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 ActiveRecord \u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043f\u043e \u043f\u0440\u044f\u043c\u043e\u043c\u0443 \u0432\u044b\u0437\u043e\u0432\u0443 \u043c\u0435\u0442\u043e\u0434\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, $post-&gt;find()-&gt;all(). \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043b\u0438\u0447\u043d\u043e \u044f \u043b\u044e\u0431\u043b\u044e Post::model()-&gt;findAll(), \u043d\u043e\u0432\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c \u0438 \u043b\u0435\u0433\u043a\u0438\u043c \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, findAll \u0431\u044b\u043b \u0437\u0430\u043c\u0435\u043d\u0451\u043d \u043d\u0430 find()-&gt;all(). \u0412\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u043e\u0438\u0441\u043a\u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u043e\u0442 find() \u0438\u043b\u0438 findBySql().<\/p>\n<p>  \u0412-\u0442\u0440\u0435\u0442\u044c\u0438\u0445, $this-&gt;render() \u0442\u0435\u043f\u0435\u0440\u044c \u0442\u0440\u0435\u0431\u0443\u0435\u0442 echo \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. \u041b\u0438\u0447\u043d\u043e \u044f \u043d\u0435\u043d\u0430\u0432\u0438\u0436\u0443 \u044d\u0442\u043e. \u042d\u0442\u043e <em>\u043e\u0447\u0435\u043d\u044c<\/em> \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 CakePHP \u0438, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u043e. \u0418\u0434\u0435\u044f, \u0441\u0442\u043e\u044f\u0449\u0430\u044f \u0437\u0430 \u044d\u0442\u0438\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c, \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u0441\u0451, \u0447\u0442\u043e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e \u0447\u0435\u0440\u0435\u0437 echo, \u0438\u043d\u0430\u0447\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043c\u0435\u0449\u0435\u043d\u043e \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u042f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e \u0441\u0442\u0430\u0440\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e (\u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0432 \u043c\u0435\u0442\u043e\u0434 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430), \u043d\u043e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u044f \u0441\u0436\u0438\u0432\u0443\u0441\u044c \u0432 \u044d\u0442\u0438\u043c.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u043d\u043e\u0432\u0438\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443&#8230;<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430\u043c\u0438 \u0438\u043c\u0451\u043d, \u0432\u044b, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0437\u0430\u043a\u0440\u0438\u0447\u0438\u0442\u0435 \u043d\u0430 \u043c\u0435\u043d\u044f, \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u044f \u043f\u043e\u0447\u0435\u043c\u0443 \u044f \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0438\u043b \u043c\u043e\u0434\u0435\u043b\u044c Post. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b, \u0442\u043e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0431\u0443\u0434\u0435\u0442\u0435 \u0443\u0434\u0438\u0432\u043b\u0435\u043d\u044b \u0442\u0435\u043c, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0443. \u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u0430. _\u0412\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0451\u043d \u0432 Yii2_. \u0412\u0441\u0451 \u0447\u0442\u043e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0447\u0451\u0442\u043a\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043e, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0440\u0430\u043d\u0435\u0435.<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0444\u0430\u0439\u043b\u0430 <em>SiteController<\/em>. \u0417\u0430\u0442\u0435\u043c \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443.<\/p>\n<pre><code class=\"php\">use app\\models\\Post;<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0443 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0442\u043e\u0432. \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0444\u0430\u0439\u043b <strong>protected\/views\/site\/index.php<\/strong> \u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"php\">&lt;?php use yii\\helpers\\Html; ?&gt;   &lt;?php echo Html::a('Create New Post', array('site\/create'), array('class' =&gt; 'btn btn-primary pull-right')); ?&gt; &lt;div class=&quot;clearfix&quot;&gt;&lt;\/div&gt; &lt;hr \/&gt; &lt;table class=&quot;table table-striped table-hover&quot;&gt;     &lt;tr&gt;         &lt;td&gt;#&lt;\/td&gt;         &lt;td&gt;Title&lt;\/td&gt;         &lt;td&gt;Created&lt;\/td&gt;         &lt;td&gt;Updated&lt;\/td&gt;         &lt;td&gt;Options&lt;\/td&gt;     &lt;\/tr&gt;     &lt;?php foreach ($data as $post): ?&gt;         &lt;tr&gt;             &lt;td&gt;                 &lt;?php echo Html::a($post-&gt;id, array('site\/read', 'id'=&gt;$post-&gt;id)); ?&gt;             &lt;\/td&gt;             &lt;td&gt;&lt;?php echo Html::a($post-&gt;title, array('site\/read', 'id'=&gt;$post-&gt;id)); ?&gt;&lt;\/td&gt;             &lt;td&gt;&lt;?php echo $post-&gt;created; ?&gt;&lt;\/td&gt;             &lt;td&gt;&lt;?php echo $post-&gt;updated; ?&gt;&lt;\/td&gt;             &lt;td&gt;                 &lt;?php echo Html::a(NULL, array('site\/update', 'id'=&gt;$post-&gt;id), array('class'=&gt;'icon icon-edit')); ?&gt;                 &lt;?php echo Html::a(NULL, array('site\/delete', 'id'=&gt;$post-&gt;id), array('class'=&gt;'icon icon-trash')); ?&gt;             &lt;\/td&gt;         &lt;\/tr&gt;     &lt;?php endforeach; ?&gt; &lt;\/table&gt;<\/code><\/pre>\n<p>  \u0425\u043c\u043c\u043c, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0438\u043d\u0430\u0447\u0435, \u043d\u0435 \u0442\u0430\u043a \u043b\u0438? CHtml::link() \u043f\u0440\u043e\u043f\u0430\u043b\u043e, \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u0433\u043e \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u0445\u0435\u043b\u043f\u0435\u0440 Html. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 CHtml::link \u0438 Html::a \u043d\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f. \u0422\u0430\u043a \u0447\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0439\u0442\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b.<\/p>\n<h5>\u0427\u0438\u0442\u0430\u0435\u043c<\/h5>\n<p>  \u0427\u0442\u0435\u043d\u0438\u0435 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f \u0441 \u043d\u0438\u043c. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432 SiteController \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c:<\/p>\n<pre><code class=\"php\">public function actionRead($id=NULL) {     echo 'HelloWorld'; }<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043a ?r=site\/read&amp;id=1. \u0412\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 <strong>HelloWorld<\/strong> \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435. \u0412\u0438\u0434\u0438\u0442\u0435? \u0425\u043e\u0440\u043e\u0433\u043e. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043d\u0430\u0448 \u043c\u0435\u0442\u043e\u0434 \u0431\u044b\u043b \u0432\u044b\u0437\u0432\u0430\u043d. \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u043d\u043e\u0432\u0438\u043c \u0435\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0431\u0430\u0437\u044b.<\/p>\n<p>  \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c HttpException \u0432 SiteController \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u0440\u043e\u0441\u0430\u0442\u044c HttpException \u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u0442 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d.<\/p>\n<pre><code class=\"php\">use \\yii\\base\\HttpException;<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 read<\/p>\n<pre><code class=\"php\">public function actionRead($id=NULL)     {         if ($id === NULL)             throw new HttpException(404, 'Not Found');           $post = Post::find($id);           if ($post === NULL)             throw new HttpException(404, 'Document Does Not Exist');           echo $this-&gt;render('read', array(             'post' =&gt; $post         ));     }<\/code><\/pre>\n<p>  \u0414\u043b\u044f \u044f\u0441\u043d\u043e\u0441\u0442\u0438, HttpException, \u043f\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443, \u044d\u0442\u043e CHttpException. \u0412\u0441\u0451, \u0447\u0442\u043e \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c, \u044d\u0442\u043e \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u0441\u0442 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c ID \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e. \u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u0442 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d \u043b\u0438\u0431\u043e ID \u043d\u0435 \u0431\u044b\u043b \u0443\u043a\u0430\u0437\u0430\u043d, \u043c\u044b \u0431\u0440\u043e\u0441\u0430\u0435\u043c HttpException.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b <strong>protected\/views\/site\/read.php<\/strong> \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0442\u0430.<\/p>\n<pre><code class=\"php\">&lt;?php use yii\\helpers\\Html; ?&gt; &lt;div class=&quot;pull-right btn-group&quot;&gt;     &lt;?php echo Html::a('Update', array('site\/update', 'id' =&gt; $post-&gt;id), array('class' =&gt; 'btn btn-primary')); ?&gt;     &lt;?php echo Html::a('Delete', array('site\/delete', 'id' =&gt; $post-&gt;id), array('class' =&gt; 'btn btn-danger')); ?&gt; &lt;\/div&gt;   &lt;h1&gt;&lt;?php echo $post-&gt;title; ?&gt;&lt;\/h1&gt; &lt;p&gt;&lt;?php echo $post-&gt;content; ?&gt;&lt;\/p&gt; &lt;hr \/&gt; &lt;time&gt;Created On: &lt;?php echo $post-&gt;created; ?&gt;&lt;\/time&gt;&lt;br \/&gt; &lt;time&gt;Updated On: &lt;?php echo $post-&gt;updated; ?&gt;&lt;\/time&gt;<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u043d\u0430 \u00abExample Post\u00bb. \u0412\u0443\u0430\u043b\u044f! \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u0442\u044b \u0432 \u0431\u043b\u043e\u0433\u0435!<\/p>\n<h5>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435<\/h5>\n<p>  \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u0442\u043e\u0432 \u0442\u0430\u043a \u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u043c \u0438 \u0437\u0430\u0439\u043c\u0451\u043c\u0441\u044f. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043a\u043e\u0434\u043e\u043c:<\/p>\n<pre><code class=\"php\">public function actionDelete($id=NULL) {   }<\/code><\/pre>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0441\u043b\u0435\u0433\u043a\u0430 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441. \u041c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0442\u0430. \u041d\u0430\u0447\u043d\u0451\u043c.<\/p>\n<p>  \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043e\u043f\u0438\u0448\u0435\u043c \u043c\u0435\u0442\u043e\u0434<\/p>\n<pre><code class=\"php\">public function actionDelete($id=NULL) {     if ($id === NULL)     {         Yii::$app-&gt;session-&gt;setFlash('PostDeletedError');         Yii::$app-&gt;getResponse()-&gt;redirect(array('site\/index'));     }       $post = Post::find($id);         if ($post === NULL)     {         Yii::$app-&gt;session-&gt;setFlash('PostDeletedError');         Yii::$app-&gt;getResponse()-&gt;redirect(array('site\/index'));     }       $post-&gt;delete();       Yii::$app-&gt;session-&gt;setFlash('PostDeleted');     Yii::$app-&gt;getResponse()-&gt;redirect(array('site\/index')); }<\/code><\/pre>\n<p>  \u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0439 \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e Yii2. \u041f\u0435\u0440\u0432\u043e\u0435, \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>Yii::$app-&gt;getResponse-&gt;redirect()<\/strong> \u0432\u043c\u0435\u0441\u0442\u043e <strong>$this-&gt;redirect()<\/strong>. \u0414\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0432 \u043f\u043b\u0430\u043d\u0435 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430, \u043d\u043e \u044d\u0442\u043e \u0442\u0430\u043a \u0434\u043e\u043b\u0433\u043e \u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c! \u0412 \u0434\u043e\u0431\u0430\u0432\u043e\u043a, \u044d\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043e\u0449\u0443\u0449\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438 $app. \u0412 \u0442\u043e\u0436\u0435 \u0432\u0440\u0435\u043c\u044f, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u0435\u0436\u043d\u0438\u043c.<\/p>\n<p>  \u0412\u0442\u043e\u0440\u043e\u0435, setFlash \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u0447\u0435\u0440\u0435\u0437 $app \u0432\u043c\u0435\u0441\u0442\u043e app(). \u0412\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0442\u0435\u043f\u0435\u0440\u044c \u043a \u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0432\u044b\u043a\u043d\u0443\u0442\u044c. =)<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438 \u0441 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435\u043c. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u043a <strong>protected\/views\/site\/index.php<\/strong> \u0438 \u043f\u043e\u0439\u043c\u0430\u0435\u043c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0441\u043b\u0430\u043b\u0438.<\/p>\n<p>  \u041f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u044d\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0442\u044d\u0433\u0430 hr<\/p>\n<pre><code class=\"php\">&lt;?php if(Yii::$app-&gt;session-&gt;hasFlash('PostDeletedError')): ?&gt; &lt;div class=&quot;alert alert-error&quot;&gt;     There was an error deleting your post! &lt;\/div&gt; &lt;?php endif; ?&gt;   &lt;?php if(Yii::$app-&gt;session-&gt;hasFlash('PostDeleted')): ?&gt; &lt;div class=&quot;alert alert-success&quot;&gt;     Your post has successfully been deleted! &lt;\/div&gt; &lt;?php endif; ?&gt;<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u00abExample Post\u00bb. \u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u0434\u0430? \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u043f\u043e\u043d\u044f\u043b\u0438 \u0438\u0434\u0435\u044e Yii::$app, \u043f\u0440\u0430\u0432\u0434\u0430?<\/p>\n<h5>\u0421\u043e\u0437\u0434\u0430\u0451\u043c<\/h5>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0432\u0435\u0441\u0451\u043b\u044b\u043c \u0432\u0435\u0449\u0430\u0435\u043c, \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043d\u043e\u0432\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u043d\u0430\u0448\u0435\u043c \u0431\u043b\u043e\u0433\u0435. \u041c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0435\u0449\u0435\u0439 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c ActiveForm \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0444\u043e\u0440\u043c\u043e\u0439. \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043b\u043e\u0432\u0438\u0442\u044c \u0438 \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 $_POST. \u0418, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0431\u0430\u0437\u0443. \u041d\u0430\u0447\u043d\u0451\u043c.<\/p>\n<p>  \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0441\u0434\u0435\u043b\u0430\u0435\u043c view \u0434\u043b\u044f \u0444\u043e\u0440\u043c\u044b. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0444\u0430\u0439\u043b <strong>protected\/views\/site\/create.php<\/strong>. \u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0438\u0434\u0436\u0435\u0442, \u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0430\u043f\u043a\u0443 \u00abassets\u00bb \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0451 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0439 \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0432\u0435\u0431\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c. Chmod 755 \u043e\u0431\u044b\u0447\u043d\u043e \u0440\u0435\u0448\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441. \u0417\u0430\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 SiteController.<\/p>\n<pre><code class=\"php\">public function actionCreate() {     $model = new Post;     if (isset($_POST['Post']))     {         $model-&gt;title = $_POST['Post']['title'];         $model-&gt;content = $_POST['Post']['content'];           if ($model-&gt;save())             Yii::$app-&gt;response-&gt;redirect(array('site\/read', 'id' =&gt; $model-&gt;id));     }       echo $this-&gt;render('create', array(         'model' =&gt; $model     )); }<\/code><\/pre>\n<p>  \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0431\u043e\u043b\u0435\u0435-\u043c\u0435\u043d\u0435\u0435 \u0442\u0430\u043a\u0436\u0435, \u043a\u0430\u043a \u0438 \u0432 Yii1. \u041d\u043e \u0432\u0441\u0451 \u0436\u0435 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0439. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0443 Controller \u0442\u0435\u043f\u0435\u0440\u044c \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u00abpopulate\u00bb ($this-&gt;populate($ds, $model)), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0442\u0435\u043e\u0440\u0438\u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0441 \u043e\u0442 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e \u0443\u0431\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0441 isset($_POST). \u041a\u043e\u0434 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"php\">if ($this-&gt;populate($_POST, $model)) {     \/\/Then do something }<\/code><\/pre>\n<p>  \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u044f \u043d\u0435 \u0441\u043c\u043e\u0433 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438. \u0414\u0430\u043d\u043d\u044b\u0435 \u0432 \u043c\u043e\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e\u0441\u0442\u0430\u0432\u0430\u043b\u0438\u0441\u044c \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u044b\u043c\u0438. \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u044f \u0442\u0430\u043a \u0436\u0435 \u043d\u0435 \u0441\u043c\u043e\u0433 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c $model-&gt;attributes = $_POST[&#8216;Post&#8217;]. ActiveRecord \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u044b\u0440\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043a\u0430 \u0447\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u043d\u043e\u0441\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0440\u0443\u043a\u0430\u043c\u0438.<\/p>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u044f \u043d\u0430\u0442\u043a\u043d\u0443\u043b\u0441\u044f \u043d\u0430 \u0435\u0449\u0451 \u043e\u0434\u043d\u0443 \u043f\u0440\u0435\u0433\u0440\u0430\u0434\u0443 \u2014 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0432 \u0431\u0430\u0437\u0443 \u0441 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c ID. \u0422\u0430\u043a \u0447\u0442\u043e \u0438 \u044d\u0442\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e. \u0415\u0441\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0432\u044b\u044f\u0441\u043d\u0438\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u2014 \u043d\u0435 \u0441\u0442\u0435\u0441\u043d\u044f\u0439\u0442\u0435\u0441\u044c \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0431\u043d\u043e\u0432\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u044c Post, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u041f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432 \u043a\u043e\u043d\u0435\u0446 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code class=\"php\">public function beforeSave($insert) {     if ($this-&gt;isNewRecord)     {         $command = static::getDb()-&gt;createCommand(&quot;select max(id) as id from posts&quot;)-&gt;queryAll();         $this-&gt;id = $command[0]['id'] + 1;     }       return parent::beforeSave($insert); }<\/code><\/pre>\n<p>  \u0412\u0441\u0451 \u0447\u0442\u043e \u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442, \u044d\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043b\u0438 \u043d\u043e\u0432\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0438 \u0435\u0441\u043b\u0438 \u0434\u0430, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 ID \u0438\u0437 \u0431\u0430\u0437\u044b, \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0435\u0433\u043e \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 ID.<\/p>\n<p>  \u042f \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0439 (NULL, 0, _ for $model-&gt;id, \u043d\u043e \u043f\u043e \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c ActiveRecord \u043e\u0442\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0441 ID \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u043c 0. \u0423 \u043c\u0435\u043d\u044f \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043c\u044b\u0441\u043b\u0435\u0439 \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442).<\/p>\n<p>  (<em>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0430\u0432\u0442\u043e\u0440 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0431\u044b\u043b \u0443\u043a\u0430\u0437\u0430\u0442\u044c AUTO_INCREMENT \u0443 \u043f\u043e\u043b\u044f id. \u041d\u043e \u044f \u0440\u0435\u0448\u0438\u043b \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u0443 \u0447\u0430\u0441\u0442\u044c \u043a\u0430\u043a \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0443\u0440\u043e\u043a \u043d\u0435\u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u041f\u0440\u0438\u043c. \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0430.<\/em>)<\/p>\n<p>  \u0421 \u044d\u0442\u0438\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c, \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0451\u043c view.<\/p>\n<pre><code class=\"php\">&lt;?php use yii\\helpers\\Html; ?&gt;   &lt;?php $form = $this-&gt;beginWidget('yii\\widgets\\ActiveForm', array(     'options' =&gt; array('class' =&gt; 'form-horizontal'), )); ?&gt;     &lt;?php echo $form-&gt;field($model, 'title')-&gt;textInput(array('class' =&gt; 'span8')); ?&gt;     &lt;?php echo $form-&gt;field($model, 'content')-&gt;textArea(array('class' =&gt; 'span8')); ?&gt;     &lt;div class=&quot;form-actions&quot;&gt;         &lt;?php echo Html::submitButton('Submit', null, null, array('class' =&gt; 'btn btn-primary')); ?&gt;     &lt;\/div&gt; &lt;?php $this-&gt;endWidget(); ?&gt;<\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0438 \u0432\u0441\u0451, \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c. \u041d\u043e \u043a\u043e\u0435-\u0447\u0442\u043e \u0441\u0442\u0440\u0430\u043d\u043d\u043e, \u043d\u0435 \u0442\u0430\u043a \u043b\u0438? \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u0447\u0435\u043c\u0443 \u0432\u0440\u0435\u043c\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u2014 0? \u0427\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043c \u043f\u0443\u0441\u0442\u0443\u044e \u0444\u043e\u0440\u043c\u0443?<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043c \u044d\u0442\u0438 \u0434\u0432\u0435 \u043e\u0448\u0438\u0431\u043a\u0438, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c. \u041e\u0442\u043a\u0440\u043e\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c Post \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434:<\/p>\n<pre><code class=\"php\">public function rules() {     return array(         array('title, content', 'required'),     ); }<\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u043e\u043b\u044f title \u0438 content \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438, \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043e\u0448\u0438\u0431\u043a\u0443, \u0435\u0441\u043b\u0438 \u043e\u0434\u043d\u043e \u0438\u0437 \u044d\u0442\u0438\u0445 \u043f\u043e\u043b\u0435\u0439 \u043f\u0443\u0441\u0442\u043e\u0435. \u0418 \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c bootstrap, \u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u0447\u0451\u043c <em>\u0438\u043c\u0435\u043d\u043d\u043e<\/em> \u0431\u044b\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435!<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u0435\u0440\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>  \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0449\u0451 \u043e\u0434\u043d\u0443 <strong>use<\/strong>-\u0441\u0442\u0440\u043e\u043a\u0443 \u0432\u0432\u0435\u0440\u0445\u0443 \u043d\u0430\u0448\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<pre><code class=\"php\">use \\yii\\db\\Expression;<\/code><\/pre>\n<p>  \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043e\u0431\u043d\u043e\u0432\u0438\u043c \u043c\u0435\u0442\u043e\u0434 beforeSave \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430.<\/p>\n<p>  \u0412\u043d\u0443\u0442\u0440\u0438 \u0431\u043b\u043e\u043a\u0430 if ($this-&gt;isNewRecord) \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u0442\u0440\u043e\u043a\u0443:<\/p>\n<pre><code class=\"php\">$this-&gt;created = new Expression('NOW()');<\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0434 return parent::beforeSave($insert) \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435:<\/p>\n<pre><code class=\"php\">$this-&gt;updated = new Expression('NOW()');<\/code><\/pre>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 \u043c\u0435\u0442\u043e\u0434 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0432\u0438\u0434:<\/p>\n<pre><code class=\"php\">public function beforeSave($insert) {       if ($this-&gt;isNewRecord)     {         $this-&gt;created = new Expression('NOW()');         $command = static::getDb()-&gt;createCommand(&quot;select max(id) as id from posts&quot;)-&gt;queryAll();         $this-&gt;id = $command[0]['id'] + 1;     }       $this-&gt;updated = new Expression('NOW()');     return parent::beforeSave($insert); }<\/code><\/pre>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0435\u0449\u0451 \u0440\u0430\u0437. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u043b\u044f title \u0438 content, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0432\u0440\u0435\u043c\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f. \u041f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044e.<\/p>\n<h5>\u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c<\/h5>\n<p>  \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u0432 \u0442\u043e\u043c, \u043a\u0430\u043a \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. <\/p>\n<p>  \u0412 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u044b \u0434\u0435\u043b\u0430\u043b\u0438 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"php\">$model = new Post;<\/code><\/pre>\n<p>  \u0412 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"php\">$model = Post::find($id);<\/code><\/pre>\n<p>  \u042f \u043b\u044e\u0431\u043b\u044e \u0431\u0440\u043e\u0441\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u0433\u0434\u0430 \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0451 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0438. \u041f\u043e\u0441\u043b\u0435 \u0438\u0445 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u0434 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043a\u0430\u043a-\u0442\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"php\">public function actionUpdate($id=NULL) {     if ($id === NULL)         throw new HttpException(404, 'Not Found');       $model = Post::find($id);       if ($model === NULL)         throw new HttpException(404, 'Document Does Not Exist');       if (isset($_POST['Post']))     {         $model-&gt;title = $_POST['Post']['title'];         $model-&gt;content = $_POST['Post']['content'];           if ($model-&gt;save())             Yii::$app-&gt;response-&gt;redirect(array('site\/read', 'id' =&gt; $model-&gt;id));     }       echo $this-&gt;render('create', array(         'model' =&gt; $model     )); }<\/code><\/pre>\n<p>  \u0417\u0430\u043c\u0435\u0442\u0438\u043b\u0438 \u043a\u043e\u0435-\u0447\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435? \u041c\u044b \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c view \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d\u0438 <i>\u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b<\/i>. \u041a\u0440\u0443\u0442\u043e, \u0434\u0430?<\/p>\n<h4>\u0412\u044b\u0432\u043e\u0434\u044b<\/h4>\n<p>  \u0418\u0442\u0430\u043a, \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c. \u0417\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u043e\u043c \u043c\u044b \u043f\u0440\u043e\u0448\u043b\u0438 \u043f\u0443\u0442\u044c \u043e\u0442 \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u043d\u0435\u0437\u043d\u0430\u043d\u0438\u044f Yii2 \u043a \u043f\u0440\u043e\u0441\u0442\u043e\u043c\u0443 CRUD-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u043d\u0430 \u043d\u0451\u043c. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u044d\u0442\u0438 \u0437\u043d\u0430\u043d\u0438\u044f, \u0432\u044b \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0432 \u043d\u0435\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e, \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0434\u0430\u0436\u0435 \u043a\u0443\u0434\u0430 \u0431\u043e\u043b\u0435\u0435 \u043c\u043e\u0449\u043d\u044b\u0435 \u0444\u0438\u0447\u0438.<\/p>\n<p>  Yii2 <em>\u043e\u0447\u0435\u043d\u044c<\/em> \u043f\u043e\u0445\u043e\u0436 Yii 1.x, \u043e\u0434\u043d\u0430\u043a\u043e \u0432 \u043d\u0451\u043c \u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. \u0422\u0430\u043a \u043a\u0430\u043a Yii2 \u043f\u043e\u043a\u0430 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u0437\u0430\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d, \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e \u043b\u0438\u0448\u044c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043d\u0430 Github. \u041a\u043e\u0434 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d. \u0418 \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u0435\u0442\u043e\u0434\u044b \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0438 \u043d\u0430 Yii1, \u0442\u043e \u0431\u044b\u043b\u043e \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0442\u043e, \u0447\u0442\u043e \u043c\u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0443\u0436\u043d\u043e.<\/p>\n<p>  \u041a\u0430\u043a \u043c\u044b \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b\u0438, \u0435\u0441\u0442\u044c \u0435\u0449\u0451 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b (\u043b\u0438\u0431\u043e \u0447\u0435\u0440\u0435\u0437 \u043b\u0443\u0447\u0448\u0435\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 ActiveRecord, \u043b\u0438\u0431\u043e \u0447\u0435\u0440\u0435\u0437 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0441\u043b\u043e\u043c\u0430\u043d\u043e).<\/p>\n<h4>\u0421\u0441\u044b\u043b\u043a\u0438<\/h4>\n<p>  <a href=\"https:\/\/github.com\/charlesportwoodii\/yii2-blog-demo\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 Github<\/a><br \/>  <a href=\"http:\/\/yii2.erianna.com\">\u0414\u0435\u043c\u043e<\/a><br \/>  <a href=\"https:\/\/www.erianna.com\/getting-starting-with-yii-framework-2\">\u0418\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f<\/a>        \t\t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/178737\/\"> http:\/\/habrahabr.ru\/post\/178737\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">\n<h4>Disclaimer<\/h4>\n<p>  \u042d\u0442\u043e\u0442 \u0443\u0440\u043e\u043a \u043f\u043e\u043c\u043e\u0436\u0435\u043c \u0432\u0430\u043c \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 Yii2. \u0412 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 Yii2 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043d\u0435 \u0433\u043e\u0442\u043e\u0432 \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0430. \u042f \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445.<\/p>\n<h4>\u041d\u0430\u0447\u043d\u0451\u043c<\/h4>\n<p>  \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0430\u0432\u0442\u043e\u0440\u044b Yii Framework \u0430\u043d\u043e\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e\u0435 \u043f\u0440\u0435\u0432\u044c\u044e Yii2. \u041c\u0435\u0436\u0434\u0443 Yii1 \u0438 Yii2 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<\/p>\n<p>  \u042d\u0442\u043e\u0442 \u0443\u0440\u043e\u043a \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0431\u043b\u043e\u0433\u0430 \u043d\u0430 Yii2. \u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c Yii2, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f, \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f, \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0442\u043e\u0432.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u044f \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f:<\/p>\n<ul>\n<li>\u0412\u0435\u0431\u0441\u0435\u0440\u0432\u0435\u0440, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 Apache \u0438\u043b\u0438 Nginx. \u042f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Nginx. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Apache \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u0432\u043e\u043b\u043d\u0443\u0439\u0442\u0435\u0441\u044c \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0442 \u043f\u043e\u0431\u043b\u0438\u0437\u043e\u0441\u0442\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0441 Nginx.<\/li>\n<li>\u0421\u0435\u0432\u0435\u0440 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u042f \u0432\u044b\u0431\u0440\u0430\u043b MySQL 5.5<\/li>\n<li>\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u043d\u0438\u044f PHP. \u042f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0442\u044c \u0432\u0441\u0451 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u043e \u0447\u0435\u043c \u043b\u0443\u0447\u0448\u0435 \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435 PHP, \u0442\u0435\u043c \u043f\u0440\u043e\u0449\u0435 \u0432\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435.<\/li>\n<li>\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u043d\u0438\u044f Yii \u0438\u043b\u0438 MVC. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u043e\u043f\u044b\u0442\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 MVC, \u0442\u043e \u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0432\u0430\u043c <a href=\"http:\/\/www.yiiframework.com\/doc\/guide\/1.1\/en\/basics.mvc\">\u043f\u0440\u043e\u0447\u0435\u0441\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u044b MVC<\/a>. \u0412\u044b <em>\u043c\u043e\u0436\u0435\u0442\u0435<\/em> \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0443\u0440\u043e\u043a \u0438 \u0431\u0435\u0437 \u0437\u043d\u0430\u043d\u0438\u044f MVC, \u043d\u043e \u0432\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043b\u0435\u0433\u0447\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0435, \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u044e\u0441\u044c \u0432 \u0442\u0435\u043c\u0435 MVC.<\/li>\n<\/ul>\n<p>  \u0412\u043f\u0435\u0440\u0451\u0434!  <\/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-178737","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/178737","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=178737"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/178737\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=178737"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=178737"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=178737"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}