Creating server

Put simply, REST servers send HTTP responses based on a given URL and HTTP verb. Keeping that in mind, let's start with the following chunk of code added to the rest-service/server/customer/index.php file:

<?phpif ('POST' == $_SERVER['REQUEST_METHOD']) {    header('Content-type: application/json');    echo json_encode(['data' => 'Triggered customer POST!']);}if ('GET' == $_SERVER['REQUEST_METHOD']) {    header('Content-type: application/json');    echo json_encode(['data' => 'Triggered customer GET!']);}if ('PUT' == $_SERVER['REQUEST_METHOD']) {    header('Content-type: application/json');    echo json_encode(['data' => 'Triggered customer PUT!']);}if ('DELETE' == $_SERVER['REQUEST_METHOD']) {    header('Content-type: application/json');    echo ...

Get Mastering PHP 7 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.