https://github.com/sensorario/sensorario-url-route
Create SEO URL with annotations
https://github.com/sensorario/sensorario-url-route
Last synced: 11 months ago
JSON representation
Create SEO URL with annotations
- Host: GitHub
- URL: https://github.com/sensorario/sensorario-url-route
- Owner: sensorario
- Created: 2012-12-29T14:07:56.000Z (over 13 years ago)
- Default Branch: master-5.4
- Last Pushed: 2013-04-25T14:47:22.000Z (about 13 years ago)
- Last Synced: 2025-03-13T02:31:48.214Z (over 1 year ago)
- Language: PHP
- Homepage: http://www.yiiframework.com/extension/sensorario-url-route/
- Size: 160 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
Install
-------
I suggest to install this module using composer.
{
...
"require": {
...
"sensorario/sensorariourlroute": "@dev"
}
...
}
Load SensorarioUrlRoute module in config/main.php configuration file:
'sensorariourlroute' => array(
'class' => 'webroot.vendor.sensorario.sensorariourlroute.SensorarioUrlRouteModule',
),
Enable URLs in path format:
'components' => array(
'urlManager' => array(
'urlFormat' => 'path',
'rules' => require 'routing.php',
),
),
Usage
-----
Add annotations in DocComments of actions:
class SiteController extends Controller
/**
* @Route(name="homepage");
*/
public function actionIndex()
{
$this->render('index');
}
}
Go to index.php/SensorarioUrlRoute and click on "Generate routing file". A file
will be generated with this contents:
'site/index',
);
Now, to get rout of 'homepage' route, you could use this code:
((new CreateUrl('homepage'))->getRoute()))
Usage with parameters
---------------------
Instead of /site/hello/username/sensorario you can type url /hello/sensorario.
/**
* @Route(value="hello/");
*/
public function actionHello($username)
{
echo "Hello $username";
die;
}