PHP code example of bubblegum-php / bubblegum-middlewares
1. Go to this page and download the library: Download bubblegum-php/bubblegum-middlewares 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/ */
bubblegum-php / bubblegum-middlewares example snippets
namespace App\Middlewares;
use Bubblegum\Middlewares\Middleware;
use Bubblegum\Request;
class TestMiddleware extends Middleware
{
public function handle(Request $request, array $data = []): string|array
{
// You can modify $request or data here, or make conditions
$fromWrapped = $this->handleWrapped($request, $data); // call handle function from wrapped component
// You can modify returned value from wrapped component
return $fromWrapped; // return result
}
}
// your controller
use App\Controllers\TestController;
// use Bubblegum middlewares down here
use Bubblegum\Middlewares\Wrapper;
use App\Middlewares\TestMiddleware;
Route::get('/',
Wrapper::wrap(TestController::class, TestMiddleware::class)
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.