PHP code example of bilfeldt / laravel-route-statistics
1. Go to this page and download the library: Download bilfeldt/laravel-route-statistics 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/ */
bilfeldt / laravel-route-statistics example snippets
// bootstrap/app.php
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
...
)
->withMiddleware(function (Middleware $middleware) {
// Place the Route middleware before all global middleware
$middleware->prepend(\Bilfeldt\LaravelRouteStatistics\Http\Middleware\RouteStatisticsMiddleware::class);
})
->withExceptions(function (Exceptions $exceptions) {
...
})
->create();
...
Route::middleware(['routestatistics'])->...
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index(Request $request)
{
$request->routeStatistics(); // This will enable route statistics logging
return view('home');
}
}