1. Go to this page and download the library: Download arkye/support 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/ */
arkye / support example snippets
use Carbon\Carbon;
use Illuminate\Support\Collection;
use Arkye\Support\DataTransferObject\DataTransferObject;
class MyDTO extends DataTransferObject
{
public Carbon $createdAt;
public Collection $tags;
}
$dto = new MyDTO(createdAt: '2000-01-01', tags: ['tag1', 'tag2']);
use Arkye\Support\Data\Data\Attributes\Transformers\CaseTransformer;use Arkye\Support\DataTransferObject\DataTransferObject;use Carbon\Carbon;
#[CaseTransformer('camel', 'snake')]
class MyDTO extends DataTransferObject
{
public Carbon $createdAt;
public string $fullName;
}
// Request came with created_at and full_name
$dto = new MyDTO(request()->all());
// Do some work with DTO...
// Will be converted to snake case again
response()->json($dto->toArray());
use Arkye\Support\Data\Data\Attributes\Transformers\CaseTransformer;use Arkye\Support\DataTransferObject\DataTransferObject;use Carbon\Carbon;
#[CaseTransformer('camel')]
class MyDTO extends DataTransferObject
{
public Carbon $createdAt;
public string $fullName;
}
// Request came with created_at and full_name
$dto = new MyDTO(request()->all());
// Do some work with DTO...
// Will be {"createdAt": "something", "fullName": "something"}
die($dto->tojson());
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.