When we originally created the API for Expressive, it was programmatic:
We had pipelines:
$pipeline->pipe($loggingMiddleware);
$pipeline->pipe($serverUrlHelperMiddleware);
$pipeline->pipeRoutingMiddleware();
<?php | |
namespace App\Entity; | |
use ArrayIterator; | |
class UserCollection extends ArrayIterator | |
{ | |
} |
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<title>Choices example</title> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous"> |
<?php | |
/** | |
* composer.json: | |
* { | |
* "require": { | |
* "zendframework/zend-http": "2.*" | |
* } | |
* } | |
*/ | |
require __DIR__ . '/vendor/autoload.php'; |
<?php | |
public function someAction() | |
{ | |
$data = doSomeWorkFetchSomeData(); | |
$entity = new \ZF\Hal\Entity($data, $data['id']); // or similar | |
return new \ZF\ContentNegotiation\ViewModel([ | |
'payload' => $entity, | |
]); | |
} |
<?php | |
use Interop\Http\ServerMiddleware\DelegateInterface; | |
use Interop\Http\ServerMiddleware\MiddlewareInterface; | |
use Psr\Http\Message\ServerRequestInterface; | |
class RemoveDevPrefixMiddleware implements MiddlewareInterface | |
{ | |
private $prefix; |
<?php | |
// In a module class somewhere... | |
use Zend\EventManager\LazyListener; | |
use Zend\Mvc\MvcEvent; | |
class Module | |
{ | |
public function onBootstrap(MvcEvent $e) | |
{ |
<?php | |
/* We'll assume that all of the above classes are defined. | |
* | |
* We'll assume that Api\V1\Rpc\Query\QueryController will handle an RPC service | |
* call to /search?s=thing. It needs to be configured such that it responds to | |
* GET requests, and Content Negotiation is set to HalJson. | |
* | |
* This is what it will look like: | |
*/ |
Proposed zend-expressive-router changes include:
Adding a $path
parameter to RouteResult::fromRouteMatch()
.
What if instead we were to add a new static method, RouteResult::fromRoute()
, and a new instance method, RouteResult::getRoute()
? (as I have suggested in zendframework/zend-expressive#398)? This would allow consumers to then pull the path from the Route
instead, and provide access to the path, name, allowed methods, options, etc. (e.g., $result->getRoute()->getPath()
)
This could even be done in a new 1.3.0 minor release; users who depend on that new feature would need to update their project to pin to the new minor release or later; otherwise, everything continues working as normal.
<?php | |
namespace MyLib; | |
use ZF\OAuth2\Adapter\PdoAdapter; | |
class OAuth2PdoAdapter extends PdoAdapter | |
{ | |
protected $mapper; | |
public function setUsersMapper(Users\MapperInterface $mapper) |