PHP code example of treblle / treblle-laravel

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

    

treblle / treblle-laravel example snippets


protected $middlewareAliases = [
  // the rest of your middleware aliases
  'treblle' => \Treblle\Middlewares\TreblleMiddleware::class,
];

Route::middleware(['treblle'])->group(function () {

  // YOUR API ROUTES GO HERE
  Route::prefix('samples')->group(function () {
    Route::get('{uuid}', [SampleController::class, 'view']);
    Route::post('store', [SampleController::class, 'store']);
  });

});

Route::group(function () {
  Route::prefix('users')->group(function () {

    // IS LOGGED BY TREBLLE
    Route::get('{uuid}', [UserController::class, 'view'])->middleware('treblle');

    // IS NOT LOGGED BY TREBLLE
    Route::post('{uuid}/update', [UserController::class, 'update']);
  });
});
bash
php artisan treblle:start