PHP code example of baldeweg / api-bundle

1. Go to this page and download the library: Download baldeweg/api-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/ */

    

baldeweg / api-bundle example snippets


Baldeweg\Bundle\ApiBundle\BaldewegApiBundle::class => ['all' => true],

use Baldeweg\Bundle\ApiBundle\AbstractApiController;
use Baldeweg\Bundle\ApiBundle\Response;

$response = new Response();

// Contains the keys of the entity you need
$fields = ['id', 'name', 'user' => ['id'], 'createdAtTimestamp', 'commentsCount'];

// JSON Response with serialized data
$response->single($fields, $genre); // single entity
$response->collection($fields, $genres); // array of entities
$response->invalid(); // Return message and 400 status code
$response->deleted(); // Return message and 200 status code

// Parse the data from the request and make them available to the form
$this->submitForm($request)

use \Baldeweg\Bundle\ApiBundle\ApiTestTrait;