JosephSilber / page-cache

Caches responses as static files on disk for lightning fast page loads.
MIT License
1.21k stars 118 forks source link

Too few arguments to function Illuminate\Routing\Router::middleware() #73

Closed raficopuntiando closed 3 years ago

raficopuntiando commented 3 years ago

Hi, I installed the pack in my laravel 5.2 and but when I try to cache one page with middleware('page-cache') my website doesn't work and I have this error

Type error: Too few arguments to function Illuminate\Routing\Router::middleware(), 1 passed in /home/vagrant/code/greenjurisdictionaldatabase/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 217 and exactly 2 expected

Route::middleware('page-cache')->get('/about', function () {
    return view('pages/about', array('id_page'=>2));
});

if I remove the middleware('page-cache') from my routes my website is working again and the page-cache folder in the public root is saving a copy of all my pages. but I don't know if the pack is working well without the middleware('page-cache') in each route.

And another thing, when I push my files to the server the page-cache is located in my document_root but not in my publict_html folder

thanks

JosephSilber commented 3 years ago

In Laravel 5.2, you have to call middleware at the end:

Route::get('/about', function () {
    return view('pages/about', array('id_page'=>2));
})->middleware('page-cache');

See the docs: https://laravel.com/docs/5.2/middleware#assigning-middleware-to-routes