{"id":280383,"date":"2016-11-02T20:05:04","date_gmt":"2016-11-02T17:05:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=280383"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=280383","title":{"rendered":"\u041a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0441 PHPixie Console"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/7cd\/47c\/66c\/7cd47c66c5df9f4b83f7886240a1cba2.png\" alt=\"image\" align=\"right\"\/><br \/>  PHPixie Console \u2014 \u044d\u0442\u043e \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c, \u0440\u043e\u0443\u0442\u0438\u0442\u044c \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u041a\u0430\u043a \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u0435\u0437 \u0441\u0430\u043c\u043e\u0439 PHPixie \u043a\u0430\u043a \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438\u0437 Symfony.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0410\u043f\u0433\u0440\u0435\u0439\u0434 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432<\/b><\/p>\n<div class=\"spoiler_text\">\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c PHPixie \u043f\u0440\u043e\u0435\u043a\u0442, \u0442\u043e \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b Console \u043d\u0430\u0434\u043e \u0432\u043d\u0435\u0441\u0442\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439:<\/p>\n<ol>\n<li>\u0421\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 <a href=\"https:\/\/github.com\/PHPixie\/Project\/blob\/master\/console\">https:\/\/github.com\/PHPixie\/Project\/blob\/master\/console<\/a> \u0432 \u043a\u043e\u0440\u0435\u043d\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0430 \u043b\u0438\u043d\u0443\u043a\u0441\u0435 \u0442\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u043f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 (chmod +x console)<\/li>\n<li>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 <i>\u00abphpixie\/framework-bundle\u00bb: &quot;~3.0&quot;<\/i> \u0432 composer.json<\/li>\n<li>\u041f\u043e\u043a\u043b\u044e\u0447\u0438\u0442\u0435 \u0431\u0430\u043d\u0434\u043b <i>\\PHPixie\\FrameworkBundle<\/i> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 <i>\/*GeneratorPlaceholder*\/<\/i><br \/>  \u043a\u0430\u043a \u0442\u0443\u0442: <a href=\"https:\/\/github.com\/PHPixie\/Project\/blob\/master\/src\/Project\/Framework\/Bundles.php\">https:\/\/github.com\/PHPixie\/Project\/blob\/master\/src\/Project\/Framework\/Bundles.php<\/a><\/li>\n<\/ol>\n<p>  \u041e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u0443\u044e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0438 \u0434\u0435\u043c\u043e-\u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0441 \u043d\u043e\u0432\u043e\u043d\u043e \u0441\u043a\u0435\u043b\u0435\u0442\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<\/p>\n<ol>\n<li><a href=\"https:\/\/github.com\/PHPixie\/Framework-Bundle\/blob\/master\/assets\/bundleTemplate\/src\/NamespacePlaceholder\/BundleNamePlaceholder\/Console.php\">Console.php<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/PHPixie\/Framework-Bundle\/blob\/master\/assets\/bundleTemplate\/src\/NamespacePlaceholder\/BundleNamePlaceholder\/Console\/Greet.php\">Console\/Greet.php<\/a><\/li>\n<li>\u0412 Builder \u043a\u043b\u0430\u0441\u0441\u0435 \u0431\u0430\u043d\u0434\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u0435 \u043a\u043b\u0430\u0441\u0441 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043a\u0430\u043a \u0442\u0443\u0442: <a href=\"https:\/\/github.com\/PHPixie\/Framework-Bundle\/blob\/master\/assets\/bundleTemplate\/src\/NamespacePlaceholder\/BundleNamePlaceholder\/Builder.php#L32\">Builder.php<\/a><\/li>\n<\/ol>\n<p>  \u0412\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0435 <i>NamespacePlaceholder<\/i> \u043d\u0430 \u043d\u0435\u0439\u043c\u0441\u043f\u0435\u0439\u0441 \u0441\u0432\u043e\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e <i>Project<\/i>) \u0438 <i>BundleNamePlaceholder<\/i> \u043d\u0430 \u0438\u043c\u044f \u0441\u0432\u043e\u0435\u0433\u043e \u0431\u0430\u043d\u0434\u043b\u0430 (\u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e <i>App<\/i>).<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u0430\u0448\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0430\u044f-\u0436\u0435 \u043a\u0430\u043a \u0443 \u0441\u0432\u0435\u0436\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430.  <\/div>\n<\/div>\n<p>  <b>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435<\/b><\/p>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0447\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434:<\/p>\n<pre><code class=\"bash\">cd your_project_directory\/  .\/console # \u0438\u043b\u0438 php .\/console <\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0438\u043c:<\/p>\n<pre><code class=\"bash\">Available commands:  app:greet                     Greet the user framework:installWebAssets    Symlink or copy bundle web files to the projects web folder framework:generateBundle      Generate a new bundle help                          Print command list and usage <\/code><\/pre>\n<p>  \u041a\u043e\u043c\u0430\u043d\u0434\u0430 <i>help<\/i> \u043f\u043e\u043a\u0430\u0436\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432:<\/p>\n<pre><code class=\"bash\">.\/console help framework:installWebAssets  framework:installWebAssets [ --copy ] Symlink or copy bundle web files to the projects web folder  Options: copy    Whether to copy web directories instead of symlinking them <\/code><\/pre>\n<p>  <b>\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/b><\/p>\n<ul>\n<li><b>framework:installWebAssets<\/b> \u2014 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u044f\u0440\u043b\u044b\u043a\u0438 \u0432 \u043f\u0430\u043f\u043a\u0435 <i>\/web\/bundles<\/i> \u0443\u043a\u0430\u0437\u0443\u044e\u0449\u0438\u0435 \u043d\u0430 <i>\/web<\/i> \u043f\u0430\u043f\u043a\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u0431\u0430\u043d\u0434\u043b\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \/web\/bundles\/app -&gt; \/bundles\/app\/web. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0431\u0430\u043d\u0434\u043b\u044b \u0438\u043d\u0441\u0442\u0430\u043b\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u043f\u043e\u0437\u0435\u0440\u0430 \u043c\u043e\u0433\u043b\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u0432\u0435\u0431 \u0444\u0430\u0439\u043b\u044b. \u0424\u043b\u0430\u0436\u043e\u043a <i>&#8212;copy<\/i> \u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0444\u0430\u0439\u043b\u044b \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u044f\u0440\u043b\u044b\u043a\u043e\u0432. \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0430\u0440\u0445\u0438\u0432\u0430 \u0434\u043b\u044f CDN.<\/li>\n<li><b>framework:generateBundle<\/b> \u2014 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0431\u0430\u043d\u0434\u043b \u0432 \u043f\u0440\u043e\u0435\u043a\u0442. \u0411\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u0430\u043d\u0434\u043b\u044b \u043f\u0443\u0442\u0435\u043c \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e.<\/li>\n<\/ul>\n<p>  <b>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434<\/b><\/p>\n<p>  \u0423 \u0432\u0430\u0441 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0443\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <i>app:greet<\/i>. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044e HTTP \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u043b\u0430\u0441\u0441 <i>\\Project\\App\\Console<\/i>. \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u043c\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <i>commandNames()<\/i> \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <i>build&lt;command_name&gt;Command<\/i>.<\/p>\n<p>  \u0412 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0434\u0430\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<pre><code class=\"php\">namespace Project\\App\\Console;  class Greet extends \\PHPixie\\Console\\Command\\Implementation {     public function __construct($config)     {         \/\/ \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435         $config-&gt;description('Greet the user');          \/\/ \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 'message'         $config-&gt;argument('message')             -&gt;description(&quot;Message to display&quot;);          parent::__construct($config);     }      \/**      * \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b.      * $argumentData \u0438 $optionData \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0442\u0430\u043a \u0436\u0435      * \u043a\u0430\u043a HTTP $request-&gt;query() \u0438 $request-&gt;data()      *\/     public function run($argumentData, $optionData)     {         $message = $argumentData-&gt;get('message', &quot;Have fun coding!&quot;);         $this-&gt;writeLine($message);     } } <\/code><\/pre>\n<p>  <b>\u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0438 \u043e\u043f\u0446\u0438\u0438<\/b><\/p>\n<p>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre><code class=\"bash\">sqldump --user=root --skip-missing -f myDatabase users items <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c <i>myDatabase<\/i> \u0438\u043c\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0437\u0430 \u043d\u0435\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0442\u0430\u0431\u043b\u0438\u0446 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u0431\u044b \u0437\u0430\u0431\u0435\u043a\u0430\u043f\u0438\u0442\u044c. \u042d\u0442\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043d\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0410 <i>user<\/i>, <i>skip-missing<\/i>, \u0438 <i>f<\/i> \u043e\u043f\u0446\u0438\u0438. \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435 \u0447\u0442\u043e \u0434\u043b\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u0430\u0436\u0435\u043d \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d\u0438 \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f, \u0430 \u0434\u043b\u044f \u043e\u043f\u0446\u0438\u0439 \u043d\u0435\u0442. \u0422\u0430\u043a\u0436\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0435 \u043e\u043f\u0446\u0438\u0438 \u0441 \u043e\u0434\u043d\u043e\u0439 \u0431\u0443\u043a\u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043e\u0434\u0438\u043d \u0437\u043d\u0430\u043a <i>&#8212;<\/i> \u0432\u043c\u0435\u0441\u0442\u043e \u0434\u0432\u0443\u0445.<\/p>\n<p>  \u0412 \u043a\u043e\u0434\u0435 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"php\">$config-&gt;option('user')      \/\/\u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043e\u043f\u0446\u0438\u044f     -&gt;required()      \/\/\u0415\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435, \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b 'help'     -&gt;description(&quot;User to connect to the database with&quot;);  $config-&gt;option('skip-missing')     -&gt;description(&quot;Don't throw an error if the tables are missing&quot;)      \/\/\u0417\u0430\u0434\u0430\u0442\u044c \u043e\u043f\u0446\u0438\u044e \u043a\u0430\u043a \u0444\u043b\u0430\u0436\u043e\u043a.     \/\/\u041e\u043f\u0446\u0438\u044f\u043c-\u0444\u043b\u0430\u0436\u043a\u0430\u043c \u043d\u0435 \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435,     \/\/\u0432\u0437\u0430\u043c\u0435\u043d \u043e\u043d\u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 'true' \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442.     -&gt;flag();  $config-&gt;option('f')     -&gt;flag()     -&gt;description(&quot;Force database dump&quot;); <\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0430\u0434\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u044c \u0447\u0442\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0445 \u043d\u0430\u0434\u043e \u0432 \u0442\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <i>database<\/i> \u0438\u0434\u0435\u0438 \u043f\u0435\u0440\u0435\u0434 <i>tables<\/i>:<\/p>\n<pre><code class=\"php\">$config-&gt;argument('database')     -&gt;required()     -&gt;description(&quot;Which database to dump the tables from&quot;);  $config-&gt;argument('tables')     -&gt;description(&quot;Tables to dump&quot;)      \/\/ \u041f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439     \/\/ \u0412 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u043e\u043b\u043a\u043e \u043e\u0434\u0438\u043d \u0442\u0430\u043a\u043e\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442,     \/\/ \u0438 \u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0447\u0442\u043e \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c     -&gt;arrayOf(); <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 <i>help<\/i> \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"bash\">.\/console help app:sqldump  app:sqldump --user=VALUE [ -f ] [ --skip-missing ] DATABASE [ TABLES... ]  Options: user            User to connect to the database with f               Force database dump skip-missing    Don't throw an error if the tables are missing  Arguments: DATABASE  Which database to dump the tables from TABLES    Tables to dump <\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043c\u0435\u0442\u043e\u0434\u0443 <i>run()<\/i> \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0443\u0442\u0441\u044f \u043e\u043f\u0446\u0438\u0438 \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u043e\u0442\u043a\u0443\u0434\u0430 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043a\u0430\u043a \u0438 \u0432 HTTP \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0435:<\/p>\n<pre><code class=\"php\">public function run($argumentData, $optionData) {     $database = $argumentData-&gt;get('database');      \/\/ \u0421 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f     $user = $optionData-&gt;get('user', 'phpixie'); } <\/code><\/pre>\n<p>  <b>\u0412\u0432\u043e\u0434 \u0438 \u0432\u044b\u0432\u043e\u0434<\/b><\/p>\n<p>  \u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e return-\u0443\u0442\u044c \u0442\u0435\u043a\u0441\u0442. \u041d\u043e \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0434\u043e\u043b\u0433\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0438 \u043d\u0430\u0434\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b:<\/p>\n<pre><code class=\"php\">public function run($argumentData, $optionData) {     \/\/ \u0412\u044b\u0432\u043e\u0434 \u0442\u0435\u043a\u0441\u0442\u0430     $this-&gt;write(&quot;Hello &quot;);      \/\/ \u0412\u044b\u0432\u043e\u0434 \u0442\u0435\u043a\u0441\u0442\u0430 \u0441 \u043d\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439     $this-&gt;writeLine(&quot;World&quot;);      \/\/ \u0421\u0447\u0438\u0442\u0430\u0442\u044c \u0432\u0432\u043e\u0434 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u043a\u043e\u043d\u0441\u043e\u043b\u0438     $str = $this-&gt;readLine();      \/\/ \u0415\u0441\u043b\u0438 \u0431\u0440\u043e\u0441\u0438\u0442\u044c CommandException \u0442\u043e \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u0441\u044f \u0442\u0435\u043a\u0441\u0442 \u043e\u0448\u0438\u0431\u043a\u0438     \/\/ \u0438 \u0441\u0430\u043c\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0438\u0442 \u043d\u0435-\u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0441\u0442\u0430\u0442\u0443\u0441 \u043a\u043e\u0434 (\u043f\u043e\u043b\u0435\u0437\u043d\u043e \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 Bash).     throw new \\PHPixie\\Console\\Exception\\CommandException(&quot;Something bad happened&quot;); } <\/code><\/pre>\n<p>  \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a CLI \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0443 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0443\u0436\u0435 \u0441 \u043d\u0438\u043c:<\/p>\n<pre><code class=\"php\">public function run($argumentData, $optionData) {     $context = $this-&gt;cliContext();      $inputStream = $cliContext-&gt;inputStream();     $outputStream = $cliContext-&gt;outputStream();     $errorStream = $cliContext-&gt;errorStream();      $outputStream-&gt;write(&quot;Hello&quot;);     $errorStream-&gt;writeLine(&quot;Something bad happened&quot;);     $context-&gt;setExitCode(1); \/\/ \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u043e\u0434 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 <\/code><\/pre>\n<p>  \u041a\u043e\u0434 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u0443\u0434\u0430\u0447\u043d\u043e \u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u043b\u0430\u0441\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0438\u0437\u0432\u043d\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 Bash:<\/p>\n<pre><code class=\"bash\">if .\/console app:somecommand ; then     echo &quot;Command succeeded&quot; else     echo &quot;Command failed&quot; fi <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u044f \u0443\u0436\u0435 \u043f\u0438\u0441\u0430\u043b \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430, \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0431\u0435\u0437 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430:<\/p>\n<pre><code class=\"php\">class YourCommandRegistry extends \\PHPixie\\Console\\Registry\\Provider\\Implementation  {     public function commandNames()     {          return ['greet'];     }      public function buildGreetCommand($config)     {          return new Greet($config);     } }  $slice = new \\PHPixie\\Slice(); $cli = new \\PHPixie\\CLI(); $registry = new YourCommandRegistry();  $console = new \\PHPixie\\Console($slice, $cli, $registry); $console-&gt;runCommand(); <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0432 \u043b\u044e\u0431\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u0432\u0441\u0435 \u044d\u0442\u043e \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438 \u0438 \u0432\u0435\u0441\u044c\u043c\u0430 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e.<br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/314314\/\"> https:\/\/habrahabr.ru\/post\/314314\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/7cd\/47c\/66c\/7cd47c66c5df9f4b83f7886240a1cba2.png\" alt=\"image\" align=\"right\"\/><br \/>  PHPixie Console \u2014 \u044d\u0442\u043e \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c, \u0440\u043e\u0443\u0442\u0438\u0442\u044c \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u041a\u0430\u043a \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u0435\u0437 \u0441\u0430\u043c\u043e\u0439 PHPixie \u043a\u0430\u043a \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438\u0437 Symfony.  <\/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-280383","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/280383","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=280383"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/280383\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=280383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=280383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=280383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}