2017 © Pedro Peláez
 

library aliasbundle

Provides a catch all route

image

matuck/aliasbundle

Provides a catch all route

  • Saturday, October 12, 2013
  • by matuck
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

AliasBundle

A system to remap any url to a url of your choosing, (*1)

Documentation

Installation

Pretty simple with Composer, add:, (*2)

{
    "require": {
        "matuck/aliasbundle": "dev-master"
    }
}

Then run the below command to install the bundle, (*3)

php composer.phar update

Database tables also need to created so run, (*4)

php app/console Doctrine:schema:update --force

Configure

Add the below snippet to the very bottom of your routing.yml file, (*5)

matuck_alias:
    resource: "@matuckAliasBundle/Resources/config/routing.yml"
    prefix:   /

This has to be the very last entry or your hard defined routes will not work., (*6)

Usage

From inside a controller, (*7)

$service = $this->get('matuck_alias');

//To create a new alias of /myalias which goes to path www.example.com/page/somepage
$service->createAlias('/myalias', '/page/somepage');

//Delete an alias of /myalias
$service->deleteAlias('/myalias');

//Get the true path for an alias in this case returns /page/somepage
$service->getTruepath('myalias');

//Gets an array of aliases for a truepath
$aliases = $service->getAliasesForTruePath('/page/somepage');
foreach($aliases as $alias)
{
    echo $alias->getAlias();
}

The Versions

12/10 2013
12/10 2013