Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
ef658842
Commit
ef658842
authored
Jun 19, 2012
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated docs
parent
29af1026
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
doc/usage.rst
doc/usage.rst
+9
-8
No files found.
doc/usage.rst
View file @
ef658842
...
...
@@ -627,17 +627,15 @@ Modularity
When your application starts to define too many controllers, you might want to
group them logically::
use Silex\ControllerCollection;
// define controllers for a blog
$blog =
new ControllerCollection()
;
$blog =
$app['controllers_factory']
;
$blog->get('/', function () {
return 'Blog home page';
});
// ...
// define controllers for a forum
$forum =
new ControllerCollection()
;
$forum =
$app['controllers_factory']
;
$forum->get('/', function () {
return 'Forum home page';
});
...
...
@@ -650,6 +648,11 @@ group them logically::
$app->mount('/blog', $blog);
$app->mount('/forum', $forum);
.. note::
``$app['controllers_factory']`` is a factory that returns a new instance
of ``ControllerCollection`` when used.
``mount()`` prefixes all routes with the given prefix and merges them into the
main Application. So, ``/`` will map to the main home page, ``/blog/`` to the
blog home page, and ``/forum/`` to the forum home page.
...
...
@@ -664,7 +667,7 @@ Another benefit is the ability to apply settings on a set of controllers very
easily. Building on the example from the middleware section, here is how you
would secure all controllers for the backend collection::
$backend =
new ControllerCollection()
;
$backend =
$app['controllers_factory']
;
// ensure that all controllers require logged-in users
$backend->before($mustBeLogged);
...
...
@@ -675,9 +678,7 @@ would secure all controllers for the backend collection::
separate file::
// blog.php
use Silex\ControllerCollection;
$blog = new ControllerCollection();
$blog = $app['controllers_factory'];
$blog->get('/', function () { return 'Blog home page'; });
return $blog;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment