{"id":197254,"date":"2013-10-12T10:46:03","date_gmt":"2013-10-12T06:46:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=197254"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=197254","title":{"rendered":"<span class=\"post_title\">Phalcon PHP \u0444\u0440\u0435\u0439\u043c\u043e\u0440\u043a. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u043c\u0438<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u00abvivo, presto, prestissimo&#8230;\u00bb<\/p>\n<p>  \u041e Phalcon \u043f\u043e\u043a\u0430 \u0435\u0449\u0435 \u043c\u0430\u043b\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432, \u043d\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u0438 \u0437\u0430\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f. \u041e\u0434\u043d\u043e \u0438\u0437 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 Phalcon \u2014 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439. \u041f\u0430\u0440\u0441\u0435\u0440 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 C, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e. \u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u0438 \u043d\u0435\u043f\u0440\u0438\u043d\u0443\u0436\u0434\u0435\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0447\u0430\u0441\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a (\u0447\u0443\u0442\u044c \u043b\u0438 \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c) \u0438\u0437 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u043a\u043e\u0434.<\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<h4>\u0427\u0430\u0441\u0442\u044c I. Vivo (\u0411\u044b\u0441\u0442\u0440\u043e).<\/h4>\n<p>  \u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432 \u0432 Phalcon \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u00ab\u0442\u0432\u043e\u0440\u0447\u0435c\u043a\u0430\u044f\u00bb \u0437\u0430\u0434\u0430\u0447\u0430.<br \/>  \u041c\u043d\u043e\u0433\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u0435\u0441\u0442\u0440\u044f\u0442 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432.<br \/>  \u041d\u0430 \u0425\u0430\u0431\u0440\u0435 \u0434\u0430\u0436\u0435 \u043f\u0440\u043e\u0441\u043a\u043e\u0447\u0438\u043b \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 xml\u2026<br \/>  \u0418 \u044d\u0442\u043e \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f, \u043a\u043e\u0433\u0434\u0430 \u043c\u043d\u043e\u0433\u0438\u0435 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e\u0442 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439.<br \/>  \u0410 \u0447\u0442\u043e \u0436\u0435 Phalcon?<br \/>  Phalcon \u0441\u043a\u0440\u043e\u043c\u043d\u043e \u0438 \u0442\u0438\u0445\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u0447\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u0445.<br \/>  \u0418 \u0447\u0442\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0430\u0432\u0442\u043e\u0440\u044b Phalcon \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043f\u0430\u0440\u0441\u0435\u0440 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u043d\u0430 C.<br \/>  \u0412\u043f\u0435\u0440\u0432\u044b\u0435!<br \/>  \u0427\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439?<br \/>  \u0412\u0441\u0435\u0433\u043e \u043d\u0438\u0447\u0435\u0433\u043e.<br \/>  \u0412 bootstrap \u0444\u0430\u0439\u043b\u0435 \u0432\u043d\u0435\u0434\u0440\u044f\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439, \u0432\u0441\u0435\u0433\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430. \u0418 \u0432\u0441\u0435.  <\/p>\n<pre><code class=\"php\">... \t\/\/set routers  \t$di-&gt;set('router', function() { \t\t$router = new \\Phalcon\\Mvc\\Router\\Annotations(false);         $router-&gt;removeExtraSlashes(true);         $router-&gt;setUriSource(\\Phalcon\\Mvc\\Router::URI_SOURCE_SERVER_REQUEST_URI);         $router-&gt;addResource('Index');         $router-&gt;notFound([                           &quot;controller&quot; =&gt; &quot;index&quot;,                            &quot;action&quot;  =&gt; &quot;page404&quot;         ]);         return $router; \t}); ...<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u044b (\u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0441 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u0430\u043c\u0438), \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u044f\u043c\u043e \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435.  <\/p>\n<pre><code class=\"php\">...   \/**    * @Post(&quot;\/create&quot;)    *\/   public function createAction()   { \t\/...   } ...  <\/code><\/pre>\n<p>  \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u044f (\u0442\u0438\u043f\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043f\u0430\u0440\u0435\u043c\u0435\u0442\u0440\u044b) \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438.<\/p>\n<h4>\u0427\u0430\u0441\u0442\u044c II. Presto (\u0411\u044b\u0441\u0442\u0440\u043e, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e)<\/h4>\n<p>  \u041c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u0445 \u2014 \u044d\u0442\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0445\u043e\u0440\u043e\u0448\u043e. \u041d\u043e \u043d\u0430\u043c \u0435\u0449\u0435 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u043c\u0435\u0442\u044c \u0434\u0435\u043b\u043e \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u0418 \u0437\u0434\u0435\u0441\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u043e\u0434\u043d\u0443 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c Phalcon.<br \/>  \u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442 \u043e\u0431\u044b\u0447\u043d\u043e 3 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<br \/>  1-\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0431\u0430\u0437\u0435.<br \/>  2-\u0439 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b.<br \/>  3-\u0439 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u0430\u043f\u0440\u043e\u0441.<br \/>  \u041d\u0435 \u0437\u043d\u0430\u044e, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u043d\u0435 \u0431\u0443\u0434\u0443 \u0441\u043f\u043e\u0440\u0438\u0442\u044c. \u041d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e.<br \/>  \u041d\u0430\u043c \u0436\u0435 3 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0438 \u043a \u0447\u0435\u043c\u0443. \u041d\u0430\u043c \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0438\u043c\u0435\u0442\u044c \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0433\u0434\u0435-\u0442\u043e \u0432 \u0437\u0430\u0433\u0430\u0448\u043d\u0438\u043a\u0435.<br \/>  \u0412 \u043a\u044d\u0448\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440.<br \/>  \u0418 Phalcon \u0442\u043e\u0433\u043e \u0436\u0435 \u043c\u043d\u0435\u043d\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043a\u044d\u0448\u0435. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438.<br \/>  \u041e\u043f\u044f\u0442\u044c DI, \u043e\u043f\u044f\u0442\u044c botstrap:  <\/p>\n<pre><code class=\"php\">... \t\/\/Set a models manager \t$di-&gt;set('modelsManager', new \\Phalcon\\Mvc\\Model\\Manager());  \t\/\/Set the models cache service \t$di-&gt;set('modelsCache', function() {  \t\t\/\/Cache data for one day by default \t\t$frontCache = new \\Phalcon\\Cache\\Frontend\\Data([ \t\t\t\t\t\t\t&quot;lifetime&quot; =&gt; 86400 \t\t]); \t\t$cache = new \\Phalcon\\Cache\\Backend\\Memcache($frontCache, [ \t\t\t\t\t\t\t\t\t\t\t&quot;host&quot; =&gt; &quot;localhost&quot;, \t\t\t\t\t\t\t\t\t\t\t&quot;port&quot; =&gt; &quot;11211&quot;, \t\t\t\t\t\t\t\t\t\t\t'persistent' =&gt; TRUE, \t\t]); \t\treturn $cache; \t}); \t \t$di-&gt;set('modelsMetadata', function() {  \t\t\/\/ Create a meta-data manager with APC \t\t\/\/$metaData = new \\Phalcon\\Mvc\\Model\\MetaData\\Apc([ \t\t\/\/         &quot;lifetime&quot; =&gt; 86400, \t\t\/\/         &quot;prefix&quot;   =&gt; &quot;general-phsql&quot; \t\t\/\/]); \t\t$metaData = new \\Phalcon\\Mvc\\Model\\MetaData\\Memory([ \t\t\t\t\t\t\t\t\t\t\t'prefix'  =&gt; 'general',         ]); \t\t$metaData-&gt;setStrategy(new StrategyAnnotations()); \t\treturn $metaData; \t}); ... <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e, \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435, \u0441\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0435 \u0435\u0434\u0438\u043d\u043e\u0436\u0434\u044b, \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u043a\u044d\u0448.<br \/>  \u041d\u0430 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p>  \u0417\u0434\u0435\u0441\u044c, \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u0432\u0441\u0435. \u041e\u043f\u044f\u0442\u044c \u0436\u0435, \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438.<\/p>\n<p>  \u0427\u0442\u043e \u0436\u0435, \u043d\u0438\u0447\u0435\u0433\u043e \u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432 \u044d\u0442\u0438\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430\u0445 \u043d\u0435\u0442. \u0417\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e. \u0411\u044b\u0441\u0442\u0440\u043e \u0442\u0430\u043a, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u043e \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u043c \u043d\u0430 C. \u0422\u043e \u0435\u0441\u0442\u044c, \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435\u0437\u0430\u043c\u0435\u0442\u043d\u043e.<br \/>  \u041d\u043e \u044d\u0442\u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u0435\u0441\u0442\u044c \u0438 \u0443 \u0434\u0440\u0443\u0433\u0438\u0445 \u0444\u0440\u0435\u0439\u043c\u043e\u0440\u043a\u043e\u0432.<br \/>  \u041d\u0430\u043c \u0436\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0447\u0435\u0433\u043e-\u0442\u043e \u0432\u043a\u0443\u0441\u043d\u0435\u043d\u044c\u043a\u043e\u0433\u043e, \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0438\u0437\u044e\u043c\u0438\u043d\u043a\u0438\u2026<\/p>\n<h4>\u0427\u0430\u0441\u0442\u044c III. Prestissimo (\u0415\u0449\u0435 \u0431\u044b\u0441\u0442\u0440\u0435\u0435).<\/h4>\n<p>  \u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u043d\u0435 \u0441\u0435\u043a\u0440\u0435\u0442, \u0447\u0442\u043e \u043f\u0440\u0438 \u043f\u0440\u043e\u044d\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u0430\u0439\u0442\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0430\u0434\u043c\u0438\u043d\u043a\u0443.<br \/>  \u0410 \u044d\u0442\u043e \u0444\u043e\u0440\u043c\u044b, \u0444\u043e\u0440\u043c\u044b, \u0438 \u0435\u0449\u0435 \u0440\u0430\u0437 \u0444\u043e\u0440\u043c\u044b. \u041c\u043d\u043e\u0433\u043e \u0444\u043e\u0440\u043c. \u0410 \u044d\u0442\u043e \u0443\u0442\u043e\u043c\u043b\u044f\u0435\u0442\u2026<br \/>  \u0425\u043e\u0447\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438.<br \/>  \u0418\u0437 \u0447\u0435\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0444\u043e\u0440\u043c\u0430? \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u2014 \u044d\u0442\u043e \u0442\u044d\u0433 input.<br \/>  \u041e\u043d, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f type, \u0434\u043b\u0438\u043d\u0443 length, \u0448\u0430\u0431\u043b\u043e\u043d \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f pattern \u0438 \u0442.\u0434.<br \/>  \u0418 \u0432\u0441\u0435 \u044d\u0442\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0444\u043e\u0440\u043c\u044b \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c\u2026 \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b\u2026<br \/>  \u0425\u043e\u0447\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. <br \/>  \u0410 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443 \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438.<br \/>  \u0418 \u0437\u0434\u0435\u0441\u044c \u043d\u0430\u043c \u043e\u043f\u044f\u0442\u044c \u043f\u0440\u0438\u0433\u043e\u0434\u044f\u0442\u0441\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438. \u041f\u0430\u0440\u0441\u0435\u0440, \u043e\u043f\u044f\u0442\u044c \u0436\u0435, \u043d\u0430 C.<br \/>  Phalcon \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Phalcon\\Forms\\Form.<br \/>  \u0412\u043e\u0437\u044c\u043c\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 Users. \u0415\u0435 \u043c\u043e\u0434\u0435\u043b\u044c:  <\/p>\n<pre><code class=\"php\">&lt;?php namespace Frontend\\Model;  class Users extends \\Phalcon\\Mvc\\Model {   \/**    * @Primary    * @Identity    * @Column(type=&quot;integer&quot;, nullable=false)    * @FormOptions(type=hidden)    *\/   public $id;   \/**    * @Column(type=&quot;string&quot;, nullable=false)    * @FormOptions(type=text, length=32)    *\/   public $name;   \/**    * @Column(type=&quot;integer&quot;, nullable=false)    * @FormOptions(type=email)    *\/   public $email;   \/**    * @Column(type=&quot;integer&quot;, nullable=false)    * @FormOptions(type=text, length=9, pattern='[0-9]{9}')    *\/   public $indcode; } <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e, \u0433\u0434\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u043d\u0430\u043c \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0444\u043e\u0440\u043c\u044b \u043e\u043f\u0446\u0438\u0438.<br \/>  \u0414\u0430, \u044d\u0442\u0443 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e \u043c\u044b \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b\u0438 \u0441\u0435\u0439\u0447\u0430\u0441, \u0441\u0430\u043c\u0438, \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435.<br \/>  \u0423 \u043d\u0430\u0441 \u044d\u0442\u043e @FormOptions. \u0412 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0435 type \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0442\u0438\u043f \u043f\u043e\u043b\u044f, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043d\u0430\u043c \u0434\u043b\u044f input.<br \/>  Phalcon \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0442\u0438\u043f\u044b <i>Phalcon\\Forms\\Element <\/i>:<br \/>  <b>Phalcon\\Forms\\Element\\Check<br \/>  Phalcon\\Forms\\Element\\Date<br \/>  Phalcon\\Forms\\Element\\Email<br \/>  Phalcon\\Forms\\Element\\File<br \/>  Phalcon\\Forms\\Element\\Hidden<br \/>  Phalcon\\Forms\\Element\\Numeric<br \/>  Phalcon\\Forms\\Element\\Password<br \/>  Phalcon\\Forms\\Element\\Select<br \/>  Phalcon\\Forms\\Element\\Submit<br \/>  Phalcon\\Forms\\Element\\Text<br \/>  Phalcon\\Forms\\Element\\TextArea<\/b><br \/>  \u0411\u043e\u043b\u0435\u0435, \u0447\u0435\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e.<br \/>  \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0434\u0435\u043b\u043e \u0437\u0430 \u043c\u0430\u043b\u044b\u043c\u2026<br \/>  \u041d\u0443\u0436\u043d\u043e \u043a\u0430\u043a-\u0442\u043e \u00ab\u043d\u0430\u0443\u0447\u0438\u0442\u044c\u00bb Phalcon \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438\u2026<br \/>  \u041d\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u043f\u0440\u043e\u0449\u0435!<br \/>  bootstrap \u2014 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043f\u0430\u0440\u0441\u0435\u0440 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439.  <\/p>\n<pre><code class=\"php\">... \t\/\/Annotations \t$di-&gt;set('annotations', function() { \t\treturn new \\Phalcon\\Annotations\\Adapter\\Memory(); \t});  ... <\/code><\/pre>\n<p>  \u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u043f\u0430\u043c\u044f\u0442\u0438, <br \/>  \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0432 \u0444\u0430\u0439\u043b\u0430\u0445, APC, XCache. <br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441 \u0444\u043e\u0440\u043c\u044b \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043b\u0430\u0441\u0441 \u0444\u043e\u0440\u043c\u044b<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">&lt;?php use Phalcon\\Forms\\Form,     \\Phalcon\\Forms\\Element\\Submit as Submit;  class EntityForm extends Form {   public $fields = [];   private $classprefix = '\\\\Phalcon\\\\Forms\\\\Element\\\\';   public $action;   \/**    * @param object $model, action    *\/   public function initialize($model, $action)   {     $this-&gt;action = $action;     \/\/\u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043f\u043e\u043b\u044f \u0444\u043e\u0440\u043c\u044b \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438\u0437 \u043c\u043e\u0434\u0435\u043b\u0438     $object = $model;     $this-&gt;setEntity($object); \t\/\/\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u043c\u043e\u0434\u0435\u043b\u0438     $attributes = $this-&gt;modelsMetadata-&gt;getAttributes($object); \t\/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0438\u0437 \u043c\u043e\u0434\u0435\u043b\u0438      $metadata = $this-&gt;annotations-&gt;get($object); \t\/\/ \u0421\u0447\u0438\u0442\u044b\u0430\u0435\u043c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e @FormOptions     foreach ( $attributes as $attribute ) {       $this-&gt;fields[$attribute] = $metadata                               -&gt;getPropertiesAnnotations()[$attribute]                               -&gt;get('FormOptions')                               -&gt;getArguments();     } \t\/\/ \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u043e\u043b\u044f \u0444\u043e\u0440\u043c\u044b \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438     foreach ($this-&gt;fields as $field  =&gt; $type) {       $fieldtype = array_shift($type); \/\/ \u0430\u0442\u0440\u0438\u0431\u0443\u0442 type \u0432 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u043d\u0430\u043c \u0431\u043e\u043b\u0435\u0435 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d       $fieldclass = $this-&gt;classprefix.$fieldtype;       $this-&gt;add(new $fieldclass($field, $type)); \t  \/\/\u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c label \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u0435 \u043d\u0435 \u0441\u043a\u0440\u044b\u0442\u043e       if ( $fieldtype !== 'hidden') {         $this-&gt;get($field)-&gt;setLabel($this-&gt;get($field)-&gt;getName());       }     } \t\/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043d\u043e\u043f\u043a\u0443 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438     $this-&gt;add(new Submit('submit',[           'value' =&gt; 'Send',           ]));   }    public function renderform()   {     echo $this-&gt;tag-&gt;form([         $this-&gt;action,         'id'  =&gt; 'actorform',         ]);     \/\/fill form tags     foreach ($this as $element) {       \/\/ collect messages        $messages = $this-&gt;getMessagesFor($element-&gt;getName());       if (count($messages)) {         \/\/ each element render         echo '&lt;div class=&quot;messages&quot;&gt;';         foreach ($messages as $message) {           echo $message;         }         echo '&lt;\/div&gt;';       }       echo '&lt;div&gt;';       echo '&lt;label for=&quot;', $element-&gt;getName(), '&quot;&gt;', $element-&gt;getLabel(), '&lt;\/label&gt;';       echo $element;       echo '&lt;\/div&gt;';     }     echo $this-&gt;tag-&gt;endForm();   } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0417\u0434\u0435\u0441\u044c, \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 EntityForm \u043c\u044b \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u0435\u0433\u043e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438.<br \/>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u043d\u0435\u0434\u0440\u044f\u0435\u043c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u043e\u043b\u044f \u0432 \u0444\u043e\u0440\u043c\u0443.<br \/>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f renderform \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043d\u0430\u0448\u0443 \u0444\u043e\u0440\u043c\u0443 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440.<\/p>\n<p>  \u0412\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440, \u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0432\u044b\u0432\u043e\u0434\u0430 \u0444\u043e\u0440\u043c\u044b:  <\/p>\n<pre><code class=\"php\">...   \/**    * @Get(&quot;\/form&quot;)    *\/   public function formAction()   {     $myform = new EntityForm(new Users(), 'create');     $this-&gt;view-&gt;setVars([         'myform'  =&gt; $myform,         ]);   } ... <\/code><\/pre>\n<p>  \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u044f:  <\/p>\n<pre><code class=\"php\">...   \/**    * @Post(&quot;\/create&quot;)    *\/   public function createAction()   {     echo '&lt;pre&gt;';     var_dump($_POST);     echo '&lt;\/pre&gt;';   } ... <\/code><\/pre>\n<p>  \u041e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0435 \u0432\u044b\u0432\u043e\u0434\u0430 (Volt) \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0444\u043e\u0440\u043c\u0443:<br \/>  <code>&lt;b&gt;{{ myform.renderform() }}&lt;\/b&gt;<\/code><br \/>  \u0412\u043e\u0442 \u0438 \u0432\u0441\u0435.<br \/>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043a\u043b\u0430\u0441\u0441 \u0444\u043e\u0440\u043c\u044b CSRF-\u0437\u0430\u0449\u0438\u0442\u0443, \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445, \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435.<br \/>  \u041d\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443 \u0438 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0432 Phalcon.<br \/>  \u042d\u0442\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u0430\u043c \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043c\u043e\u0449\u043d\u043e\u043c\u0443 \u0438 \u0431\u044b\u0441\u0442\u0440\u043e\u043c\u0443 \u043f\u0430\u0440\u0441\u0435\u0440\u0443 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 PhalconPHP.<br \/>  \u0418, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0448\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Phalcon, \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0448\u044c, \u0447\u0442\u043e \u043e\u043d \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440.<br \/>  \u0418 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0432\u044b\u0432\u043e\u0434\u0435 \u00abHello, world!\u00bb.<br \/>  \u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0438 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Phalcon \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0440\u0430\u0436\u0430\u044e\u0442.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">index.php<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">&lt;?php use Phalcon\\Mvc\\View\\Engine\\Volt; use Phalcon\\Mvc\\Model\\MetaData\\Strategy\\Annotations as StrategyAnnotations; try { \t\/\/Register an autoloader \t$loader = new \\Phalcon\\Loader(); \t$loader-&gt;registerDirs([ \t\t\t\t'..\/app\/controllers\/', \t\t\t\t'..\/app\/models\/', \t\t\t\t'..\/app\/forms\/' \t]); \t$loader-&gt;registerNamespaces([ \t\t\t\t'Frontend\\\\Model'  =&gt; __DIR__.'\/..\/app\/models\/',     ]); \t$loader-&gt;register(); \t\/\/Create a DI \t$di = new \\Phalcon\\DI\\FactoryDefault();    \t\/\/Set a models manager \t$di-&gt;set('modelsManager', new \\Phalcon\\Mvc\\Model\\Manager());  \t\/\/Set the models cache service \t$di-&gt;set('modelsCache', function() {  \t\t\/\/Cache data for one day by default \t\t$frontCache = new \\Phalcon\\Cache\\Frontend\\Data([ \t\t\t\t\t\t\t&quot;lifetime&quot; =&gt; 86400 \t\t]); \t\t$cache = new \\Phalcon\\Cache\\Backend\\Memcache($frontCache, [ \t\t\t\t\t\t\t\t\t\t\t&quot;host&quot; =&gt; &quot;localhost&quot;, \t\t\t\t\t\t\t\t\t\t\t&quot;port&quot; =&gt; &quot;11211&quot;, \t\t\t\t\t\t\t\t\t\t\t'persistent' =&gt; TRUE, \t\t]); \t\treturn $cache; \t}); \t \t$di-&gt;set('modelsMetadata', function() {  \t\t\/\/ Create a meta-data manager with APC \t\t\/\/$metaData = new \\Phalcon\\Mvc\\Model\\MetaData\\Apc([ \t\t\/\/         &quot;lifetime&quot; =&gt; 86400, \t\t\/\/         &quot;prefix&quot;   =&gt; &quot;general-phsql&quot; \t\t\/\/]); \t\t$metaData = new \\Phalcon\\Mvc\\Model\\MetaData\\Memory([ \t\t\t\t\t\t\t\t\t\t\t'prefix'  =&gt; 'general',         ]); \t\t$metaData-&gt;setStrategy(new StrategyAnnotations()); \t\treturn $metaData; \t});   \t\/\/SQL profiler \t$di-&gt;set('profiler', function(){ \t\treturn new \\Phalcon\\Db\\Profiler();     }, true); \t\/\/set database connection \t$di-&gt;set('db', function() use ($di) { \t\t$eventsManager = new \\Phalcon\\Events\\Manager();  \t\t\/\/Get a shared instance of the DbProfiler \t\t$profiler = $di-&gt;getProfiler();  \t\t\/\/Listen all the database events \t\t$eventsManager-&gt;attach('db', function($event, $connection) use ($profiler) { \t\t\tif ($event-&gt;getType() == 'beforeQuery') { \t\t\t\t$profiler-&gt;startProfile($connection-&gt;getSQLStatement()); \t\t\t} \t\t\tif ($event-&gt;getType() == 'afterQuery') { \t\t\t\t$profiler-&gt;stopProfile(); \t\t\t} \t\t});  \t\t$connection = new \\Phalcon\\Db\\Adapter\\Pdo\\Mysql([ \t\t\t\t\t\t\t\t\t\t\t&quot;host&quot; =&gt; &quot;localhost&quot;, \t\t\t\t\t\t\t\t\t\t\t&quot;username&quot; =&gt; &quot;root&quot;, \t\t\t\t\t\t\t\t\t\t\t&quot;password&quot; =&gt; &quot;12345&quot;, \t\t\t\t\t\t\t\t\t\t\t&quot;dbname&quot; =&gt; &quot;general&quot; \t\t]);  \t\t\/\/Assign the eventsManager to the db adapter instance \t\t$connection-&gt;setEventsManager($eventsManager);  \t\treturn $connection; \t}); \t\/\/Register Volt as a service \t$di-&gt;set('voltService', function($view, $di) { \t\t$volt = new Volt($view, $di);  \t\t$volt-&gt;setOptions([ \t\t\t&quot;compiledPath&quot; =&gt; &quot;..\/app\/cache\/&quot;,         ]);  \t\treturn $volt; \t});  \t\/\/Setting up the view component \t$di-&gt;set('view', function(){ \t\t$view = new \\Phalcon\\Mvc\\View(); \t\t$view-&gt;setViewsDir('..\/app\/views\/'); \t\t$view-&gt;registerEngines([ \t\t\t\t\t\t&quot;.volt&quot; =&gt; 'voltService'         ]); \t\treturn $view; \t});  \t\/\/Create Form manager \t$di-&gt;set('forms', function() { \t\t$forms = new \\Phalcon\\Forms\\Manager(); \t\treturn $forms; \t});  \t$di-&gt;set('session', function() use($di) { \t\t$session = new Phalcon\\Session\\Adapter\\Files();         $session-&gt;setoptions([ \t\t\t\t\t'uniqueId'  =&gt; 'privatRsc',         ]);         $session-&gt;start();         return $session; \t});  \t\/\/set routers  \t$di-&gt;set('router', function() { \t\t$router = new \\Phalcon\\Mvc\\Router\\Annotations(false);         $router-&gt;removeExtraSlashes(true);         $router-&gt;setUriSource(\\Phalcon\\Mvc\\Router::URI_SOURCE_SERVER_REQUEST_URI);         $router-&gt;addResource('Index');         $router-&gt;notFound([ \t\t\t\t\t\t&quot;controller&quot;\t=&gt; &quot;index&quot;, \t\t\t\t\t\t&quot;action&quot;\t\t=&gt; &quot;page404&quot; \t\t]);         return $router; \t}); \t \t\/\/Annotations \t$di-&gt;set('annotations', function() { \t\treturn new \\Phalcon\\Annotations\\Adapter\\Memory(); \t});    \t\/\/Handle the request \t$application = new \\Phalcon\\Mvc\\Application($di);  \techo $application-&gt;handle()-&gt;getContent();  } catch(\\Phalcon\\Exception $e) { \techo &quot;PhalconException: &quot;, $e-&gt;getMessage(); } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">IndexController.php<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">&lt;?php  use \\Frontend\\Model\\Users as Users;  \/**  * @RoutePrefix(&quot;&quot;)  **\/  class IndexController extends \\Phalcon\\Mvc\\Controller {   \/**    * @Get(&quot;\/&quot;)    *\/   public function indexAction()   {     echo &lt;h3&gt;Index Action&lt;\/h3&gt;;   }   \/**    * @Get(&quot;\/form&quot;)    *\/   public function formAction()   {     $myform = new EntityForm(new Users(), 'create');     $this-&gt;view-&gt;setVars([         'myform'  =&gt; $myform,         ]);   }    \/**    * @Post(&quot;\/create&quot;)    *\/   public function createAction()   {     echo '&lt;pre&gt;';     var_dump($_POST);     echo '&lt;\/pre&gt;';   }    \/**    * @Get(&quot;\/page404&quot;)    *\/   public function page404Action()   {     echo '404 - route not found';   } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">EntityForm.php<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">&lt;?php use Phalcon\\Forms\\Form,     \\Phalcon\\Forms\\Element\\Submit as Submit;  class EntityForm extends Form {   public $fields = [];   private $classprefix = '\\\\Phalcon\\\\Forms\\\\Element\\\\';   public $action;   \/**    * @param object $model, action    *\/   public function initialize($model, $action)   {     $this-&gt;action = $action;     \/\/Set fields options from annotations     $object = $model;     $this-&gt;setEntity($object);     $attributes = $this-&gt;modelsMetadata-&gt;getAttributes($object);      $metadata = $this-&gt;annotations-&gt;get($object);     foreach ( $attributes as $attribute ) {       $this-&gt;fields[$attribute] = $metadata                               -&gt;getPropertiesAnnotations()[$attribute]                               -&gt;get('FormOptions')                               -&gt;getArguments();     }     foreach ($this-&gt;fields as $field  =&gt; $type) {       $fieldtype = array_shift($type);       $fieldclass = $this-&gt;classprefix.$fieldtype;       $this-&gt;add(new $fieldclass($field, $type));       if ( $fieldtype !== 'hidden') {         $this-&gt;get($field)-&gt;setLabel($this-&gt;get($field)-&gt;getName());       }     }     $this-&gt;add(new Submit('submit',[           'value' =&gt; 'Send',           ]));   }    public function renderform()   {     echo $this-&gt;tag-&gt;form([         $this-&gt;action,         'id'  =&gt; 'actorform',         ]);     \/\/fill form tags     foreach ($this as $element) {       \/\/ collect messages        $messages = $this-&gt;getMessagesFor($element-&gt;getName());       if (count($messages)) {         \/\/ each element render         echo '&lt;div class=&quot;messages&quot;&gt;';         foreach ($messages as $message) {           echo $message;         }         echo '&lt;\/div&gt;';       }       echo '&lt;div&gt;';       echo '&lt;label for=&quot;', $element-&gt;getName(), '&quot;&gt;', $element-&gt;getLabel(), '&lt;\/label&gt;';       echo $element;       echo '&lt;\/div&gt;';     }     echo $this-&gt;tag-&gt;endForm();   } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Users.php<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">&lt;?php namespace Frontend\\Model;  class Users extends \\Phalcon\\Mvc\\Model {   \/**    * @Primary    * @Identity    * @Column(type=&quot;integer&quot;, nullable=false)    * @FormOptions(type=hidden)    *\/   public $id;   \/**    * @Column(type=&quot;string&quot;, nullable=false)    * @FormOptions(type=text, length=32)    *\/   public $name;   \/**    * @Column(type=&quot;integer&quot;, nullable=false)    * @FormOptions(type=email)    *\/   public $email;   \/**    * @Column(type=&quot;integer&quot;, nullable=false)    * @FormOptions(type=text, length=9, pattern='[0-9]{9}')    *\/   public $indcode; } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">form.volt<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"html\">&lt;h2&gt;Test form in Volt&lt;\/h2&gt; &lt;hr&gt; {{ myform.renderform() }} &lt;hr&gt; <\/code><\/pre>\n<\/div>\n<\/div>\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\/197254\/\"> http:\/\/habrahabr.ru\/post\/197254\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u00abvivo, presto, prestissimo&#8230;\u00bb<\/p>\n<p>  \u041e Phalcon \u043f\u043e\u043a\u0430 \u0435\u0449\u0435 \u043c\u0430\u043b\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432, \u043d\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u0438 \u0437\u0430\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f. \u041e\u0434\u043d\u043e \u0438\u0437 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 Phalcon \u2014 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439. \u041f\u0430\u0440\u0441\u0435\u0440 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 C, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e. \u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u0438 \u043d\u0435\u043f\u0440\u0438\u043d\u0443\u0436\u0434\u0435\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0447\u0430\u0441\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a (\u0447\u0443\u0442\u044c \u043b\u0438 \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c) \u0438\u0437 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u043a\u043e\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-197254","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/197254","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=197254"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/197254\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=197254"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=197254"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=197254"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}