{locale} placeholder in routes |
Hi, I just want to share with you one of my changes I made to base router. Hopefully, it will save some time, to somebody who will search for the same solution like I did.
I was wondering why my project takes URL like Code: www.domain.com/blah/users when I've never defined it? Why this works? What I found out: PHP Code: $routes->group('{locale}', function ($routes) { {locale} will take ANYTHING Why does all this URLs works? Code: www.domain.com/this/users {locale} should represent locale placeholder. According to me, it does not. It represent anything. Yes, it takes default locale value, if placeholder doesn't match any supported language. PHP Code: public $supportedLocales = ['en']; Only this should works. Code: www.domain.com/en/users Changes I have made: Create new file app/Services/Router.php PHP Code: <?php Check added part of code: PHP Code: /** Add this use to app/Config/Services.php PHP Code: use App\Services\Router; Add custom router: PHP Code: /** |
Messages In This Thread |
{locale} placeholder in routes - by webdeveloper - 06-08-2022, 06:23 AM
RE: {locale} placeholder in routes - by includebeer - 06-08-2022, 03:10 PM
RE: {locale} placeholder in routes - by webdeveloper - 06-09-2022, 01:56 AM
RE: {locale} placeholder in routes - by includebeer - 06-09-2022, 02:44 PM
RE: {locale} placeholder in routes - by InsiteFX - 06-09-2022, 11:57 PM
RE: {locale} placeholder in routes - by includebeer - 06-10-2022, 12:36 PM
RE: {locale} placeholder in routes - by kenjis - 06-10-2022, 06:05 PM
RE: {locale} placeholder in routes - by includebeer - 06-10-2022, 06:34 PM
RE: {locale} placeholder in routes - by webdeveloper - 06-11-2022, 04:29 AM
|