2017 © Pedro Peláez
 

symfony-bundle service-proxy-bundle

Service Proxy Symfony2 Bundle

image

openclassrooms/service-proxy-bundle

Service Proxy Symfony2 Bundle

  • Friday, November 24, 2017
  • by openclassrooms-admin
  • Repository
  • 5 Watchers
  • 0 Stars
  • 13,882 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 15 % Grown

The README.md

ServiceProxyBundle

Build Status SensioLabsInsight Coverage Status, (*1)

The ServiceProxyBundle offers integration of the ServiceProxy library.
ServiceProxy provides functionality to manage technical code over a class:
* Transactional context (not implemented yet) * Security access (not implemented yet) * Cache management * Events (not implemented yet) * Logs (not implemented yet), (*2)

See ServiceProxy for full details., (*3)

Installation

This bundle can be installed using composer:, (*4)

composer require openclassrooms/service-proxy-bundle
or by adding the package to the composer.json file directly., (*5)

{
    "require": {
        "openclassrooms/service-proxy-bundle": "*"
    }
}

After the package has been installed, add the bundle to the AppKernel.php file:, (*6)

// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new OpenClassrooms\Bundle\ServiceProxyBundle\OpenClassroomsServiceProxyBundle(),
    // ...
);

:warning: The usage of cache capabilities requires the installation of the openclassrooms/doctrine-cache-extension-bundle.
See the openclassrooms/doctrine-cache-extension-bundle installation guidefor more details., (*7)

Configuration


# app/config/config.yml openclassrooms_service_proxy: ~

Full configuration, (*8)

Usage

Cache

Use the Cache annotation.
See Service Proxy Cache for more details., (*9)

``` php <?php, (*10)

namespace A\Namespace;, (*11)

use OpenClassrooms\ServiceProxy\Annotations\Cache;, (*12)

class AClass { /** * @Cache */ public function aMethod() { // do things } }, (*13)


#### Using default cache provider ``` yaml # app/config/config.yml doctrine_cache: providers: a_cache_provider: type: array openclassrooms_service_proxy: default_cache: doctrine_cache.providers.a_cache_provider
<!-- services.xml -->
<service id="a_service" class="A\Namespace\AClass">
    <tag name="openclassrooms.service_proxy"/>
</service>

Using specific cache provider

<!-- services.xml -->
<service id="a_service" class="AClass">
    <tag name="openclassrooms.service_proxy" cache="doctrine_cache.providers.a_cache_provider"/>
</service>

Performance

Autoloader

The usage of a proxy require a lot of I/O. See Ocramius\ProxyManager Tunning for production.
It's possible to specify the environments where the proxy autoloader is used., (*14)

``` yaml, (*15)

openclassrooms_service_proxy: production_environments: ['prod', 'stage'] # default : ['prod'], (*16)


### Cache Warmup The bundle uses the Symfony cache warmup to dump the proxies files. ## Full configuration ``` yaml openclassrooms_service_proxy: # the directory where the proxy are written cache_dir : "/a/path/to/the/cache/directory" # default: %kernel.cache_dir% # the default cache provider (optional) default_cache: doctrine_cache.providers.a_cache_provider # default: null # the Symfony environments where the proxy autoloader is used production_environments: ['prod', 'stage'] # default : ['prod']

The Versions