1. Go to this page and download the library: Download bpa/api-sandbox-bundle 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/ */
bpa / api-sandbox-bundle example snippets
class AppKernel extends Kernel {
public function registerBundles() {
// ...
$bundles = [
// ...
new Bpa\ApiSandboxBundle\ApiSandboxBundle(),
// ...
];
// ...
}
}
$kernel = new AppKernel('sandbox', false);
namespace AppBundle\Controller;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Bpa\ApiSandboxBundle\Annotation as Bpa;
use FOS\RestBundle\Controller\FOSRestController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
/**
* Controller for books
*/
class BookController extends FOSRestController
{
/**
* Get book informations
*
* Retrieve informations about a specific book
*
* @ApiDoc(
* section="Books",
* resource=true,
* statusCodes={
* 200="Ok",
* }
* )
*
* @Bpa\SandboxRequest(
* responses={
* @Bpa\SandboxResponse(
* statusCode=200,
* content="@AppBundle/Resources/sandbox/responses/books/get.json",
* )
* }
* )
*
* @param Request $request
*
* @return JsonResponse
*/
public function getAction(Request $request)
{
return new JsonResponse([
'books' => [ 'id' => 1, 'title' => 'A Brief History of Time' ],
]);
}
}