Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bhojkamal's avatar

In laravel 11 and 12, making new routes files and applying middleware and domain to them difficult or impossible?

In Laravel 11 and 12, making routes custom files and applying middleware, add domain to route files is difficult; may be it is possible for some or few developers, I am trying to add middleware to just api or just api.php for specific domain with specific custom middleware for few day, but I could not apply the custom middleware to routes files and also applying the domain to particular route file. It was quite easy in laravel 8, 9 or 10. Laravel framework getting harder for such small adjustment or adding such bit thing, I could not understand.

I tried to apply ItendifyTenant class to api.php files. but could not succeed. If I put this $middleware->append(IdentifyTenant::class); it applied to all routes files. If I $middleware->prependToGroup('api', IdentifyTenant::class); it does not work. In laravel, 8, 9, 10. It was quite easy. Assist is appreciated.

0 likes
1 reply

Please or to participate in this conversation.