brainstorm/slim4locale

A simple Middleware for Slim 4 to use locale in uri, part of the PerSeo CMS

1.0.1 2021-06-01 08:22 UTC

This package is auto-updated.

Last update: 2024-10-29 06:00:20 UTC


README

A simple middleware for Slim4 framework for using locale in uri. Usage is very simple, just enable this Middleware (in the Middleware part of your Slim4 Project) with:

<?php

use BrainStorm\Slim4Locale\Locale;

$enabled = true; //or false if disabled
$languages = ['en', 'de', 'it']; //all the languages permitted

$app->add(new Locale($app, $enabled, $languages));

After this, all your Slim 4 routes works without the language prefix in routes (because this Middleware check the language before routes are called). To retrive what language the project is using, just call:

$request->getAttribute('locale');

Simple, isn't it?