1. Go to this page and download the library: Download gaiatools/content-accord 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/ */
use GaiaTools\ContentAccord\Attributes\ApiVersion;
use GaiaTools\ContentAccord\Attributes\MapToVersion;
#[ApiVersion('2')]
class UserController
{
public function index() {}
#[MapToVersion('2.1')]
public function show() {}
}
use GaiaTools\ContentAccord\ValueObjects\ApiVersion;
public function index(): JsonResponse
{
$version = apiVersion(); // ?ApiVersion
}
use GaiaTools\ContentAccord\Http\NegotiatedContext;
$version = app(NegotiatedContext::class)->get('version');
use GaiaTools\ContentAccord\Testing\Concerns\InteractsWithApiVersion;
class ExampleTest extends TestCase
{
use InteractsWithApiVersion;
public function test_example()
{
$this->withApiVersion('2')->get('/api/users');
}
}