Add routing examples

This commit is contained in:
Dmitriy Simushev 2014-05-12 14:16:05 +04:00
parent 6be97b32a8
commit e454b69740
2 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,24 @@
<?php
namespace Mibew\Mibew\Plugin\Boilerplate\Controller;
use Mibew\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* Serve license info page
*/
class HelloWorldController extends AbstractController
{
/**
* Generate content for "mibew_boilerplate_hello" route.
*
* @param Request $request
* @return Response
*/
public function indexAction(Request $request)
{
return new Response('Hello ' . $request->attributes->get('name') . '!');
}
}

View File

@ -0,0 +1,11 @@
# Here we can easily define custom routes. Let's create a "Hello world!" page.
mibew_boilerplate_hello:
# Relative path from the Mibew web root is used here.
path: /mibew-boilerplate-hello/{name}
# Set some defaults for the request
defaults:
# This value is special. It tells the system what action should be
# invoked for the response
_controller: Mibew\Mibew\Plugin\Boilerplate\Controller\HelloWorldController::indexAction
# Set a default value for the "{name}" placeholder
name: world