{"id":275053,"date":"2016-02-27T00:02:03","date_gmt":"2016-02-26T21:02:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=275053"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=275053","title":{"rendered":"\u041a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 Dependency Injection Container"},"content":{"rendered":"<p>       \u041f\u0440\u0438\u0432\u0435\u0442 \u0432\u0441\u0435\u043c!<br \/>  \u042d\u0442\u043e \u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/www.sitepoint.com\/how-to-build-your-own-dependency-injection-container\/\">How to Build Your Own Dependency Injection Container<\/a>.<br \/>  \u0422.\u043a. \u044d\u0442\u043e \u043c\u043e\u0439 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0434\u043b\u044f \u0445\u0430\u0431\u0440\u0430, \u0434\u0430 \u0438 \u0432\u043e\u043e\u0431\u0449\u0435. \u041f\u0440\u043e\u0448\u0443 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0438, \u043d\u0435\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0438\u0442\u0434..<\/p>\n<h2>\u041a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 Dependency Injection Container.<\/h2>\n<p>  \u041f\u043e\u0438\u0441\u043a \u201cdependency injection container\u201d \u043d\u0430 <a href=\"https:\/\/packagist.org\/\">packagist<\/a> \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u044b\u0434\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 95 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430. \u0421 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u043e\u0441\u043e\u0431\u043e\u0435 \u201c\u043a\u043e\u043b\u0435\u0441\u043e\u201d \u0443\u0436\u0435 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u043e.<\/p>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e, \u043d\u0435 \u043e\u0434\u0438\u043d \u0448\u0435\u0444 \u043f\u043e\u0432\u0430\u0440 \u043d\u0435 \u0443\u0447\u0438\u043b\u0441\u044f \u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u0435\u0434\u0443. \u0422\u0430\u043a\u0436\u0435 \u0438 \u043d\u0435 \u043e\u0434\u0438\u043d \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0443\u0447\u0438\u043b\u0441\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 <em>dependency injection container<\/em> \u043f\u0430\u043a\u0435\u0442. \u0412\u0435\u0441\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u043a\u043e\u0434, \u043f\u043b\u044e\u0441 PHPDoc \u0430\u043d\u043d\u0430\u0442\u0430\u0446\u0438\u0438 \u0438 unit-\u0442\u0435\u0441\u0442\u044b \u0441 100% \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043d\u0430 <a href=\"https:\/\/github.com\/sitepoint\/Container\">GitHub<\/a>. \u0412\u0441\u0435 \u044d\u0442\u043e \u0442\u0430\u043a \u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e \u043d\u0430 <a href=\"https:\/\/packagist.org\/packages\/sitepoint\/container\">Packagist<\/a>.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u041f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448 Dependency Injection Container<\/h2>\n<p>  \u041f\u043e\u0437\u0432\u043e\u043b\u044c\u0442\u0435 \u043d\u0430\u043c \u043d\u0430\u0447\u0430\u0442\u044c \u0441 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0434\u0435\u043b\u0430\u043b.<br \/>  \u0425\u043e\u0440\u043e\u0448\u0435\u0435 \u043d\u0430\u0447\u0430\u043b\u043e \u044d\u0442\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c <em>\u201cDependency Injection Container\u201d<\/em> \u043d\u0430 \u0434\u0432\u0435 \u0440\u043e\u043b\u0438, <em>\u201cDependency Injection\u201d<\/em> \u0438 <em>\u201cContainer\u201d<\/em>.<\/p>\n<p>  \u0414\u0432\u0430 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 <em>constructor injection<\/em> \u0438\u043b\u0438 <em>setter injection<\/em>. \u042d\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0432 \u0432\u0438\u0434\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0438\u043b\u0438 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430. \u0415\u0441\u043b\u0438 \u043d\u0430\u0448 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441\u044b, \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u0442\u044c \u043e\u0431\u0430 \u044d\u0442\u0438\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u0430.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0431\u044b\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u043c, \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432. \u042d\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u043d\u043e \u044d\u0442\u043e \u0432\u0441\u0435 \u0435\u0449\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044f. \u041f\u0430\u043a\u0435\u0442 <a href=\"https:\/\/github.com\/container-interop\/container-interop\">container-interop<\/a> \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u043d\u0430\u0431\u043e\u0440 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <em>ContainerInterface<\/em> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430, \u043e\u0434\u0438\u043d \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u0434\u0440\u0443\u0433\u043e\u0439 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d \u043b\u0438 \u0441\u0435\u0440\u0432\u0438\u0441.<\/p>\n<pre><code>interface ContainerInterface {     public function get($id);     public function has($id); }<\/code><\/pre>\n<p>  <\/p>\n<h2>\u041e\u043f\u044b\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 Dependency Injection Containers<\/h2>\n<p>  <a href=\"http:\/\/symfony.com\/doc\/current\/components\/dependency_injection\/introduction.html\">Symfony Dependency Injection Container<\/a> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438. \u0412 <em>YAML<\/em>, \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code>parameters:     # ...     mailer.transport: sendmail  services:     mailer:         class:     Mailer         arguments: [&quot;%mailer.transport%&quot;]     newsletter_manager:         class:     NewsletterManager         calls:             - [setMailer, [&quot;@mailer&quot;]]<\/code><\/pre>\n<p>  \u041f\u0443\u0442\u044c <em>Symfony<\/em> \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u0430. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u0434\u0430\u043d\u043d\u044b\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0438\u043c \u043a\u0430\u043a \u043a\u043b\u044e\u0447\u0438 API, \u043a\u043b\u044e\u0447\u0438 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0442\u043e\u043a\u0435\u043d\u044b \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u044b\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0432 \u0444\u0430\u0439\u043b\u0430\u0445 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f.<\/p>\n<p>  \u0412 PHP, \u0442\u0430 \u0436\u0435 \u0441\u0430\u043c\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <em>Symfony Dependency Injection<\/em> \u0431\u044b\u043b\u0430 \u0431\u044b \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 \u044d\u0442\u043e:<\/p>\n<pre><code>use Symfony\\Component\\DependencyInjection\\Reference;  \/\/ ... $container-&gt;setParameter('mailer.transport', 'sendmail');  $container     -&gt;register('mailer', 'Mailer')     -&gt;addArgument('%mailer.transport%');  $container     -&gt;register('newsletter_manager', 'NewsletterManager')     -&gt;addMethodCall('setMailer', array(new Reference('mailer')));<\/code><\/pre>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043e\u0431\u044a\u0435\u043a\u0442 <em>Reference<\/em> \u0432 \u0432\u044b\u0437\u043e\u0432\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <em>setMailer<\/em>, \u043b\u043e\u0433\u0438\u043a\u0430 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0441\u0441\u044b\u043b\u043a\u0430 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u043b\u044f \u043e\u0431\u043e\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 PHP \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0431\u044b\u0442\u044c \u043b\u0435\u0433\u043a\u043e \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u043d\u044b\u043c\u0438 \u0432 \u0441\u0435\u0440\u0432\u0438\u0441 \u0431\u0435\u0437 \u043f\u0443\u0442\u0430\u043d\u0438\u0446\u044b.<\/p>\n<h3>\u041d\u0430\u0447\u0430\u043b\u043e \u0440\u0430\u0431\u043e\u0442\u044b<\/h3>\n<p>  \u041f\u0435\u0440\u0432\u0430\u044f \u0432\u0435\u0449\u044c \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0438 \u0444\u0430\u0439\u043b <em>composer.json<\/em> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>Composer<\/em> \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0430\u0432\u0442\u043e\u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a \u043d\u0430\u0448\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u0412\u0435\u0441\u044c \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u0440\u0442\u043e\u0439 <em>SitePoint\\Container<\/em> \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0435\u043d \u043a \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <em>src<\/em>.<\/p>\n<pre><code>{     &quot;autoload&quot;: {         &quot;psr-4&quot;: {             &quot;SitePoint\\\\Container\\\\&quot;: &quot;src\/&quot;         }     }, }<\/code><\/pre>\n<p>  \u0414\u0430\u043b\u044c\u0448\u0435 \u043a\u0430\u043a \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0435\u043c\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <em>container-interop<\/em>, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0447\u0442\u043e\u0431\u044b composer \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b \u0438\u0445 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0432 \u043d\u0430\u0448 <em>composer.json<\/em> \u0444\u0430\u0439\u043b:<\/p>\n<pre><code>composer require container-interop\/container-interop<\/code><\/pre>\n<p>  \u041d\u0430\u0440\u044f\u0434\u0443 \u0441 \u0433\u043b\u0430\u0432\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c <em>ContainerInterface<\/em>, \u043f\u0430\u043a\u0435\u0442 <em>container-interop<\/em> \u0442\u0430\u043a\u0436\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0434\u0432\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0434\u043b\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439. \u041f\u0435\u0440\u0432\u044b\u0439 \u0434\u043b\u044f \u043e\u0431\u0449\u0438\u0445 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u0434\u043b\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u043a\u043e\u0433\u0434\u0430 \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u043d\u0435 \u0431\u044b\u043b \u043d\u0430\u0439\u0434\u0435\u043d. \u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u0440\u0443\u0433\u043e\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u044d\u0442\u043e\u043c\u0443 \u0441\u043f\u0438\u0441\u043a\u0443, \u0434\u043b\u044f \u0442\u0435\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439 \u043a\u043e\u0433\u0434\u0430 \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043d\u0435 \u0431\u044b\u043b \u043d\u0430\u0439\u0434\u0435\u043d.<\/p>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u0430\u043a\u0443\u044e \u043b\u0438\u0431\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0445\u043e\u0434\u044f\u0449\u0443\u044e \u0437\u0430 \u0440\u0430\u043c\u043a\u0438 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u043e\u043c \u044f\u0434\u0440\u0430 PHP <em>Exception<\/em>, \u044d\u0442\u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b. \u0412 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u044b\u043c\u0438, \u0442\u0430\u043a\u043e\u0435 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043b\u0435\u0433\u0447\u0435 \u043e\u0442\u043b\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0438\u0445 \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443 <em>src<\/em> \u0438 \u0432 \u043d\u0435\u0439 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0444\u0430\u0439\u043b\u044b <em>src\/Exception\/ContainerException.php<\/em>, <em>src\/Exception\/ServiceNotFoundException.php<\/em> \u0438 <em>src\/Exception\/ParameterNotFoundException.php<\/em> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e:<\/p>\n<pre><code>&lt;?php  namespace SitePoint\\Container\\Exception;  use Interop\\Container\\Exception\\ContainerException as InteropContainerException;  class ContainerException extends \\Exception implements InteropContainerException {}<\/code><\/pre>\n<p>  <\/p>\n<pre><code>&lt;?php  namespace SitePoint\\Container\\Exception;  use Interop\\Container\\Exception\\NotFoundException as InteropNotFoundException;  class ServiceNotFoundException extends \\Exception implements InteropNotFoundException {}<\/code><\/pre>\n<p>  <\/p>\n<pre><code>&lt;?php  namespace SitePoint\\Container\\Exception;  class ParameterNotFoundException extends \\Exception {}<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435<\/h2>\n<p>  Symfony \u043a\u043b\u0430\u0441\u0441 <em>Reference<\/em> \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u0440\u0430\u043d\u0435\u0435, \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u0442\u044c PHP \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0437\u0430\u0438\u043c\u0441\u0442\u0432\u0443\u0435\u043c \u044d\u0442\u0443 \u0438\u0434\u0435\u044e \u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u043b\u044f \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044b. \u0422\u0430\u043a \u043a\u0430\u043a \u043e\u0431\u0430 \u044d\u0442\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u0430 \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u0430 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043d\u0438 \u0441\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f, \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u0434 \u0434\u0432\u0430\u0436\u0434\u044b.<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0444\u0430\u0439\u043b\u044b <em>src\/Reference\/AbstractReference.php<\/em>, <em>src\/Reference\/ServiceReference.php<\/em> \u0438 <em>src\/Reference\/ParameterReference.php<\/em> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e:<\/p>\n<pre><code>&lt;?php  namespace SitePoint\\Container\\Reference;  abstract class AbstractReference {     private $name;      public function __construct($name)     {         $this-&gt;name = $name;     }      public function getName()     {         return $this-&gt;name;     } }<\/code><\/pre>\n<p>  <\/p>\n<pre><code>&lt;?php  namespace SitePoint\\Container\\Reference;  class ServiceReference extends AbstractReference {}<\/code><\/pre>\n<p>  <\/p>\n<pre><code>&lt;?php  namespace SitePoint\\Container\\Reference;  class ParameterReference extends AbstractReference {}<\/code><\/pre>\n<p>  <\/p>\n<h2>\u041a\u043b\u0430\u0441\u0441 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430<\/h2>\n<p>  \u041d\u0430\u0441\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440. \u041c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u043d\u0430\u0447\u0430\u0442\u044c \u0441 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0441\u0445\u0435\u043c\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0432 \u043d\u0435\u0433\u043e \u043f\u043e \u0445\u043e\u0434\u0443 \u0434\u0435\u043b\u0430.<\/p>\n<p>  \u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0434\u0432\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430. \u041f\u0435\u0440\u0432\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. <\/p>\n<p>  \u0412 <em>src\/Container.php<\/em> \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code>&lt;?php  namespace SitePoint\\Container;  use Interop\\Container\\ContainerInterface as InteropContainerInterface;  class Container implements InteropContainerInterface {     private $services;     private $parameters;     private $serviceStore;      public function __construct(array $services = [], array $parameters = [])     {         $this-&gt;services     = $services;         $this-&gt;parameters   = $parameters;         $this-&gt;serviceStore = [];     } }<\/code><\/pre>\n<p>  \u0412\u0441\u0435 \u0447\u0442\u043e \u043c\u044b \u0437\u0434\u0435\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <em>ContainerInterface<\/em> \u0438\u0437 <em>container-interop<\/em> \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043f\u043e\u0437\u0434\u043d\u0435\u0435. \u0422\u0430\u043a \u0436\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <em>serviceStore<\/em> \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0435\u0433\u043e \u043f\u0443\u0441\u0442\u044b\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c. \u041a\u043e\u0433\u0434\u0430 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043f\u043e\u043f\u0440\u043e\u0441\u044f\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441\u044b, \u043c\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0438\u0445 \u0432 \u044d\u0442\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0442\u0430\u043a \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b\u0442\u044c \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u043f\u043e\u0437\u0436\u0435 \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438\u0445.<\/p>\n<p>  \u0421\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u0437\u0432\u043e\u043b\u044c\u0442\u0435 \u043d\u0430\u043c \u043d\u0430\u0447\u0430\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0432 <em>container-interop<\/em>. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 <em>get($name)<\/em>, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432 \u043a\u043b\u0430\u0441\u0441:<\/p>\n<pre><code>use SitePoint\\Container\\Exception\\ServiceNotFoundException;  \/\/ ...     public function get($name)     {         if (!$this-&gt;has($name)) {             throw new ServiceNotFoundException('Service not found: '.$name);         }          if (!isset($this-&gt;serviceStore[$name])) {             $this-&gt;serviceStore[$name] = $this-&gt;createService($name);         }          return $this-&gt;serviceStore[$name];     } \/\/ ... <\/code><\/pre>\n<p>  \u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 <em>use<\/em> \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0444\u0430\u0439\u043b\u0430. \u041d\u0430\u0448 <em>get($name)<\/em> \u043c\u0435\u0442\u043e\u0434 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430. \u0415\u0441\u043b\u0438 \u0435\u0433\u043e \u043d\u0435\u0442 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d <em>ServiceNotFoundException<\/em> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0440\u0430\u043d\u0435\u0435. \u0415\u0441\u043b\u0438 \u043e\u043d \u0435\u0441\u0442\u044c, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0435\u0433\u043e, \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0435\u0433\u043e \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0435\u0441\u043b\u0438 \u043e\u043d \u043d\u0435 \u0431\u044b\u043b \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d.<\/p>\n<p>  \u041f\u043e\u043a\u0430 \u043c\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u0432 \u043d\u0435\u043c, \u043d\u0430\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430. \u041f\u0440\u0438\u043d\u0438\u043c\u0430\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0438\u0437 n-\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431 \u0447\u0438\u0441\u0442\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043b\u044e\u0431\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443. \u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u0447\u043a\u0443 \u043a\u0430\u043a \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c, \u0442\u0430\u043a \u0447\u0442\u043e\u0431\u044b \u0441\u0442\u0440\u043e\u043a\u0430 <em>foo.bar<\/em> \u0441\u0441\u044b\u043b\u0430\u043b\u0430\u0441\u044c \u043d\u0430 \u043a\u043b\u044e\u0447 <em>bar<\/em> \u0432 \u043a\u043b\u044e\u0447\u0435 <em>foo<\/em> \u0438\u0437 \u043a\u043e\u0440\u043d\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432.<\/p>\n<pre><code>use SitePoint\\Container\\Exception\\ParameterNotFoundException;  \/\/ ...     public function getParameter($name)     {         $tokens  = explode('.', $name);         $context = $this-&gt;parameters;          while (null !== ($token = array_shift($tokens))) {             if (!isset($context[$token])) {                 throw new ParameterNotFoundException('Parameter not found: '.$name);             }              $context = $context[$token];         }          return $context;     } \/\/ ...<\/code><\/pre>\n<p>  \u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043f\u0430\u0440\u0443 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0435\u0449\u0435 \u043d\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438. \u041f\u0435\u0440\u0432\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445 <em>has($name)<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d \u0432 <em>container-interop<\/em>. \u042d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u0438 \u0435\u043c\u0443 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0435\u0441\u043b\u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0443 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 <em>$name<\/em> \u0441\u0435\u0440\u0432\u0438\u0441.<\/p>\n<pre><code>\/\/ ...     public function has($name)     {         return isset($this-&gt;services[$name]);     } \/\/ ...<\/code><\/pre>\n<p>  \u0414\u0440\u0443\u0433\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u0438\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <em>createService($name)<\/em>. \u042d\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u043c \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0431\u044b\u043b \u0432\u044b\u0437\u0432\u0430\u043d \u0441\u043d\u0430\u0440\u0443\u0436\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0435\u0433\u043e \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u043c.<\/p>\n<p>  \u041f\u0435\u0440\u0432\u0430\u044f \u0432\u0435\u0449\u044c \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u044d\u0442\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 \u044d\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0437\u0443\u043c\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438.<br \/>  \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043c\u044b \u0442\u0440\u0435\u0431\u0443\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u043a\u043b\u044e\u0447 <em>class<\/em> \u0438 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 <em>arguments<\/em> \u0438 <em>calls<\/em>. \u041e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0438 \u0441\u0435\u0442\u0442\u0435\u0440\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0442\u0430\u043a \u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u0449\u0438\u0442\u0443 \u043e\u0442 \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u043d\u0438\u044f \u0441\u0441\u044b\u043b\u043e\u043a, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0432, \u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0438\u0441\u044c \u043b\u0438 \u043c\u044b \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043a\u043b\u044e\u0447 <em>arguments<\/em> \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 PHP \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0443. \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043e\u0431\u044a\u044f\u0432\u0438\u043b\u0438 \u0440\u0430\u043d\u0435\u0435 \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435. \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u043b\u043e\u0433\u0438\u043a\u0443 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <em>resolveArguments($name, array $argumentDefinitons)<\/em>.<br \/>  \u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <em>ReflectionClass::newInstanceArgs()<\/em> \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043c\u0430\u0441\u0441\u0438\u0432 arguments. \u042d\u0442\u043e \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043a\u043b\u044e\u0447 <em>calls<\/em> \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 <em>call definitions<\/em> \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u043a \u0441\u0435\u0440\u0432\u0438\u0441\u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043b\u0438. \u0421\u043d\u043e\u0432\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c \u043a\u0430\u043a <em>initializeService($service, $name, array $callDefinitions)<\/em>. \u042d\u0442\u043e \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0441\u0435\u0442\u0442\u0435\u0440\u0430.<\/p>\n<pre><code>use SitePoint\\Container\\Exception\\ContainerException;  \/\/ ...     private function createService($name)     {         $entry = &amp;$this-&gt;services[$name];          if (!is_array($entry) || !isset($entry['class'])) {             throw new ContainerException($name.' service entry must be an array containing a \\'class\\' key');         } elseif (!class_exists($entry['class'])) {             throw new ContainerException($name.' service class does not exist: '.$entry['class']);         } elseif (isset($entry['lock'])) {             throw new ContainerException($name.' service contains a circular reference');         }          $entry['lock'] = true;          $arguments = isset($entry['arguments']) ? $this-&gt;resolveArguments($name, $entry['arguments']) : [];          $reflector = new \\ReflectionClass($entry['class']);         $service = $reflector-&gt;newInstanceArgs($arguments);          if (isset($entry['calls'])) {             $this-&gt;initializeService($service, $name, $entry['calls']);         }          return $service;     } \/\/ ...<\/code><\/pre>\n<p>  \u041d\u0430\u043c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0432\u0430 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430. \u041f\u0435\u0440\u0432\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 PHP \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b <em>ParameterReference<\/em> \u0438 <em>ServiceReference<\/em> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438 \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430.<\/p>\n<pre><code>use SitePoint\\Container\\Reference\\ParameterReference; use SitePoint\\Container\\Reference\\ServiceReference;  \/\/ ...     private function resolveArguments($name, array $argumentDefinitions)     {         $arguments = [];          foreach ($argumentDefinitions as $argumentDefinition) {             if ($argumentDefinition instanceof ServiceReference) {                 $argumentServiceName = $argumentDefinition-&gt;getName();                  $arguments[] = $this-&gt;get($argumentServiceName);             } elseif ($argumentDefinition instanceof ParameterReference) {                 $argumentParameterName = $argumentDefinition-&gt;getName();                  $arguments[] = $this-&gt;getParameter($argumentParameterName);             } else {                 $arguments[] = $argumentDefinition;             }         }          return $arguments;     }<\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0441\u0435\u0442\u0442\u0435\u0440\u0430 \u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0430. \u0427\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0431\u0440\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u043c\u0435\u0442\u043e\u0434\u0430. \u041a\u043b\u044e\u0447 method \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u0438 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 <em>arguments<\/em> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u044d\u0442\u043e\u043c\u0443 \u043c\u0435\u0442\u043e\u0434\u0443. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438, \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u0435\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 PHP \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<pre><code>private function initializeService($service, $name, array $callDefinitions)     {         foreach ($callDefinitions as $callDefinition) {             if (!is_array($callDefinition) || !isset($callDefinition['method'])) {                 throw new ContainerException($name.' service calls must be arrays containing a \\'method\\' key');             } elseif (!is_callable([$service, $callDefinition['method']])) {                 throw new ContainerException($name.' service asks for call to uncallable method: '.$callDefinition['method']);             }              $arguments = isset($callDefinition['arguments']) ? $this-&gt;resolveArguments($name, $callDefinition['arguments']) : [];              call_user_func_array([$service, $callDefinition['method']], $arguments);         }     } }<\/code><\/pre>\n<p>  \u0418 \u0441\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0433\u043e\u0442\u043e\u0432\u044b\u0439 <em>dependency injection container<\/em>! \u0427\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435 <a href=\"https:\/\/github.com\/sitepoint\/Container\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u043d\u0430 GitHub<\/a>.<\/p>\n<h2>\u041e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0435 \u043c\u044b\u0441\u043b\u0438<\/h2>\n<p>  \u041c\u044b \u0438\u0437\u0443\u0447\u0438\u043b\u0438 \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 dependency <em>injection container<\/em>, \u043d\u043e \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u0441 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0448 \u0435\u0449\u0435 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442.<\/p>\n<p>  \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 dependency injection containers, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <a href=\"http:\/\/php-di.org\/doc\/autowiring.html\">PHP-DI<\/a> \u0438 <a href=\"https:\/\/github.com\/auraphp\/Aura.Di#auto-resolution-of-parameter-values\">Aura.DI<\/a> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435. \u042d\u0442\u043e \u0433\u0434\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0434\u043e\u0433\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a\u0438\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0432\u043d\u0435\u0434\u0440\u0438\u0442\u044c \u0432 \u0434\u0440\u0443\u0433\u0438\u0435. \u0427\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 reflection API \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430.           \t<\/p>\n<div class=\"polling\">\n<form action=\"\/json\/polling\/\" class=\"poll\" method=\"post\">\n<div class=\"poll_title\">\u041f\u043e\u043b\u0435\u0437\u0435\u043d \u043b\u0438 \u0431\u044b\u043b \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0432\u043e\u0434?<\/div>\n<p>  \t\t<input type=\"hidden\" name=\"post_id\" value=\"278049\"\/> \t\t<input type=\"hidden\" name=\"polling_question_id\" value=\"14655\"\/>  \t\t<\/p>\n<table class=\"answer\">\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"radio\" id=\"vv71617\" \t\t\t\t\t\tclass=\"radio js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"71617\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv71617\">\u0434\u0430<\/label> \t\t\t\t<\/td>\n<\/tr>\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"radio\" id=\"vv71619\" \t\t\t\t\t\tclass=\"radio js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"71619\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv71619\">\u043d\u0435\u0442<\/label> \t\t\t\t<\/td>\n<\/tr>\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"radio\" id=\"vv71621\" \t\t\t\t\t\tclass=\"radio js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"71621\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv71621\">\u043d\u0435 \u0437\u043d\u0430\u044e<\/label> \t\t\t\t<\/td>\n<\/tr>\n<\/table>\n<p class=\"total\">\u041d\u0438\u043a\u0442\u043e \u0435\u0449\u0451 \u043d\u0435 \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b. \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u043d\u0435\u0442.<\/p>\n<\/p><\/form>\n<p class=\"for_users_only_msg\">\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u043e\u0441\u0435. <a href=\"https:\/\/habrahabr.ru\/auth\/login\/\">\u0412\u043e\u0439\u0434\u0438\u0442\u0435<\/a>, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.<\/p>\n<\/p><\/div>\n<div class=\"clear\"><\/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=\"https:\/\/habrahabr.ru\/post\/278049\/\"> https:\/\/habrahabr.ru\/post\/278049\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u041f\u0440\u0438\u0432\u0435\u0442 \u0432\u0441\u0435\u043c!<br \/>  \u042d\u0442\u043e \u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/www.sitepoint.com\/how-to-build-your-own-dependency-injection-container\/\">How to Build Your Own Dependency Injection Container<\/a>.<br \/>  \u0422.\u043a. \u044d\u0442\u043e \u043c\u043e\u0439 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0434\u043b\u044f \u0445\u0430\u0431\u0440\u0430, \u0434\u0430 \u0438 \u0432\u043e\u043e\u0431\u0449\u0435. \u041f\u0440\u043e\u0448\u0443 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0438, \u043d\u0435\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0438\u0442\u0434..<\/p>\n<h2>\u041a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 Dependency Injection Container.<\/h2>\n<p>  \u041f\u043e\u0438\u0441\u043a \u201cdependency injection container\u201d \u043d\u0430 <a href=\"https:\/\/packagist.org\/\">packagist<\/a> \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u044b\u0434\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 95 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430. \u0421 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u043e\u0441\u043e\u0431\u043e\u0435 \u201c\u043a\u043e\u043b\u0435\u0441\u043e\u201d \u0443\u0436\u0435 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u043e.<\/p>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e, \u043d\u0435 \u043e\u0434\u0438\u043d \u0448\u0435\u0444 \u043f\u043e\u0432\u0430\u0440 \u043d\u0435 \u0443\u0447\u0438\u043b\u0441\u044f \u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u0435\u0434\u0443. \u0422\u0430\u043a\u0436\u0435 \u0438 \u043d\u0435 \u043e\u0434\u0438\u043d \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0443\u0447\u0438\u043b\u0441\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 <em>dependency injection container<\/em> \u043f\u0430\u043a\u0435\u0442. \u0412\u0435\u0441\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u043a\u043e\u0434, \u043f\u043b\u044e\u0441 PHPDoc \u0430\u043d\u043d\u0430\u0442\u0430\u0446\u0438\u0438 \u0438 unit-\u0442\u0435\u0441\u0442\u044b \u0441 100% \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043d\u0430 <a href=\"https:\/\/github.com\/sitepoint\/Container\">GitHub<\/a>. \u0412\u0441\u0435 \u044d\u0442\u043e \u0442\u0430\u043a \u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e \u043d\u0430 <a href=\"https:\/\/packagist.org\/packages\/sitepoint\/container\">Packagist<\/a>.  <\/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-275053","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/275053","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=275053"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/275053\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=275053"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=275053"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=275053"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}