Skip to content

Releases: Articus/PathHandler

v0.8.3

23 Feb 21:12
Compare
Choose a tag to compare

Enhancements

Tiny adjustment for Articus\Pathhandler\Transfer attribute - it allows mixed parsed body now (not only array as before). There is no need in this restriction for articus/data-transfer 0.4+

v0.8.2

30 Jan 21:11
Compare
Choose a tag to compare

New features

New build-in attribute Articus\PathHandler\Attribute\IdentifiableValueListLoad. Check documentation for details.

v0.8.1

21 Nov 19:31
Compare
Choose a tag to compare

New features

New build-in attribute Articus\PathHandler\Attribute\IdentifiableValueLoad. Check documentation for details.

v0.8

23 Oct 16:00
Compare
Choose a tag to compare

New features

This update refines handling of problematic requests:

  • custom messages for 400, 401 and 403 HTTP exceptions are now sent as response body, not as reason phrase (reason phrase is not really convenient for long messages and might be reset by some proxies)
  • build-in producers now encode null as any other data (empty response that was generated before might violate response content type encoding rules)
  • library now allows to declare media type and producer for requests with mangled Accept header - text/plain and Articus\PathHandler\Produce\Text are used by default

Migration notes

You do not need to change anything in your current API project unless your API clients rely on reason phrase for 400, 401 and 403 responses. The easiest workaround for this case would be to use old copies of Articus\PathHandler\Exception\BadRequest, Articus\PathHandler\Exception\Forbidden, Articus\PathHandler\Exception\Unauthorized moved to your own namespace.

v0.7

04 Apr 16:38
Compare
Choose a tag to compare

New features

  • new metadata provider for PHP 8 - Articus\PathHandler\MetadataProvider\PhpAttribute. It allows to declare metadata via PHP attributes.

Migration notes

Library configuration structure was slightly rearranged to simplify metadata provider switching. Nothing drastic:

  • metadata provider and all plugin managers are now configured as separate services by default
  • route injection factory was moved from Articus\PathHandler\RouteInjection\Factory to Articus\PathHandler\RouteInjectionFactory

So you have to adjust your application configuration from something like:

dependencies:
  factories:
    Mezzio\Router\RouterInterface: Articus\PathHandler\RouteInjection\Factory

Articus\PathHandler\RouteInjection\Factory:
  paths:
    '':
    - My\Handler
  handlers:
    factories:
      My\Handler: My\HandlerFactory
  consumers:
    factories:
      My\Consumer: My\ConsumerFactory
  attributes:
    factories:
      My\Attribute: My\AttributeFactory
  producers:
    factories:
      My\Producer: My\ProducerFactory

to

dependencies:
  factories:
    Mezzio\Router\RouterInterface: Articus\PathHandler\RouteInjectionFactory
    Articus\PathHandler\MetadataProviderInterface: Articus\PathHandler\MetadataProvider\Factory\Annotation
    Articus\PathHandler\Handler\PluginManager: Articus\PathHandler\Handler\Factory\PluginManager
    Articus\PathHandler\Consumer\PluginManager: Articus\PathHandler\Consumer\Factory\PluginManager
    Articus\PathHandler\Attribute\PluginManager: Articus\PathHandler\Attribute\Factory\PluginManager
    Articus\PathHandler\Producer\PluginManager: Articus\PathHandler\Producer\Factory\PluginManager

Articus\PathHandler\RouteInjectionFactory:
  paths:
    '':
    - My\Handler

Articus\PathHandler\Handler\PluginManager:
  factories:
    My\Handler: My\HandlerFactory
Articus\PathHandler\Consumer\PluginManager:
  factories:
    My\Consumer: My\ConsumerFactory
Articus\PathHandler\Attribute\PluginManager:
  factories:
    My\Attribute: My\AttributeFactory
Articus\PathHandler\Producer\PluginManager:
  factories:
    My\Producer: My\ProducerFactory

Check updated documentation for details.

v0.6.1

30 Jan 16:25
Compare
Choose a tag to compare

Enhancements

  • library can be used in PHP 8.0 projects - Mezzio finally got official support for it!

v0.6

04 Oct 22:21
Compare
Choose a tag to compare

New features

  • rename of consumer annotation property (media type -> media range)
  • migration from Zend to Laminas packages due to global brand change:
    • zendframework/zend-expressive -> mezzio/mezzio
    • zendframework/zend-servicemanager -> laminas/laminas-servicemanager
    • zendframework/zend-stdlib -> laminas/laminas-stdlib
  • library no longer depends from zendframework/zend-http
  • metadata and default router caching mechanism overhaul:
    • library no longer relies directly on zendframework/zend-cache, you may use any implementation of psr/simple-cache you like
    • simple partial PSR-16 implementation optimized for metadata storage and default router cache is provided out-of-the-box
  • it is now possible to specify custom object instanciator in Transfer attribute options

Migration notes

Sadly migration might be a bit cumbersome because you have to apply quite a lot small technical changes.

Update your consumer annotations

You need to rename mediaType parameter to mediaRange wherever you use Articus\PathHandler\Annotation\Consumer annotation.

Migrate to Laminas

More or less it is just a namespace change both in your code and in your configuration. Check official guide for useful tips.

Check metadata cache configuration for production environment

Previously simple file caching for metadata required two extra dependencies ( zendframework/zend-cache and zendframework/zend-serializer) and quite lengthy configuration:

Articus\PathHandler\RouteInjection\Factory:
  metadata:
    cache:
      adapter: filesystem
      options:
        cache_dir: data/PathHandler
        namespace: ph-metadata
      plugins:
        serializer:
          serializer: phpserialize

Articus\PathHandler\RouteInjection\Factory:
  router:
    cache:
      adapter: filesystem
      options:
        cache_dir: data/PathHandler
        namespace: ph-router
      plugins:
        serializer:
          serializer: phpserialize

Now it requires only one extra dependency psr/simple-cache and tiny configuration:

Articus\PathHandler\RouteInjection\Factory:
  metadata:
    cache:
      directory: data/PathHandler

Articus\PathHandler\RouteInjection\Factory:
  router:
    cache:
      directory: data/PathHandler

If you use separate caching service no configuration changes should be needed.

v0.5

19 Jan 21:43
Compare
Choose a tag to compare

New features

Migration notes

DataTransfer v0.3 dropped support for mapping during data transferring, so Articus\PathHandler\Producer\Transfer does not allow to specify mapper any longer.

v0.4

13 Jan 22:39
Compare
Choose a tag to compare

New features

  • migration to Zend Expressive 3.2
  • end of support for PHP 5.6 and 7.0 (same as Zend Expressive 3)
  • support for custom HTTP methods in handlers

Migration notes

Significant part of the library was rewritten from scratch due to route changes in Zend Expressive 3. Now it is not a replacement for standard routing and dispatch middlewares but a smart router factory that provides the same functionality as before. So any existing application will require drastic update.

Configuration overhaul

Please check official migration guide for Zend Expressive 3 and Path Handler documentation for details. You can also find server stub sample here.

PHP 7.1 embrace

Library interfaces for consumers, attributes and producers have type declarations now so you may have to update your own classes that implement them.

Route declaration

Articus\PathHandler\Router\TreeConfiguration did not survive changes in Zend Expressive 3 routing and was removed.

HTTP-methods declaration

Interfaces Articus\PathHandler\Operation\* were replaced with annotations Articus\PathHandler\Annotation\HttpMethod, Articus\PathHandler\Annotation\Get, Articus\PathHandler\Annotation\Post, Articus\PathHandler\Annotation\Put, Articus\PathHandler\Annotation\Patch, Articus\PathHandler\Annotation\Delete. So you have to update all your handlers. Please check library documentation for details.

v0.3

22 Jan 20:49
Compare
Choose a tag to compare

New features

  • migration to Zend Expressive 2.1,
  • huge update of routing - new prefered routing implementation was added, hard dependecy on Zend Router was removed
  • convenience update for middleware factory and router factories - you can now select their configuration root key

Migration notes

There are three breaking changes, so be careful if you are updating existing app.

Routing

SimpleRouter was renamed to TreeConfiguration and it is no longer possible to configure it inside middleware configuration block. So if you have something like this in your configuration file:

path_handler:
  routes:
    routes:
      entity:
        type: Literal
        options:
          route: /entity
          defaults:
            handler: My\Handler

you need to add "zendframework/zend-router": "^3.0" and "zendframework/zend-psr7bridge": "^1.0" to your composer.json and adjust your configuration:

#add new router service
dependencies:
  my_router: Articus\PathHandler\Router\Factory\TreeConfiguration
#add new router service configuration
Articus\PathHandler\Router\TreeConfiguration:
  #simply move your old routing configuration here
  routes:
   entity:
     type: Literal
     options:
       route: /entity
       defaults:
         handler: My\Handler
#set new router service in middleware configuration
path_handler:
  routes: my_router

Middleware configuration

Key path_handler is no longer a default configuration root for MiddlewareFactory. So you can either replace:

path_handler:
  #middleware configuration

with:

Articus\PathHandler\Middleware:
  #same middleware configuration

Or you can adjust middlware service declaration from:

dependencies:
  Articus\PathHandler\Middleware: Articus\PathHandler\MiddlewareFactory

to:

dependencies:
  Articus\PathHandler\Middleware: [Articus\PathHandler\MiddlewareFactory, path_handler]

Producer/attribute/consumer order

There was a mismatch between code and documention in how several producers or attributes or consumers with equal priority are sorted. According code and tests the first to appear was the last to be invoked while documentaion stated otherwise. The way it was described in documentation seems more loigical and easy use. So now code does exactly as documentation states. If you have handler with several attributes or producers or consumers, you need to either swap their annotation lines or set priority for them to preserve same order as was before library update.
Before update:

namespace App
use Articus\PathHandler\Annotation as PHA;
use Articus\PathHandler\Operation;
use Psr\Http\Message\ServerRequestInterface;

class MyHandler implements Operation\PostInterface
{
	/**
	 * @PHA\Attribute(name="SecondToBeInvoked)
	 * @PHA\Attribute(name="FirstToBeInvoked)
	 */
	public function handlePost(ServerRequestInterface $request)
	{
		//Some code...
	}
}

After update:

namespace App
use Articus\PathHandler\Annotation as PHA;
use Articus\PathHandler\Operation;
use Psr\Http\Message\ServerRequestInterface;

class MyHandler implements Operation\PostInterface
{
	/**
	 * @PHA\Attribute(name="FirstToBeInvoked)
	 * @PHA\Attribute(name="SecondToBeInvoked)
	 */
	public function handlePost(ServerRequestInterface $request)
	{
		//Some code...
	}
}