All Versions
21
Latest Version
Avg Release Cycle
133 days
Latest Release
1951 days ago

Changelog History
Page 2

  • v3.0.3 Changes

    February 02, 2016

    โž• Added

    • #89 adds cyclic alias detection to the ServiceManager; it now raises a Zend\ServiceManager\Exception\CyclicAliasException when one is detected, detailing the cycle detected.
    • #95 adds GitHub Pages publication automation, and moves the documentation to https://zendframework.github.io/zend-servicemanager/
    • #93 adds Zend\ServiceManager\Test\CommonPluginManagerTrait, which can be used to validate that a plugin manager instance is ready for version 3.

    ๐Ÿ—„ Deprecated

    • Nothing.

    โœ‚ Removed

    • Nothing.

    ๐Ÿ›  Fixed

    • ๐Ÿ›  #90 fixes several examples in the configuration chapter of the documentation, ensuring that the signatures are correct.
    • #92 ensures that alias resolution is skipped during configuration if no aliases are present, and forward-ports the test from #81 to validate v2/v3 compatibility for plugin managers.
  • v3.0.2 Changes

    January 24, 2016

    โž• Added

    • ๐ŸŽ #64 performance optimizations when dealing with alias resolution during service manager instantiation

    ๐Ÿ—„ Deprecated

    • Nothing.

    โœ‚ Removed

    • Nothing.

    ๐Ÿ›  Fixed

    • #62 #64 corrected benchmark assets signature
    • #72 corrected link to the Proxy Pattern Wikipedia page in the documentation
    • #78 #79 creation context was not being correctly passed to abstract factories when using plugin managers
    • #82 corrected migration guide in the DocBlock of the InitializerInterface
  • v3.0.1 Changes

    January 19, 2016

    โž• Added

    • Nothing.

    ๐Ÿ—„ Deprecated

    • Nothing.

    โœ‚ Removed

    • ๐Ÿšš #68 removes the dependency on zend-stdlib by inlining the ArrayUtils::merge() routine as a private method of Zend\ServiceManager\Config.

    ๐Ÿ›  Fixed

    • Nothing.
  • v3.0.0 Changes

    January 11, 2016

    ๐Ÿš€ First stable release of version 3 of zend-servicemanager.

    ๐Ÿ“š Documentation is now available at http://zend-servicemanager.rtfd.org

    โž• Added

    • You can now map multiple key names to the same factory. It was previously possible in ZF2 but it was not enforced by the FactoryInterface interface. Now the interface receives the $requestedName as the second parameter (previously, it was the third).

    Example:

      $sm = new \Zend\ServiceManager\ServiceManager([
          'factories'  => [
              MyClassA::class => MyFactory::class,
              MyClassB::class => MyFactory::class,
              'MyClassC'      => 'MyFactory' // This is equivalent as using ::class
          ],
      ]);
    
      $sm->get(MyClassA::class); // MyFactory will receive MyClassA::class as second parameter
    
    • ๐Ÿ”Œ Writing a plugin manager has been simplified. If you have simple needs, you no longer need to implement the complete validate method.

    In versions 2.x, if your plugin manager only allows creating instances that implement Zend\Validator\ValidatorInterface, you needed to write the following code:

      class MyPluginManager extends AbstractPluginManager
      {
        public function validate($instance)
        {
            if ($instance instanceof \Zend\Validator\ValidatorInterface) {
                return;
            }
    
            throw new InvalidServiceException(sprintf(
                'Plugin manager "%s" expected an instance of type "%s", but "%s" was received',
                 __CLASS__,
                 \Zend\Validator\ValidatorInterface::class,
                 is_object($instance) ? get_class($instance) : gettype($instance)
            ));
        }
      }
    

    In version 3, this becomes:

      use Zend\ServiceManager\AbstractPluginManager;
      use Zend\Validator\ValidatorInterface;
    
      class MyPluginManager extends AbstractPluginManager
      {
          protected $instanceOf = ValidatorInterface::class;
      }
    

    Of course, you can still override the validate method if your logic is more complex.

    To aid migration, validate() will check for a validatePlugin() method (which was required in v2), and proxy to it if found, after emitting an E_USER_DEPRECATED notice prompting you to rename the method.

    • ๐Ÿ”ง A new method, configure(), was added, allowing full configuration of the ServiceManager instance at once. Each of the various configuration methods โ€” setAlias(), setInvokableClass(), etc. โ€” now proxy to this method.

    • A new method, mapLazyService($name, $class = null), was added, to allow mapping a lazy service, and as an analog to the other various service definition methods.

    ๐Ÿ—„ Deprecated

    • Nothing

    โœ‚ Removed

    • ๐Ÿšš Peering has been removed. It was a complex and rarely used feature that was misunderstood most of the time.

    • ๐Ÿšš Integration with Zend\Di has been removed. It may be re-integrated later.

    • ๐Ÿšš MutableCreationOptionsInterface has been removed, as options can now be passed directly through factories.

    • ๐Ÿšš ServiceLocatorAwareInterface and its associated trait has been removed. It was an anti-pattern, and you are encouraged to inject your dependencies in factories instead of injecting the whole service locator.

    ๐Ÿ”„ Changed/Fixed

    v3 of the ServiceManager component is a completely rewritten, more efficient implementation of the service locator pattern. It includes a number of breaking ๐Ÿ”„ changes, outlined in this section.

    • ๐Ÿ”ง You no longer need a Zend\ServiceManager\Config object to configure the service manager; you can pass the configuration array directly instead.

    In version 2.x:

      $config = new \Zend\ServiceManager\Config([
          'factories'  => [...]
      ]);
    
      $sm = new \Zend\ServiceManager\ServiceManager($config);
    

    In ZF 3.x:

      $sm = new \Zend\ServiceManager\ServiceManager([
          'factories'  => [...]
      ]);
    

    Config and ConfigInterface still exist, however, but primarily for the purposes of codifying and aggregating configuration to use.

    • ConfigInterface has two important changes:

      • configureServiceManager() now must return the updated service manager instance.
      • A new method, toArray(), was added, to allow pulling the configuration in order to pass to a ServiceManager or plugin manager's constructor or configure() method.
    • Interfaces for FactoryInterface, DelegatorFactoryInterface and AbstractFactoryInterface have changed. All are now directly invokable. This allows a number of performance optimization internally.

    Additionally, all signatures that accepted a "canonical name" argument now remove it.

    Most of the time, rewriting a factory to match the new interface implies replacing the method name by __invoke, and removing the canonical name argument if present.

    For instance, here is a simple version 2.x factory:

      class MyFactory implements FactoryInterface
      {
          function createService(ServiceLocatorInterface $sl)
          {
              // ...
          }
      }
    

    The equivalent version 3 factory:

      class MyFactory implements FactoryInterface
      {
          function __invoke(ServiceLocatorInterface $sl, $requestedName)
          {
              // ...
          }
      }
    

    Note another change in the above: factories also receive a second parameter, enforced through the interface, that allows you to easily map multiple service names to the same factory.

    To provide forwards compatibility, the original interfaces have been retained, but extend the new interfaces (which are under new namespaces). You can implement the new methods in your existing v2 factories in order to make them forwards compatible with v3.

    • The for AbstractFactoryInterface interface renames the method canCreateServiceWithName() to canCreate(), and merges the $name and $requestedName arguments.

    • ๐Ÿ”Œ Plugin managers will now receive the parent service locator instead of itself in factories. In version 2.x, you needed to call the method getServiceLocator() to retrieve the parent (application) service locator. This was confusing, and not IDE friendly as this method was not enforced through the interface.

    In version 2.x, if a factory was set to a service name defined in a plugin manager:

      class MyFactory implements FactoryInterface
      {
          function createService(ServiceLocatorInterface $sl)
          {
              // $sl is actually a plugin manager
    
              $parentLocator = $sl->getServiceLocator();
    
              // ...
          }
      }
    

    In version 3:

      class MyFactory implements FactoryInterface
      {
          function __invoke(ServiceLocatorInterface $sl, $requestedName)
          {
              // $sl is already the main, parent service locator. If you need to
              // retrieve the plugin manager again, you can retrieve it through the
              // servicelocator:
              $pluginManager = $sl->get(MyPluginManager::class);
              // ...
          }
      }
    

    In practice, this should reduce code, as dependencies often come from the main service locator, and not the plugin manager itself.

    To assist in migration, the method getServiceLocator() was added to ServiceManager to ensure that existing factories continue to work; the method emits an E_USER_DEPRECATED message to signal developers to update their factories.

    • ๐Ÿ”Œ PluginManager now enforces the need for the main service locator in its constructor. In v2.x, people often forgot to set the parent locator, which led to bugs in factories trying to fetch dependencies from the parent locator. Additionally, plugin managers now pull dependencies from the parent locator by default; if you need to pull a peer plugin, your factories will now need to pull the corresponding plugin manager first.

    If you omit passing a service locator to the constructor, your plugin manager will continue to work, but will emit a deprecation notice indicatin you should update your initialization code.

    • It's so fast now that your app will fly!
  • v2.7.11 Changes

    June 22, 2018

    2.7.11 - 2018-06-22

    โž• Added

    • Nothing.

    ๐Ÿ”„ Changed

    • Nothing.

    ๐Ÿ—„ Deprecated

    • Nothing.

    โœ‚ Removed

    • Nothing.

    ๐Ÿ›  Fixed

    • ๐Ÿ›  #269 fixes a
      regression whereby using static Callable strings caused an undefined variable
      ๐Ÿ”” notice.
  • v2.7.10 Changes

    December 05, 2017

    โž• Added

    • Nothing.

    ๐Ÿ”„ Changed

    • Nothing.

    ๐Ÿ—„ Deprecated

    • Nothing.

    โœ‚ Removed

    • Nothing.

    ๐Ÿ›  Fixed

    • ๐Ÿ›  #210 fixes a regression whereby factories accepting creation options were receiving an empty array versus a null value when no options were present for a particular invocation; they now correctly receive a null value.
  • v2.7.9 Changes

    November 27, 2017

    โž• Added

    • Nothing.

    ๐Ÿ—„ Deprecated

    • Nothing.

    โœ‚ Removed

    • Nothing.

    ๐Ÿ›  Fixed

    • ๐Ÿš€ #205 fixes how the AbstractPluginManager handles repeated retrievals of the same service when instance options are provided and the service is marked as "shared". Previously, it incorrectly would return the first instance retrieved; with this release, no instance created with instance options is ever shared.
  • v2.7.0 Changes

    January 11, 2016

    โž• Added

    • #60 adds forward compatibility features for AbstractPluingManager and introduces InvokableFactory to help forward migration to version 3.

    ๐Ÿ—„ Deprecated

    • Nothing.

    โœ‚ Removed

    • Nothing.

    ๐Ÿ›  Fixed

    • โšก๏ธ #46 updates the exception hierarchy to inherit from the container-interop exceptions. This ensures that all exceptions thrown by the component follow the recommendations of that project.
    • ๐Ÿ›  #52 fixes the exception message thrown by ServiceManager::setFactory() to remove references to abstract factories.
  • v2.6.0 Changes

    July 23, 2015

    โž• Added

    ๐Ÿ—„ Deprecated

    • Nothing.

    โœ‚ Removed

    • Nothing.

    ๐Ÿ›  Fixed

    • โšก๏ธ #3 properly updates the codebase to PHP 5.5, by taking advantage of the default closure binding ($this in a closure is the invoking object when created within a method). It also removes several @requires PHP 5.4.0 annotations.
  • v2.4.13

    July 13, 2017