by Matthew Weier O'Phinney and Enrico Zimuel
Zend Framework Team
Rogue Wave Software, Inc.
ZendCon 2017, Las Vegas (NV), Oct. 23
// What we'll use
public function process(
ServerRequestInterface $request
) : ResponseInterface
// Current PSR-15
public function handle(
ServerRequestInterface $request
) : ResponseInterface
// What we'll use
public function process(
ServerRequestInterface $request,
DelegateInterface $delegate
) : ResponseInterface
// Current PSR_15
public function process(
ServerRequestInterface $request,
RequestHandlerInterface $delegate
) : ResponseInterface
// DelegateInterface:
$response = $delegate->process($request);
// RequestHandlerInterface
$response = $delegate->handle($request);
public function process(ServerRequest $request, Delegate $delegate)
{
$item = $this->repository->fetchById(
$request->getAttribute('id')
);
return new JsonResponse($item);
}
CREATE TABLE user (
username VARCHAR(80) PRIMARY KEY,
password VARCHAR(100) NOT NULL,
role VARCHAR(80) DEFAULT 'user'
);
CREATE TABLE book (
id BINARY PRIMARY KEY,
title VARCHAR(80),
author VARCHAR(80),
publisher VARCHAR(80),
pages INT NULL,
year INT NOT NULL,
isbn VARCHAR(13) UNIQUE NULL
);
CREATE TABLE review (
id BINARY PRIMARY KEY,
username VARCHAR(80) NOT NULL,
book_id BINARY NOT NULL,
review TEXT NOT NULL,
stars INT NOT NULL
);
git clone https://github.com/ezimuel/zendcon2017-api-tutorial
* user authentication required
* user authentication required, ** only admin
More info at
https://docs.zendframework.com/zend-expressive/