Skip to content

Updated installation instructions for lazy services #2778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions components/dependency_injection/lazy_services.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,17 @@ the `ProxyManager bridge`_:

.. note::

If you're using the full-stack framework, this package is not included
and needs to be added to ``composer.json`` and installed (which is what
the above command does).
If you're using the full-stack framework, the proxy manager bridge is already
included but the actual proxy manager needs to be included. Therefore add

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing .. code-block:: json

.. code-block:: json

"require": {
"ocramius/proxy-manager": "0.4.*"
}

to your ``composer.json``. Afterwards compile your container and check if you
get a proxy for your lazy services.

Configuration
-------------
Expand Down Expand Up @@ -71,6 +79,16 @@ the same signature of the class representing the service. You can also inject
the service just like normal into other services. The object that's actually
injected will be the proxy.

To check if your proxy works you can simply check the interface of the
received object.

.. code-block:: php

var_dump(class_implements($service));

If the class implements the "ProxyManager\Proxy\LazyLoadingInterface" your lazy
loaded services will work as expected.

.. note::

If you don't install the `ProxyManager bridge`_, the container will just
Expand All @@ -89,4 +107,4 @@ in the `documentation of ProxyManager`_.

.. _`ProxyManager bridge`: https://github.com/symfony/symfony/tree/master/src/Symfony/Bridge/ProxyManager
.. _`proxy`: http://en.wikipedia.org/wiki/Proxy_pattern
.. _`documentation of ProxyManager`: https://github.com/Ocramius/ProxyManager/blob/master/docs/lazy-loading-value-holder.md
.. _`documentation of ProxyManager`: https://github.com/Ocramius/ProxyManager/blob/master/docs/lazy-loading-value-holder.md