twiro / routing

XML based frontend routing for Symphony.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Routing

XML based frontend routing for Symphony.

Configuration

By default, the extension stores a routes.xml file in your workspace folder.

However, a new setting is also added to your config.php, where you can provide an alternative file path relative to the workspace folder.

Attention

This extension completely replaces Symphony's default routing.

This means it will throw a FrontendPageNotFoundException and display a 404 page for every path that's not defined in your routes.xml file, even if the page actually exists.

Caching

For better performance, the routes.xml file is only processed once and then cached using Symphony's Cacheable API.

It's therefore necessary to refresh the cache after making changes in your routes.xml or config.php.

This can be done by simply re-enabling the extension under System › Extensions.

Schema

The routes.xml schema is pretty simple.

<routes>
    <route from="..." to="..." />
    <route from="..." to="...">
        <filter parameter="..." match="..." />
    </route>
</routes>

Routes

Each route is defined by a <route> element, which has two attributes, @from and @to.

These attributes contain pathes relative to your root URL.

<route from="/en/about-us/"  to="/about-us/" />
<route from="/de/ueber-uns/" to="/about-us/" />

The @from path, which your users see in their browser address bar, is silently routed to an existing page path.

Parameters

Parameters are declared by a leading : and can be reused in the @to path.

<route from="/:language/blog/:article/" to="/blog/:article/" />

Filters

To match a parameter against a specific pattern, you can optionally provide a <filter> element for that parameter inside the <route> element.

A <filter> element also has two attributes, @parameter and @match.

<route from="/:language/blog/:article/" to="/blog/:article/">

    <filter parameter=":language" match="[a-z]{2}" />

</route>

The @match attribute can contain a PCRE regex pattern.

By default, all parameters will be matched against the [\w\.-]+ pattern.

About

XML based frontend routing for Symphony.

License:MIT License


Languages

Language:PHP 100.0%