Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation instructions on Laravel 10 #108

Open
RasmusLindstrom opened this issue Feb 20, 2023 · 2 comments
Open

Installation instructions on Laravel 10 #108

RasmusLindstrom opened this issue Feb 20, 2023 · 2 comments
Labels

Comments

@RasmusLindstrom
Copy link

I tried to install this on Laravel 10, but the instructions don't match

  1. When I want to run this on specific pages, the instructions say to first open "app/Http/Kernel.php" and then "...you should instead add a new mapping to the routeMiddleware array", but there's no such array in that Kernel-file. I can find one in another Kernel.php, where there's an empty array. Should it be added there instead?

  2. Web.php seems to have a different format in Laravel 10 than last time I played around with Laravel, now a route in "web.php" looks like this: Route::get('/', function () { return view('index'); });

According to the docs, the way to do this would be: Route::middleware('page-cache')->get('/', 'PostController@index');
But that is not working. [Perhaps the issue here is that I implemented the middleware incorrectly in 1)]

Thanks!

@JosephSilber
Copy link
Owner

In Laravel 10, routeMiddleware has been renamed to middlewareAliases.

Thanks for reminding me to update the docs: 3893f39

@JosephSilber
Copy link
Owner

JosephSilber commented Feb 20, 2023

Web.php seems to have a different format in Laravel 10 than last time I played around with Laravel

Both of these syntaxes are valid:

// This uses an inline function to handle the route:
Route::middleware('page-cache')->get('/', function () {
    return view('index');
});

// This uses a controller method to handle the route:
Route::middleware('page-cache')->get('/', 'PostController@index');

See the Laravel documentation for more details: https://laravel.com/docs/10.x/routing#basic-routing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants