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',
'group' => 'admin',
'middlewares' => ['auth:api'],
],
],
],
],
Route::crud('users', 'UserController');
Route::apiResource('users', 'UserController');
Route::get('users/trash', 'UserController@trash')->name('users.trash');
Route::patch('users/{user}/restore', 'UserController@restore')->name('users.restore');
Route::delete('users/{user}/force-delete', 'UserController@forceDelete')->name('users.force-delete');
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