PHP code example of harryosmar / php-restful-api-response
1. Go to this page and download the library: Download harryosmar/php-restful-api-response library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
harryosmar / php-restful-api-response example snippets
use PhpRestfulApiResponse\Tests\unit\Lib\Book;
/** @var \PhpRestfulApiResponse\Response $response */
echo $response->withItem(
new Book('harry', '[email protected]', 'how to be a ninja', 100000, 2017),
new \PhpRestfulApiResponse\Tests\unit\Lib\Transformer\Book,
201
);
use PhpRestfulApiResponse\Tests\unit\Lib\Book;
/** @var \PhpRestfulApiResponse\Response $response */
$response->withCollection(
[
new Book('harry', '[email protected]', 'how to be a ninja', 100000, 2017),
new Book('harry', '[email protected]', 'how to be a mage', 500000, 2016),
new Book('harry', '[email protected]', 'how to be a samurai', 25000, 2000),
],
new \PhpRestfulApiResponse\Tests\unit\Lib\Transformer\Book,
200
);