matuck / aliasbundle
Provides a catch all route
1.0.0-beta
2013-10-12 00:46 UTC
Requires
- php: >=5.4
- doctrine/doctrine-bundle: 1.2.*
- doctrine/orm: >=2.2.3,<2.4-dev
- symfony/framework-bundle: ~2.0
This package is not auto-updated.
Last update: 2024-12-30 16:03:34 UTC
README
A system to remap any url to a url of your choosing
Documentation
Installation
Pretty simple with Composer, add:
{ "require": { "matuck/aliasbundle": "dev-master" } }
Then run the below command to install the bundle
php composer.phar update
Database tables also need to created so run
php app/console Doctrine:schema:update --force
Configure
Add the below snippet to the very bottom of your routing.yml file
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.
Usage
From inside a controller
$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(); }