I'm trying to register a middleware class in an addon and it isn't being run.

I have this in my addon's service provider:

$this->app['router']->middleware('addon-name', AddonNameMiddleware::class);

If I dump out $this->app['router'], I can see it in the array, but the middleware doesn't seem to be being run, as if I try and dd() anything in the handle method, nothing happens. It's not even loading the middleware file, as I can create a parse error in the file and nothing happens, but the namespacing is correct and I have run composer dump-autoload to no effect.

All the docs say is "in general, we mean registering things, including registering service container bindings, event listeners, middleware, and even routes", which is just copied from the Laravel docs, and posts on other sites are saying to do what I'm doing, but I'm not having any joy.

Does anyone have any ideas?