PHP code example of d-scribe / laravel-apidoc-generator

1. Go to this page and download the library: Download d-scribe/laravel-apidoc-generator 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/ */

    

d-scribe / laravel-apidoc-generator example snippets


$app->register(\Mpociot\ApiDoc\ApiDocGeneratorServiceProvider::class);

$app->configure('apidoc');

return [
     //...,

     'routes' => [
          [
              'match' => [
                  'domains' => ['*'],
                  'prefixes' => ['api/*', 'v2-api/*'],
                  'versions' => ['v1'],
              ],
              '


return [
     //...,

     'routes' => [
          [
              'match' => [
                  'domains' => ['v1.*'],
                  'prefixes' => ['*'],
              ],
              '              ],
          ],
          [
              'match' => [
                  'domains' => ['v2.*'],
                  'prefixes' => ['*'],
              ],
              '

/**
 * @group User management
 *
 * APIs for managing users
 */
class UserController extends Controller
{

 /**
  * Create a user
  *
  * [Insert optional longer description of the API endpoint here.]
  *
  */
  public function createUser()
  {

  }

 /**
  * @group Account management
  *
  */
  public function changePassword()
  {

  }
}

/**
 * @urlParam id int wPost($id)
{
    // ...
}

/**
 * @bodyParam title string ng The type of post to create. Defaults to 'textophonious'.
 * @bodyParam author_id int the ID of the author
 * @bodyParam thumbnail image This is / ...
}

    /**
     * @urlParam id _id ired The id of the user. Example: me
     * @queryParam page _id string The id of the room.
     * @bodyParam forever boolean Whether to ban the user forever. Example: false
     */

/**
 * @bodyParam title string ired The title of the post.
 * @bodyParam type string The type of post to create. Defaults to 'textophonious'.
 * @bodyParam author_id int the ID of the author
 * @bodyParam thumbnail image This is 

/**
 * @response {
 *  "id": 4,
 *  "name": "Jessica Jones",
 *  "roles": ["admin"]
 * }
 */
public function show($id)
{
    return User::find($id);
}

/**
 * @response {
 *  "id": 4,
 *  "name": "Jessica Jones",
 *  "roles": ["admin"]
 * }
 * @response 404 {
 *  "message": "No query results for model [\App\User]"
 * }
 */
public function show($id)
{
    return User::findOrFail($id);
}

/**
 * @transformercollection \App\Transformers\UserTransformer
 * @transformerModel \App\User
 */
public function listUsers()
{
    //...
}

/**
 * @transformer \App\Transformers\UserTransformer
 */
public function showUser(User $user)
{
    //...
}

/**
 * @transformer \App\Transformers\UserTransformer
 * @transformerModel \App\User
 */
public function showUser(int $id)
{
    // ...
}

/**
 * @responseFile responses/users.get.json
 */
public function getUser(int $id)
{
  // ...
}

/**
 * @responseFile responses/users.get.json
 * @responseFile 404 responses/model.not.found.json
 */
public function getUser(int $id)
{
  // ...
}

/**
 * Books List
 *
 * Fetch a listing of books
 *
 * @responseFile path/to/index/response/file
 */
public function index()
{
    return parent::index();
}

/**
 * Book Resource
 *
 * The long description of the book resource
 *
 * @group Books
 *
 * @indexTitle Books List
 * @indexDescription Fetch a listing of books
 * @indexResponseFile path/to/index/response/file
 *
 * @storeTitle Create Book
 * @storeDescription Create a new book
 * @storeBodyParam title string 

Route::group(['tags' => ['internal']], function () {
    Route::resource('/books', 'BooksController')
});

/**
 * @tags internal
 */
public function index()
{
    # code...
}

php artisan apidoc:generate --skip-tags=internal

php artisan apidoc:generate --only-tags=internal
bash
php artisan vendor:publish --provider="Mpociot\ApiDoc\ApiDocGeneratorServiceProvider" --tag=apidoc-config
sh
php artisan apidoc:generate

sh
php artisan apidoc:rebuild