PHP code example of bastian / fractal-magic

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

    

bastian / fractal-magic example snippets

 php
Response::macro('fractal', function()
{
  return new Hofmann\FractalMagic\Fractal([
    'resource' => new ResourceTransformer
  ]);
});
 php
class SomeController {

  public function index()
  {
    return Response::fractal()->resources($data);
  }
  
}