foreverglory/routing-bundle

Symfony RoutingBundle

v1.0.0 2016-08-07 12:00 UTC

This package is not auto-updated.

Last update: 2024-11-04 07:47:36 UTC


README

Use alias path to access the original Controller

使用别名路径访问原始Controller

###Usage

composer require foreverglory/routing-bundle

###AppKernel

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles[] = new Glory\Bundle\RoutingBundle\GloryRoutingBundle();
    }
}

###Configure routing config routing.yml

homepage:
    path: /homepage
    defaults: { _controller: AppBundle:Default:index }
newpage:
    path: /new
    defaults: { _alias: homepage }

###Code

//generate alias url
$url = $container->get('router')->generate('homepage');
//$url: /new
{{path("homepage")}}