PHP code example of michaeldrennen / jsonapi

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

    

michaeldrennen / jsonapi example snippets


// This $user is the object we want to return to the client requesting the User data.
$user  = new User( 74, "Mike", TRUE );

// Create the response object, set the $user as the data you want to return, and 
// specify the Transformer you want to use to munge the User data. 
$array = \MichaelDrennen\JSONAPI\Response::create()
                                         ->setData( $user )
                                         ->transformWith( new UserTransformer() )
                                         ->toArray();