PHP code example of sambenge / codeigniter4-transformer
1. Go to this page and download the library: Download sambenge/codeigniter4-transformer 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/ */
sambenge / codeigniter4-transformer example snippets
use App\Transformers\UserTransformer;
$users = model('UserModel')->findAll();
// Transform a single record
$user = UserTransformer::make($users[0]);
// Transform multiple records
return $this->response->setJSON([
'data' => UserTransformer::collection($users)
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.