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
2434ad91
Commit
2434ad91
authored
Nov 10, 2011
by
Hugo Hamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[doc] proofread documentation and fixed some typos.
parent
20eeadbc
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
28 additions
and
27 deletions
+28
-27
doc/internals.rst
doc/internals.rst
+2
-1
doc/intro.rst
doc/intro.rst
+1
-1
doc/providers.rst
doc/providers.rst
+3
-3
doc/providers/translation.rst
doc/providers/translation.rst
+11
-11
doc/services.rst
doc/services.rst
+2
-2
doc/testing.rst
doc/testing.rst
+3
-3
doc/usage.rst
doc/usage.rst
+6
-6
No files found.
doc/internals.rst
View file @
2434ad91
...
@@ -25,7 +25,8 @@ them.
...
@@ -25,7 +25,8 @@ them.
The application makes strong use of the `EventDispatcher
The application makes strong use of the `EventDispatcher
<http://api.symfony.com/2.0/Symfony/Component/EventDispatcher/EventDispatcher.html>`_
<http://api.symfony.com/2.0/Symfony/Component/EventDispatcher/EventDispatcher.html>`_
to hook into the Symfony2 HttpKernel events. This allows
to hook into the Symfony2 `HttpKernel
<http://api.symfony.com/2.0/Symfony/Component/HttpKernel/HttpKernel.html>`_ events. This allows
fetching the ``Request``, converting string responses into
fetching the ``Request``, converting string responses into
``Response`` objects and handling Exceptions. We also use it
``Response`` objects and handling Exceptions. We also use it
to dispatch some custom events like before/after filters and
to dispatch some custom events like before/after filters and
...
...
doc/intro.rst
View file @
2434ad91
...
@@ -7,7 +7,7 @@ of Symfony2 and Pimple and also inspired by sinatra.
...
@@ -7,7 +7,7 @@ of Symfony2 and Pimple and also inspired by sinatra.
A microframework provides the guts for building simple single-file apps.
A microframework provides the guts for building simple single-file apps.
Silex aims to be:
Silex aims to be:
* *Concise*: Silex exposes a intuitive and concise API that is fun to use.
* *Concise*: Silex exposes a
n
intuitive and concise API that is fun to use.
* *Extensible*: Silex has an extension system based around the Pimple
* *Extensible*: Silex has an extension system based around the Pimple
micro service-container that makes it even easier to tie in third party
micro service-container that makes it even easier to tie in third party
...
...
doc/providers.rst
View file @
2434ad91
...
@@ -108,7 +108,7 @@ Here is an example of such a provider::
...
@@ -108,7 +108,7 @@ Here is an example of such a provider::
}
}
This class provides a ``hello`` service which is a protected
This class provides a ``hello`` service which is a protected
closure. It takes a
name
argument and will return
closure. It takes a
``name``
argument and will return
``hello.default_name`` if no name is given. If the default
``hello.default_name`` if no name is given. If the default
is also missing, it will use an empty string.
is also missing, it will use an empty string.
...
@@ -241,6 +241,6 @@ the provider.
...
@@ -241,6 +241,6 @@ the provider.
.. tip::
.. tip::
You can also define a
n
provider that implements both the service and the
You can also define a provider that implements both the service and the
controller provider interface and package in the same class the services
controller provider interface and package in the same class the services
needed to make your controllers work.
needed to make your controllers work.
doc/providers/translation.rst
View file @
2434ad91
TranslationServiceProvider
TranslationServiceProvider
==========================
==========================
The *TranslationServiceProvider* provides a service for translating your
application
The *TranslationServiceProvider* provides a service for translating your
into different languages.
application
into different languages.
Parameters
Parameters
----------
----------
* **translator.messages**: A mapping of locales to message arrays. This
parameter
* **translator.messages**: A mapping of locales to message arrays. This
contains the translation data in all languages.
parameter
contains the translation data in all languages.
* **locale** (optional): The locale for the translator. You will most likely
want
* **locale** (optional): The locale for the translator. You will most likely
to set this based on some request parameter. Defaults to ``en``.
want
to set this based on some request parameter. Defaults to ``en``.
* **locale_fallback** (optional): Fallback locale for the translator. It will
* **locale_fallback** (optional): Fallback locale for the translator. It will
be used when the current locale has no messages set.
be used when the current locale has no messages set.
...
@@ -92,7 +92,7 @@ Recipes
...
@@ -92,7 +92,7 @@ Recipes
YAML-based language files
YAML-based language files
~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~
Having your translation in PHP files can be inconvenient. This recipe will
Having your translation
s
in PHP files can be inconvenient. This recipe will
show you how to load translations from external YAML files.
show you how to load translations from external YAML files.
First you will need the ``Config`` and ``Yaml`` components from Symfony2. Also
First you will need the ``Config`` and ``Yaml`` components from Symfony2. Also
...
@@ -109,8 +109,8 @@ use is ``locales/en.yml``. Just do the mapping in this file as follows:
...
@@ -109,8 +109,8 @@ use is ``locales/en.yml``. Just do the mapping in this file as follows:
hello: Hello %name%
hello: Hello %name%
goodbye: Goodbye %name%
goodbye: Goodbye %name%
Repeat this for all of your languages. Then set up the ``translator.messages``
to map
Repeat this for all of your languages. Then set up the ``translator.messages``
languages to files::
to map
languages to files::
$app['translator.messages'] = array(
$app['translator.messages'] = array(
'en' => __DIR__.'/locales/en.yml',
'en' => __DIR__.'/locales/en.yml',
...
@@ -118,8 +118,8 @@ languages to files::
...
@@ -118,8 +118,8 @@ languages to files::
'fr' => __DIR__.'/locales/fr.yml',
'fr' => __DIR__.'/locales/fr.yml',
);
);
Finally override the ``translator.loader`` to use a ``YamlFileLoader`` instead
of the
Finally override the ``translator.loader`` to use a ``YamlFileLoader`` instead
default ``ArrayLoader``::
of the
default ``ArrayLoader``::
$app['translator.loader'] = new Symfony\Component\Translation\Loader\YamlFileLoader();
$app['translator.loader'] = new Symfony\Component\Translation\Loader\YamlFileLoader();
...
...
doc/services.rst
View file @
2434ad91
...
@@ -47,7 +47,7 @@ in fact other services.
...
@@ -47,7 +47,7 @@ in fact other services.
Container
Container
~~~~~~~~~
~~~~~~~~~
A DI or service container is responsible for creating and storing
A DI
C
or service container is responsible for creating and storing
services. It can recursively create dependencies of the requested
services. It can recursively create dependencies of the requested
services and inject them. It does so lazily, which means a service
services and inject them. It does so lazily, which means a service
is only created when you actually need it.
is only created when you actually need it.
...
@@ -61,7 +61,7 @@ Pimple
...
@@ -61,7 +61,7 @@ Pimple
------
------
Pimple is probably the simplest service container out there. It
Pimple is probably the simplest service container out there. It
makes strong use of closures implements the ArrayAccess interface.
makes strong use of closures
and
implements the ArrayAccess interface.
We will start off by creating a new instance of Pimple -- and
We will start off by creating a new instance of Pimple -- and
because ``Silex\Application`` extends ``Pimple`` all of this
because ``Silex\Application`` extends ``Pimple`` all of this
...
...
doc/testing.rst
View file @
2434ad91
...
@@ -109,15 +109,15 @@ executed before every test.
...
@@ -109,15 +109,15 @@ executed before every test.
// ...
// ...
use Symfony\Component\HttpFoundation\SessionStorage\FilesystemSessionStorage;
use Symfony\Component\HttpFoundation\SessionStorage\FilesystemSessionStorage;
//
...
//
...
public function createApplication()
public function createApplication()
{
{
//
...
//
...
$this->app['session.storage'] = $this->app->share(function() {
$this->app['session.storage'] = $this->app->share(function() {
return new FilesystemSessionStorage(sys_get_temp_dir());
return new FilesystemSessionStorage(sys_get_temp_dir());
});
});
//
...
//
...
}
}
The WebTestCase provides a ``createClient`` method. A client acts as a browser,
The WebTestCase provides a ``createClient`` method. A client acts as a browser,
...
...
doc/usage.rst
View file @
2434ad91
...
@@ -164,7 +164,7 @@ It is pretty straightforward.
...
@@ -164,7 +164,7 @@ It is pretty straightforward.
The current ``request`` is automatically injected by Silex to the Closure
The current ``request`` is automatically injected by Silex to the Closure
thanks to the type hinting. It is an instance of `Request
thanks to the type hinting. It is an instance of `Request
<http://api.symfony.com/2.0/Symfony/Component/HttpFoundation/Request.html>`_,
<http://api.symfony.com/2.0/Symfony/Component/HttpFoundation/Request.html>`_,
so you can fetch variables using the request
's
``get`` method.
so you can fetch variables using the request ``get`` method.
Instead of returning a string we are returning an instance of
Instead of returning a string we are returning an instance of
`Response
`Response
...
@@ -211,7 +211,7 @@ You can match multiple methods with one controller using regex syntax::
...
@@ -211,7 +211,7 @@ You can match multiple methods with one controller using regex syntax::
Route variables
Route variables
~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~
As
has been show
before you can define variable parts in a route like this::
As
it has been shown
before you can define variable parts in a route like this::
$app->get('/blog/show/{id}', function ($id) {
$app->get('/blog/show/{id}', function ($id) {
...
...
...
@@ -230,7 +230,7 @@ While it's not suggested, you could also do this (note the switched arguments)::
...
@@ -230,7 +230,7 @@ While it's not suggested, you could also do this (note the switched arguments)::
...
...
});
});
You can also ask for the current Request and Application object::
You can also ask for the current Request and Application object
s
::
$app->get('/blog/show/{id}', function (Application $app, Request $request, $id) {
$app->get('/blog/show/{id}', function (Application $app, Request $request, $id) {
...
...
...
@@ -345,7 +345,7 @@ Before and after filters
...
@@ -345,7 +345,7 @@ Before and after filters
------------------------
------------------------
Silex allows you to run code before and after every request. This happens
Silex allows you to run code before and after every request. This happens
through
before and after
filters. All you need to do is pass a closure::
through
``before`` and ``after``
filters. All you need to do is pass a closure::
$app->before(function () {
$app->before(function () {
// set up
// set up
...
@@ -355,8 +355,8 @@ through before and after filters. All you need to do is pass a closure::
...
@@ -355,8 +355,8 @@ through before and after filters. All you need to do is pass a closure::
// tear down
// tear down
});
});
The before filter has access to the current Request, and can short-circuit
the
The before filter has access to the current Request, and can short-circuit
whole rendering by returning a Response::
the
whole rendering by returning a Response::
$app->before(function (Request $request) {
$app->before(function (Request $request) {
// redirect the user to the login screen if access to the Resource is protected
// redirect the user to the login screen if access to the Resource is protected
...
...
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