PHPackages                             exs/silex-locale-detector - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. exs/silex-locale-detector

ActiveLibrary[Localization &amp; i18n](/categories/localization)

exs/silex-locale-detector
=========================

Locale detector bundle for Silex 2

1804PHP

Since Jul 17Pushed 10y ago11 watchersCompare

[ Source](https://github.com/ExSituMarketing/EXS-silex-locale-detector)[ Packagist](https://packagist.org/packages/exs/silex-locale-detector)[ RSS](/packages/exs-silex-locale-detector/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

EXS-silex-locale-detector
=========================

[](#exs-silex-locale-detector)

Locale detection with country and language breakdown

It will get the accepted language and country from $\_SERVER\['HTTP\_ACCEPT\_LANGUAGE'\] and will check it against Db.

If it's not found in Db, it will insert it and return the new entry.

Results are cached with memcache.

Installation
------------

[](#installation)

Create a composer.json in your projects root-directory :

```
{
    "require": {
        "EXS/silex-locale-detector": "~1.0@dev"
    }
}
```

and run :

```
$ curl -sS http://getcomposer.org/installer | php
$ php composer.phar install
```

or run this command:

```
    composer require exs/silex-locale-detector ~1.0@dev
```

Composer will now update all dependencies and you should see our bundle in the list:

```
  - Installing exs/silex-locale-detector (dev-master 463eb20)
    Cloning 463eb2081e7205e7556f6f65224c6ba9631e070a
```

Update your DB
--------------

[](#update-your-db)

```
CREATE TABLE `locales` (
  `id` smallint(6) NOT NULL AUTO_INCREMENT,
  `tag` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
  `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `tag` (`tag`)
) ENGINE=InnoDB AUTO_INCREMENT=134 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `languages` (
  `id` smallint(6) NOT NULL AUTO_INCREMENT,
  `tag` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
  `language` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_language` (`tag`)
) ENGINE=InnoDB AUTO_INCREMENT=142 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `countries` (
  `id` smallint(6) NOT NULL AUTO_INCREMENT,
  `iso3166alpha2` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL,
  `iso3166alpha3` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL,
  `iso3166numeric` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL,
  `fips` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL,
  `country` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `continent` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_country` (`iso3166alpha2`)
) ENGINE=InnoDB AUTO_INCREMENT=259 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
```

Registering
-----------

[](#registering)

```
    $app->register(new \EXS\LocaleProvider\Providers\ServiceProvider());
```

Example
-------

[](#example)

```
    $app->register(new \EXS\LocaleProvider\Providers\ServiceProvider());
    // Simple use
    $language = $app['exs.serv.locale.detector']->getLanguage();
    $local = $app['exs.serv.locale.detector']->getLocale();
    $country = $app['exs.serv.locale.detector']->getCountry();
```

Dependencies
------------

[](#dependencies)

Silex 2.0

Doctrine\\Dbal 2.2

kuikui/memcache-service-provider ~2.0

You need a memcache server up and running.

License
-------

[](#license)

The LocaleDetectorPovider for Silex is licensed under the [MIT license](https://github.com/ExSituMarketing/EXS-silex-locale-detector/blob/master/LICENSE).

#### Contributing

[](#contributing)

Anyone and everyone is welcome to contribute.

If you have any questions or suggestions please [let us know](http://www.ex-situ.com/).

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/af284ff600087e33c35e00252ade1cc1dc3987f969661b91b036254dbe4bbb9c?d=identicon)[rumpranger](/maintainers/rumpranger)

---

Top Contributors

[![damien-qc](https://avatars.githubusercontent.com/u/12374806?v=4)](https://github.com/damien-qc "damien-qc (14 commits)")[![rumpranger](https://avatars.githubusercontent.com/u/718301?v=4)](https://github.com/rumpranger "rumpranger (1 commits)")

### Embed Badge

![Health badge](/badges/exs-silex-locale-detector/health.svg)

```
[![Health](https://phpackages.com/badges/exs-silex-locale-detector/health.svg)](https://phpackages.com/packages/exs-silex-locale-detector)
```

###  Alternatives

[smmoosavi/php-gettext

Wrapper for php-gettext by danilo segan. This library provides PHP functions to read MO files even when gettext is not compiled in or when appropriate locale is not present on the system.

1927.0k1](/packages/smmoosavi-php-gettext)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
