PHP code example of ahmedessam / api-versionizer

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

    

ahmedessam / api-versionizer example snippets


'versions' => [
    'v1' => [
        'name'        => 'v1',
        'description' => 'First version of the API',
        'status'      => 'active',
        'files' => [
            [
                'name'        => 'users',
                'as'          => 'users',
                'prefix'      => 'users',
                'namespace'   => 'Users',
                'middlewares' => ['auth:api'],
            ],
        ],
    ],
    'v2' => [
        'name'        => 'v2',
        'description' => 'Second version of the API',
        'status'      => 'active',
        'files' => [
            [
                'name'        => 'users',
                'as'          => 'users',
                'prefix'      => 'users',
                'namespace'   => 'Users',
                'middlewares' => ['auth:api'],
            ],
            [
                'name'        => 'posts',
                'as'          => 'posts',
                'prefix'      => 'posts',
                'namespace'   => 'Posts',
                'middlewares' => ['auth:api'],
            ],
        ],
    ],
],
bash
php artisan vendor:publish --tag=apiversionizer-config
bash
php artisan api:versionize --versions=v1,v2
bash
php artisan api:versionize --copy=v1 --to=v2
bash
php artisan api:versionize --delete=v1