PHP code example of idnexacloud / laravel-bytedocs
1. Go to this page and download the library: Download idnexacloud/laravel-bytedocs 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/ */
idnexacloud / laravel-bytedocs example snippets
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\User;
class UserController extends Controller
{
/**
* Get all users with pagination support
* @param page query integer false "Page number for pagination"
* @param limit query integer false "Number of users per page"
* @param search query string false "Search term to filter users"
*/
public function index(Request $request)
{
// Your implementation
}
/**
* Create a new user account
*/
public function store(Request $request)
{
// Your implementation
}
/**
* Get user details by ID
* @param id path integer true "User ID to retrieve"
*/
public function show(User $user)
{
// Your implementation
}
}
use ByteDocs\Laravel\Facades\ByteDocs;
use ByteDocs\Laravel\Core\RouteInfo;
use ByteDocs\Laravel\Core\Parameter;
// In a service provider or controller
ByteDocs::addRouteInfo(new RouteInfo(
method: 'GET',
path: '/api/custom-endpoint',
handler: null,
summary: 'Custom endpoint',
description: 'This is a manually registered endpoint',
parameters: [
new Parameter('id', 'path', 'integer', true, 'Record ID'),
new Parameter('
use ByteDocs\Laravel\Facades\ByteDocs;
// Get OpenAPI JSON
$openAPIJSON = ByteDocs::getOpenAPIJSON();
// Get OpenAPI YAML
$openAPIYAML = ByteDocs::getOpenAPIYAML();
// Save to file
file_put_contents(storage_path('api-docs/openapi.yaml'), $openAPIYAML);
file_put_contents(storage_path('api-docs/openapi.json'), json_encode($openAPIJSON, JSON_PRETTY_PRINT));