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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.