1. Go to this page and download the library: Download team-moment/fractal 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/ */
team-moment / fractal example snippets
namespace Transformer;
use Moment\Fractal\AbstractTransformer;
class AppTransformer extends AbstractTransformer
{
public function transform($app)
{
return [
'id' => $app->id,
'name' => $app->name,
];
}
}
namespace Controller;
use Models\App;
use FastD\Http\ServerRequest;
use Transformer\AppTransformer;
use FastD\Http\Response;
class AppsController
{
public function show(ServerRequest $request)
{
$app = App::find($request->getAttribute('id'));
return fractal()->item($app, AppTransformer::class, Response::HTTP_OK);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.