Download the PHP package mvccore/ext-router-localization without Composer

On this page you can find all versions of the php package mvccore/ext-router-localization. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package ext-router-localization

MvcCore - Extension - Router - Localization

Latest Stable Version License PHP Version

MvcCore Router extension to have localized and non-localized URL addresses in your application, very configurable.
URL addresses could contain localization by language code or by language and locale code together (/en/custom/path or
/en-US/custom/path or /any/non-localized/path). The router works with any HTTP method and with multi or single language route patterns and reverses.

Outline

  1. Installation
  2. Features
    2.1. Features - Routing
    2.2. Features - Url Generating
  3. How It Works
    3.1. How It Works - Routing
    3.2. How It Works - Url Completing
  4. Usage
    4.1. Usage - Bootstrap Initialization
    4.2. Usage - Default Localization
    4.3. Usage - Allowed Localizations
    4.4. Usage - Routes Configuration
    4.5. Usage - Allow Non-Localized Routes
    4.6. Usage - Detect Localization Only By Language
    4.7. Usage - Localization Equivalents
    4.8. Usage - Route Records By Language And Locale
    4.9. Usage - Redirect To Default And Back In First Request
    4.10. Usage - Generate Localized URL Or Non-Localized URL
    4.11. Usage - Localized URL In Non-Localized Request
  5. Advanced Configuration
    5.1. Advanced Configuration - Session Expiration
    5.2. Advanced Configuration - Strict Session Mode
    5.3. Advanced Configuration - Routing GET Requests Only

1. Installation

2. Features

2.1. Features - Routing

go to top

2.2. Features - Url Generating

go to top

3. How It Works

3.1. How It Works - Routing

go to top

3.2. How It Works - Url Completing

go to top

4. Usage

4.1. Usage - Bootstrap Initialization

Add this to Bootstrap.php or to very application beginning, before application routing or any other extension configuration using router for any purposes:

go to top

4.2. Usage - Default Localization

Default localization configuration is always required.

go to top

4.3. Usage - Allowed Localizations

Default localization configured above en-US is allowed automatically.

Any other request (e.g. path like: /something) is not localized and if no non-localized route is matched, it's redirected to default localization path like: /en-US/something, which could be useful to prevent URL typo mistakes.

But also any other requested localization not allowed (e.g. path like: /nl-NL/product-lijst) is not used to localize request and if no non-localized route is matched, request is redirected to default localization path /en-US/nl-NL/product-lijst, which could generate error 404 - not found otherwise, so be careful to have everywhere only localizations you want.

go to top

4.4. Usage - Routes Configuration

go to top

4.5. Usage - Allow Non-Localized Routes

Non-localized routes are allowed by default, so you can route localized and non-localized routes together. But to have all routes strictly localized and to redirect all requests into default localization prefix or into URL with default localization query string param value - all requests - where was not possible to recognize localization by query string param and also where was not possible to recognize localization even by URL prefix, you need to configure router by:

go to top

4.6. Usage - Detect Localization Only By Language

The router is configured with TRUE value by default to detect localization only by language record from Accept-Language HTTP header record, not strictly together with locale code. The parsed international language code is enough by default to choose final target application localization. There will be chosen first localization in the allowed list with detected language.
If the value is FALSE, then there is necessary to send into application in Accept-Language HTTP header international language code together with international locale code with the only same combination which application has configured in allowed localizations only:

go to top

4.7. Usage - Localization Equivalents

You can define a list of localization equivalents used in localization detection by HTTP header Accept-Language parsed in the first request. It could be used for language very similar countries like Ukraine & Russia, Czech & Slovakia ... Keys in this array is target localization, values are an array with target localization equivalents.

go to top

4.8. Usage - Route Records By Language And Locale

If you define TRUE value (default is FALSE), defined route records like pattern, match, reverse or defaults has to be defined by international language code and international locale code, not only by language code. This option is very rare if different locales have different naming for URL strings.

go to top

4.9. Usage - Redirect To Default And Back In First Request

If TRUE (FALSE by default), if request is historically first (by session), if localization by HTTP headers is not the best match or if it is the best match but requested localization is not the same as HTTP headers prefer, redirect to default localization homepage with source_url query string param:

go to top

4.10. Usage - Generate Localized URL Or Non-Localized URL

If you put into Url() method as first param localized route name, there is generated localized URL automatically:

If there is put a non-localized route name, returned is non-localized URL.

go to top

4.11. Usage - Localized URL In Non-Localized Request

If request is routed on any non-localized route and request object has some strange localization from session or default localization (if there was nothing in session), you still could generate differently localized URL addresses, for example for email messages in CRON scripts like so:

go to top

5. Advanced Configuration

5.1. Advanced Configuration - Session Expiration

There is possible to change session expiration about detected localization value to not recognize localization every request where is no prefix in URL, because to process parsing Accept-Language HTTP header could take some time. By default there is 1 hour. You can change it by:

go to top

5.2. Advanced Configuration - Strict Session Mode

In session strict mode, there is not possible to change localization only by requesting different localization prefix in URL. Strict session mode is router mode when localization is managed by session value from the first request HTTP header recognition. All requests to different localization version than the version in session are automatically redirected to localization version stored in the session.

Normally, there is possible to get different localization version only by requesting different localization version URL prefix. For example - to get a different version from en-US localization, for example, to get de-DE localization, it's only necessary to request application with configured de-DE allowed localization in URL like this: /de-DE/any/application/request/path.

In session strict mode, there is possible to change localization version only by special $_GET parameter in your media version navigation. For example - to get a different localization from en-US, for example, de-DE localization, you need to add into query string parameters like this: /any/application/request/path?switch_localization=de-DE Then, there is changed localization version stored in the session and the user is redirected to the new localization version with de-DE URL prefixes everywhere.

To have this session strict mode, you only need to configure router by:

go to top

5.3. Advanced Configuration - Routing GET Requests Only

The router manages the localization version only for GET requests. It means redirections to the proper version in session strict mode or to redirect in the first request to recognized localization version. POST requests and other request methods to manage for localization version doesn't make sense. For those requests, you have still localization version record in session and you can use it any time. But to process all request methods, you can configure the router to do so like this:

go to top


All versions of ext-router-localization with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
mvccore/mvccore Version ^5.3
mvccore/ext-router-extended Version ^5.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mvccore/ext-router-localization contains the following files

Loading the files please wait ....