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
a7894570
Commit
a7894570
authored
Sep 21, 2011
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated documentation
parent
5a20c1cc
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
142 additions
and
141 deletions
+142
-141
doc/contributing.rst
doc/contributing.rst
+1
-1
doc/index.rst
doc/index.rst
+1
-1
doc/internals.rst
doc/internals.rst
+1
-1
doc/providers.rst
doc/providers.rst
+72
-71
doc/providers/doctrine.rst
doc/providers/doctrine.rst
+7
-7
doc/providers/http_cache.rst
doc/providers/http_cache.rst
+6
-6
doc/providers/index.rst
doc/providers/index.rst
+0
-0
doc/providers/monolog.rst
doc/providers/monolog.rst
+5
-5
doc/providers/session.rst
doc/providers/session.rst
+5
-5
doc/providers/swiftmailer.rst
doc/providers/swiftmailer.rst
+5
-5
doc/providers/symfony_bridges.rst
doc/providers/symfony_bridges.rst
+8
-8
doc/providers/translation.rst
doc/providers/translation.rst
+5
-5
doc/providers/twig.rst
doc/providers/twig.rst
+5
-5
doc/providers/url_generator.rst
doc/providers/url_generator.rst
+5
-5
doc/providers/validator.rst
doc/providers/validator.rst
+7
-7
doc/services.rst
doc/services.rst
+2
-2
doc/usage.rst
doc/usage.rst
+7
-7
No files found.
doc/contributing.rst
View file @
a7894570
...
@@ -2,7 +2,7 @@ Contributing
...
@@ -2,7 +2,7 @@ Contributing
============
============
We are open to contributions to the Silex code. If you find
We are open to contributions to the Silex code. If you find
a bug or want to contribute a
n extension
, just follow these
a bug or want to contribute a
provider
, just follow these
steps.
steps.
* Fork `the Silex repository <https://github.com/fabpot/Silex>`_
* Fork `the Silex repository <https://github.com/fabpot/Silex>`_
...
...
doc/index.rst
View file @
a7894570
...
@@ -7,7 +7,7 @@ Silex
...
@@ -7,7 +7,7 @@ Silex
intro
intro
usage
usage
services
services
extension
s
provider
s
testing
testing
internals
internals
contributing
contributing
...
...
doc/internals.rst
View file @
a7894570
...
@@ -49,7 +49,7 @@ ControllerCollection
...
@@ -49,7 +49,7 @@ ControllerCollection
One of the goals of exposing the `RouteCollection
One of the goals of exposing the `RouteCollection
<http://api.symfony.com/2.0/Symfony/Component/Routing/RouteCollection.html>`_
<http://api.symfony.com/2.0/Symfony/Component/Routing/RouteCollection.html>`_
was to make it mutable, so
extension
s could add stuff to it.
was to make it mutable, so
provider
s could add stuff to it.
The challenge here is the fact that routes know nothing
The challenge here is the fact that routes know nothing
about their name. The name only has meaning in context
about their name. The name only has meaning in context
of the ``RouteCollection`` and cannot be changed.
of the ``RouteCollection`` and cannot be changed.
...
...
doc/
extension
s.rst
→
doc/
provider
s.rst
View file @
a7894570
Extension
s
Provider
s
=========
=
=========
Extensions allow the developer to reuse parts of an application into another
Providers allow the developer to reuse parts of an application into another
one. Silex provides two interfaces for extensions: `ExtensionInterface` for
one. Silex provides two types of providers defined by two interfaces:
services and `ControllersExtensionInterface` for controllers.
`ServiceProviderInterface` for services and `ControllerProviderInterface` for
controllers.
Service
Extension
s
Service
Provider
s
-----------------
-
-----------------
Loading
extension
s
Loading
provider
s
~~~~~~~~~~~~~~~~~
~
~~~~~~~~~~~~~~~~~
In order to load and use a service
extension
, you must register it on the
In order to load and use a service
provider
, you must register it on the
application::
application::
$app = new Silex\Application();
$app = new Silex\Application();
$app->register(new Acme\Database
Extension
());
$app->register(new Acme\Database
Provider
());
You can also provide some parameters as a second argument. These
You can also provide some parameters as a second argument. These
will be set **before** the
extension
is registered::
will be set **before** the
provider
is registered::
$app->register(new Acme\Database
Extension
(), array(
$app->register(new Acme\Database
Provider
(), array(
'database.dsn' => 'mysql:host=localhost;dbname=myapp',
'database.dsn' => 'mysql:host=localhost;dbname=myapp',
'database.user' => 'root',
'database.user' => 'root',
'database.password' => 'secret_root_password',
'database.password' => 'secret_root_password',
...
@@ -31,52 +32,52 @@ Conventions
...
@@ -31,52 +32,52 @@ Conventions
~~~~~~~~~~~
~~~~~~~~~~~
You need to watch out in what order you do certain things when
You need to watch out in what order you do certain things when
interacting with
extension
s. Just keep to these rules:
interacting with
provider
s. Just keep to these rules:
* Class paths (for the autoloader) must be defined **before**
* Class paths (for the autoloader) must be defined **before**
the
extension
is registered. Passing it as a second argument
the
provider
is registered. Passing it as a second argument
to ``Application::register`` qualifies too, because it sets
to ``Application::register`` qualifies too, because it sets
the passed parameters first.
the passed parameters first.
*Reason: The
extension
will set up the autoloader at
*Reason: The
provider
will set up the autoloader at
extension
register time. If the class path is not set
provider
register time. If the class path is not set
at that point, no autoloader can be registered.*
at that point, no autoloader can be registered.*
* Overriding existing services must occur **after** the
* Overriding existing services must occur **after** the
extension
is registered.
provider
is registered.
*Reason: If the services already exist, the
extension
*Reason: If the services already exist, the
provider
will overwrite it.*
will overwrite it.*
* You can set parameters any time before the service is
* You can set parameters any time before the service is
accessed.
accessed.
Make sure to stick to this behavior when creating your
Make sure to stick to this behavior when creating your
own extensions.
own providers.
Included extensions
~~~~~~~~~~~~~~~~~~~
There are a few extensions that you get out of the box.
All of these are within the ``Silex\Extension`` namespace.
* :doc:`DoctrineExtension <extensions/doctrine>`
Included providers
* :doc:`MonologExtension <extensions/monolog>`
~~~~~~~~~~~~~~~~~~
* :doc:`SessionExtension <extensions/session>`
* :doc:`SwiftmailerExtension <extensions/swiftmailer>`
* :doc:`SymfonyBridgesExtension <extensions/symfony_bridges>`
* :doc:`TwigExtension <extensions/twig>`
* :doc:`TranslationExtension <extensions/translation>`
* :doc:`UrlGeneratorExtension <extensions/url_generator>`
* :doc:`ValidatorExtension <extensions/validator>`
* :doc:`HttpCacheExtension <extensions/http_cache>`
Creating an extension
There are a few provider that you get out of the box.
~~~~~~~~~~~~~~~~~~~~~
All of these are within the ``Silex\Provider`` namespace.
* :doc:`DoctrineProvider <providers/doctrine>`
* :doc:`MonologProvider <providers/monolog>`
* :doc:`SessionProvider <providers/session>`
* :doc:`SwiftmailerServiceProvider <providers/swiftmailer>`
* :doc:`SymfonyBridgesServiceProvider <providers/symfony_bridges>`
* :doc:`TwigProvider <providers/twig>`
* :doc:`TranslationProvider <providers/translation>`
* :doc:`UrlGeneratorProvider <providers/url_generator>`
* :doc:`ValidatorProvider <providers/validator>`
* :doc:`HttpCacheProvider <providers/http_cache>`
Creating a provider
~~~~~~~~~~~~~~~~~~~
Extensions must implement the ``Silex\Extension
Interface``::
Providers must implement the ``Silex\ServiceProvider
Interface``::
interface
Extension
Interface
interface
ServiceProvider
Interface
{
{
function register(Application $app);
function register(Application $app);
}
}
...
@@ -86,14 +87,14 @@ implements the ``register`` method. In this method you must
...
@@ -86,14 +87,14 @@ implements the ``register`` method. In this method you must
define services on the application which then may make use
define services on the application which then may make use
of other services and parameters.
of other services and parameters.
Here is an example of such a
n extension
::
Here is an example of such a
provider
::
namespace Acme;
namespace Acme;
use Silex\Application;
use Silex\Application;
use Silex\
Extension
Interface;
use Silex\
ServiceProvider
Interface;
class Hello
Extension implements Extension
Interface
class Hello
Provider implements ServiceProvider
Interface
{
{
public function register(Application $app)
public function register(Application $app)
{
{
...
@@ -111,11 +112,11 @@ closure. It takes a name argument and will return
...
@@ -111,11 +112,11 @@ 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.
You can now use this
extension
as follows::
You can now use this
provider
as follows::
$app = new Silex\Application();
$app = new Silex\Application();
$app->register(new Acme\Hello
Extension
(), array(
$app->register(new Acme\Hello
Provider
(), array(
'hello.default_name' => 'Igor',
'hello.default_name' => 'Igor',
));
));
...
@@ -131,9 +132,9 @@ query string, so the request path would have to be ``/hello?name=Fabien``.
...
@@ -131,9 +132,9 @@ query string, so the request path would have to be ``/hello?name=Fabien``.
Class loading
Class loading
~~~~~~~~~~~~~
~~~~~~~~~~~~~
Extension
s are great for tying in external libraries as you
Provider
s are great for tying in external libraries as you
can see by looking at the ``Monolog
Extension
`` and
can see by looking at the ``Monolog
Provider
`` and
``Twig
Extension
``. If the library is decent and follows the
``Twig
Provider
``. If the library is decent and follows the
`PSR-0 Naming Standard <http://groups.google.com/group/php-standards/web/psr-0-final-proposal>`_
`PSR-0 Naming Standard <http://groups.google.com/group/php-standards/web/psr-0-final-proposal>`_
or the PEAR Naming Convention, it is possible to autoload
or the PEAR Naming Convention, it is possible to autoload
classes using the ``UniversalClassLoader``.
classes using the ``UniversalClassLoader``.
...
@@ -146,9 +147,9 @@ Here is an example of how to use it (based on `Buzz <https://github.com/kriswall
...
@@ -146,9 +147,9 @@ Here is an example of how to use it (based on `Buzz <https://github.com/kriswall
namespace Acme;
namespace Acme;
use Silex\Application;
use Silex\Application;
use Silex\
Extension
Interface;
use Silex\
ServiceProvider
Interface;
class Buzz
Extension implements Extension
Interface
class Buzz
Provider implements ServiceProvider
Interface
{
{
public function register(Application $app)
public function register(Application $app)
{
{
...
@@ -161,9 +162,9 @@ Here is an example of how to use it (based on `Buzz <https://github.com/kriswall
...
@@ -161,9 +162,9 @@ Here is an example of how to use it (based on `Buzz <https://github.com/kriswall
}
}
This allows you to simply provide the class path as an
This allows you to simply provide the class path as an
option when registering the
extension
::
option when registering the
provider
::
$app->register(new Buzz
Extension
(), array(
$app->register(new Buzz
Provider
(), array(
'buzz.class_path' => __DIR__.'/vendor/buzz/lib',
'buzz.class_path' => __DIR__.'/vendor/buzz/lib',
));
));
...
@@ -173,40 +174,40 @@ option when registering the extension::
...
@@ -173,40 +174,40 @@ option when registering the extension::
instead of ``registerNamespace``, which will use an underscore as directory
instead of ``registerNamespace``, which will use an underscore as directory
delimiter.
delimiter.
Controllers
Extension
s
Controllers
provider
s
---------------------
-
---------------------
Loading
extension
s
Loading
provider
s
~~~~~~~~~~~~~~~~~
~
~~~~~~~~~~~~~~~~~
In order to load and use a controller
extension
, you must "mount" its
In order to load and use a controller
provider
, you must "mount" its
controllers under a path::
controllers under a path::
$app = new Silex\Application();
$app = new Silex\Application();
$app->mount('/blog', new Acme\Blog
Extension
());
$app->mount('/blog', new Acme\Blog
Provider
());
All controllers defined by the
extension
will now be available under the
All controllers defined by the
provider
will now be available under the
`/blog` path.
`/blog` path.
Creating a
n extension
Creating a
provider
~~~~~~~~~~~~~~~~~~~
~~
~~~~~~~~~~~~~~~~~~~
Extensions must implement the ``Silex\ControllersExtension
Interface``::
Providers must implement the ``Silex\ControllerProvider
Interface``::
interface Controller
sExtension
Interface
interface Controller
Provider
Interface
{
{
function connect(Application $app);
function connect(Application $app);
}
}
Here is an example of such a
n extension
::
Here is an example of such a
provider
::
namespace Acme;
namespace Acme;
use Silex\Application;
use Silex\Application;
use Silex\Controller
sExtension
Interface;
use Silex\Controller
Provider
Interface;
class Hello
Extension implements ControllersExtension
Interface
class Hello
Provider implements ControllerProvider
Interface
{
{
public function connect(Application $app)
public function connect(Application $app)
{
{
...
@@ -228,17 +229,17 @@ defined (like ``get``, ``post``, ``match``, ...).
...
@@ -228,17 +229,17 @@ defined (like ``get``, ``post``, ``match``, ...).
The ``Application`` class acts in fact as a proxy for these methods.
The ``Application`` class acts in fact as a proxy for these methods.
You can now use this
extension
as follows::
You can now use this
provider
as follows::
$app = new Silex\Application();
$app = new Silex\Application();
$app->connect('/blog', new Acme\Hello
Extension
());
$app->connect('/blog', new Acme\Hello
Provider
());
In this example, the ``/blog/`` path now references the controller defined in
In this example, the ``/blog/`` path now references the controller defined in
the
extension
.
the
provider
.
.. tip::
.. tip::
You can also define an
extension
that implements both the service and the
You can also define an
provider
that implements both the service and the
controller
extension
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/
extension
s/doctrine.rst
→
doc/
provider
s/doctrine.rst
View file @
a7894570
Doctrine
Extension
Doctrine
Provider
================
=
================
The *Doctrine
Extension
* provides integration with the `Doctrine DBAL
The *Doctrine
Provider
* provides integration with the `Doctrine DBAL
<http://www.doctrine-project.org/projects/dbal>`_ for easy database acccess.
<http://www.doctrine-project.org/projects/dbal>`_ for easy database acccess.
.. note::
.. note::
...
@@ -58,7 +58,7 @@ Registering
...
@@ -58,7 +58,7 @@ Registering
Make sure you place a copy of *Doctrine DBAL* in ``vendor/doctrine-dbal``
Make sure you place a copy of *Doctrine DBAL* in ``vendor/doctrine-dbal``
and *Doctrine Common* in ``vendor/doctrine-common``::
and *Doctrine Common* in ``vendor/doctrine-common``::
$app->register(new Silex\
Extension\DoctrineExtension
(), array(
$app->register(new Silex\
Provider\DoctrineProvider
(), array(
'db.options' => array(
'db.options' => array(
'driver' => 'pdo_sqlite',
'driver' => 'pdo_sqlite',
'path' => __DIR__.'/app.db',
'path' => __DIR__.'/app.db',
...
@@ -70,7 +70,7 @@ and *Doctrine Common* in ``vendor/doctrine-common``::
...
@@ -70,7 +70,7 @@ and *Doctrine Common* in ``vendor/doctrine-common``::
Usage
Usage
-----
-----
The Doctrine
extension
provides a ``db`` service. Here is a usage
The Doctrine
provider
provides a ``db`` service. Here is a usage
example::
example::
$app->get('/blog/show/{id}', function ($id) use ($app) {
$app->get('/blog/show/{id}', function ($id) use ($app) {
...
@@ -84,12 +84,12 @@ example::
...
@@ -84,12 +84,12 @@ example::
Using multiple databases
Using multiple databases
------------------------
------------------------
The Doctrine
extension
can allow access to multiple databases. In order to
The Doctrine
provider
can allow access to multiple databases. In order to
configure the data sources, replace the **db.options** with **dbs.options**.
configure the data sources, replace the **db.options** with **dbs.options**.
**dbs.options** is an array of configurations where keys are connection names
**dbs.options** is an array of configurations where keys are connection names
and values are options::
and values are options::
$app->register(new Silex\
Extension\DoctrineExtension
(), array(
$app->register(new Silex\
Provider\DoctrineProvider
(), array(
'dbs.options' => array (
'dbs.options' => array (
'mysql_read' => array(
'mysql_read' => array(
'driver' => 'pdo_mysql',
'driver' => 'pdo_mysql',
...
...
doc/
extension
s/http_cache.rst
→
doc/
provider
s/http_cache.rst
View file @
a7894570
HttpCache
Extension
HttpCache
Provider
=================
=
=================
The *HttpCache
Extension
* provides support for the Symfony2 Reverse Proxy.
The *HttpCache
Provider
* provides support for the Symfony2 Reverse Proxy.
Parameters
Parameters
----------
----------
...
@@ -23,7 +23,7 @@ Registering
...
@@ -23,7 +23,7 @@ Registering
::
::
$app->register(new Silex\
Extension\HttpCacheExtension
(), array(
$app->register(new Silex\
Provider\HttpCacheProvider
(), array(
'http_cache.cache_dir' => __DIR__.'/cache/',
'http_cache.cache_dir' => __DIR__.'/cache/',
));
));
...
@@ -39,12 +39,12 @@ setting Response HTTP cache headers::
...
@@ -39,12 +39,12 @@ setting Response HTTP cache headers::
));
));
});
});
This
extension
allows you to use the Symfony2 reverse proxy natively with
This
provider
allows you to use the Symfony2 reverse proxy natively with
Silex applications by using the `http_cache` service::
Silex applications by using the `http_cache` service::
$app['http_cache']->run();
$app['http_cache']->run();
The
extension
also provide ESI support::
The
provider
also provide ESI support::
$app->get('/', function() {
$app->get('/', function() {
return new Response(
<
<<
EOF
return new Response(
<
<<
EOF
...
...
doc/
extension
s/index.rst
→
doc/
provider
s/index.rst
View file @
a7894570
File moved
doc/
extension
s/monolog.rst
→
doc/
provider
s/monolog.rst
View file @
a7894570
Monolog
Extension
Monolog
Provider
===============
=
===============
The *Monolog
Extension
* provides a default logging mechanism
The *Monolog
Provider
* provides a default logging mechanism
through Jordi Boggiano's `Monolog <https://github.com/Seldaek/monolog>`_
through Jordi Boggiano's `Monolog <https://github.com/Seldaek/monolog>`_
library.
library.
...
@@ -46,7 +46,7 @@ Registering
...
@@ -46,7 +46,7 @@ Registering
Make sure you place a copy of *Monolog* in the ``vendor/monolog``
Make sure you place a copy of *Monolog* in the ``vendor/monolog``
directory::
directory::
$app->register(new Silex\
Extension\MonologExtension
(), array(
$app->register(new Silex\
Provider\MonologProvider
(), array(
'monolog.logfile' => __DIR__.'/development.log',
'monolog.logfile' => __DIR__.'/development.log',
'monolog.class_path' => __DIR__.'/vendor/monolog/src',
'monolog.class_path' => __DIR__.'/vendor/monolog/src',
));
));
...
@@ -59,7 +59,7 @@ directory::
...
@@ -59,7 +59,7 @@ directory::
Usage
Usage
-----
-----
The Monolog
Extension
provides a ``monolog`` service. You can use
The Monolog
Provider
provides a ``monolog`` service. You can use
it to add log entries for any logging level through ``addDebug()``,
it to add log entries for any logging level through ``addDebug()``,
``addInfo()``, ``addWarning()`` and ``addError()``.
``addInfo()``, ``addWarning()`` and ``addError()``.
...
...
doc/
extension
s/session.rst
→
doc/
provider
s/session.rst
View file @
a7894570
Session
Extension
Session
Provider
===============
=
===============
The *Session
Extension
* provides a service for storing data persistently
The *Session
Provider
* provides a service for storing data persistently
between requests.
between requests.
Parameters
Parameters
...
@@ -40,12 +40,12 @@ Registering
...
@@ -40,12 +40,12 @@ Registering
::
::
$app->register(new Silex\
Extension\SessionExtension
());
$app->register(new Silex\
Provider\SessionProvider
());
Usage
Usage
-----
-----
The Session
extension
provides a ``session`` service. Here is an
The Session
provider
provides a ``session`` service. Here is an
example that authenticates a user and creates a session for him::
example that authenticates a user and creates a session for him::
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Response;
...
...
doc/
extension
s/swiftmailer.rst
→
doc/
provider
s/swiftmailer.rst
View file @
a7894570
Swiftmailer
Extension
Swiftmailer
ServiceProvider
====================
====================
======
The *Swiftmailer
Extension
* provides a service for sending
The *Swiftmailer
ServiceProvider
* provides a service for sending
email through the `Swift Mailer <http://swiftmailer.org>`_
email through the `Swift Mailer <http://swiftmailer.org>`_
library.
library.
...
@@ -60,7 +60,7 @@ directory. Make sure you point the class path to ``/lib/classes``.
...
@@ -60,7 +60,7 @@ directory. Make sure you point the class path to ``/lib/classes``.
::
::
$app->register(new Silex\
Extension\SwiftmailerExtension
(), array(
$app->register(new Silex\
Provider\SwiftmailerServiceProvider
(), array(
'swiftmailer.class_path' => __DIR__.'/vendor/swiftmailer/lib/classes',
'swiftmailer.class_path' => __DIR__.'/vendor/swiftmailer/lib/classes',
));
));
...
@@ -72,7 +72,7 @@ directory. Make sure you point the class path to ``/lib/classes``.
...
@@ -72,7 +72,7 @@ directory. Make sure you point the class path to ``/lib/classes``.
Usage
Usage
-----
-----
The Swiftmailer
extension
provides a ``mailer`` service.
The Swiftmailer
provider
provides a ``mailer`` service.
::
::
...
...
doc/
extension
s/symfony_bridges.rst
→
doc/
provider
s/symfony_bridges.rst
View file @
a7894570
SymfonyBridges
Extension
SymfonyBridges
ServiceProvider
=======================
=======================
======
The *SymfonyBridges
Extension
* provides additional integration between
The *SymfonyBridges
ServiceProvider
* provides additional integration between
Symfony2 components and libraries.
Symfony2 components and libraries.
Parameters
Parameters
...
@@ -13,20 +13,20 @@ Parameters
...
@@ -13,20 +13,20 @@ Parameters
Twig
Twig
----
----
When the ``SymfonyBridges
Extension`` is enabled, the ``TwigExtension
`` will
When the ``SymfonyBridges
ServiceProvider`` is enabled, the ``TwigServiceProvider
`` will
provide you with the following additional capabilities:
provide you with the following additional capabilities:
* **UrlGenerator
Extension**: If you are using the ``UrlGeneratorExtension
``,
* **UrlGenerator
ServiceProvider**: If you are using the ``UrlGeneratorServiceProvider
``,
you will get ``path`` and ``url`` helpers for Twig. You can find more
you will get ``path`` and ``url`` helpers for Twig. You can find more
information in the
information in the
`Symfony2 Routing documentation <http://symfony.com/doc/current/book/routing.html#generating-urls-from-a-template>`_.
`Symfony2 Routing documentation <http://symfony.com/doc/current/book/routing.html#generating-urls-from-a-template>`_.
* **Translation
Extension**: If you are using the ``TranslationExtension
``,
* **Translation
ServiceProvider**: If you are using the ``TranslationServiceProvider
``,
you will get ``trans`` and ``transchoice`` helpers for translation in
you will get ``trans`` and ``transchoice`` helpers for translation in
Twig templates. You can find more information in the
Twig templates. You can find more information in the
`Symfony2 Translation documentation <http://symfony.com/doc/current/book/translation.html#twig-templates>`_.
`Symfony2 Translation documentation <http://symfony.com/doc/current/book/translation.html#twig-templates>`_.
* **Form
Extension**: If you are using the ``FormExtension
``,
* **Form
ServiceProvider**: If you are using the ``FormServiceProvider
``,
you will get a set of helpers for working with forms in templates.
you will get a set of helpers for working with forms in templates.
You can find more information in the
You can find more information in the
`Symfony2 Forms reference <http://symfony.com/doc/current/reference/forms/twig_reference.html>`_.
`Symfony2 Forms reference <http://symfony.com/doc/current/reference/forms/twig_reference.html>`_.
...
@@ -37,6 +37,6 @@ Registering
...
@@ -37,6 +37,6 @@ Registering
Make sure you place a copy of the Symfony2 Bridges in
Make sure you place a copy of the Symfony2 Bridges in
``vendor/symfony/src``. You can simply clone the whole Symfony2 into vendor::
``vendor/symfony/src``. You can simply clone the whole Symfony2 into vendor::
$app->register(new Silex\
Extension\SymfonyBridgesExtension
(), array(
$app->register(new Silex\
Provider\SymfonyBridgesServiceProvider
(), array(
'symfony_bridges.class_path' => __DIR__.'/vendor/symfony/src',
'symfony_bridges.class_path' => __DIR__.'/vendor/symfony/src',
));
));
doc/
extension
s/translation.rst
→
doc/
provider
s/translation.rst
View file @
a7894570
Translation
Extension
Translation
Provider
===================
==
===================
The *Translation
Extension
* provides a service for translating your application
The *Translation
Provider
* provides a service for translating your application
into different languages.
into different languages.
Parameters
Parameters
...
@@ -40,7 +40,7 @@ Registering
...
@@ -40,7 +40,7 @@ Registering
Make sure you place a copy of the Symfony2 Translation component in
Make sure you place a copy of the Symfony2 Translation component in
``vendor/symfony/src``. You can simply clone the whole Symfony2 into vendor::
``vendor/symfony/src``. You can simply clone the whole Symfony2 into vendor::
$app->register(new Silex\
Extension\TranslationExtension
(), array(
$app->register(new Silex\
Provider\TranslationProvider
(), array(
'locale_fallback' => 'en',
'locale_fallback' => 'en',
'translation.class_path' => __DIR__.'/vendor/symfony/src',
'translation.class_path' => __DIR__.'/vendor/symfony/src',
));
));
...
@@ -48,7 +48,7 @@ Make sure you place a copy of the Symfony2 Translation component in
...
@@ -48,7 +48,7 @@ Make sure you place a copy of the Symfony2 Translation component in
Usage
Usage
-----
-----
The Translation
extension
provides a ``translator`` service and makes use of
The Translation
provider
provides a ``translator`` service and makes use of
the ``translator.messages`` parameter::
the ``translator.messages`` parameter::
$app['translator.messages'] = array(
$app['translator.messages'] = array(
...
...
doc/
extension
s/twig.rst
→
doc/
provider
s/twig.rst
View file @
a7894570
Twig
Extension
Twig
Provider
============
=
============
The *Twig
Extension
* provides integration with the `Twig
The *Twig
Provider
* provides integration with the `Twig
<http://twig.sensiolabs.org/>`_ template engine.
<http://twig.sensiolabs.org/>`_ template engine.
Parameters
Parameters
...
@@ -39,7 +39,7 @@ Registering
...
@@ -39,7 +39,7 @@ Registering
Make sure you place a copy of *Twig* in the ``vendor/twig``
Make sure you place a copy of *Twig* in the ``vendor/twig``
directory::
directory::
$app->register(new Silex\
Extension\TwigExtension
(), array(
$app->register(new Silex\
Provider\TwigProvider
(), array(
'twig.path' => __DIR__.'/views',
'twig.path' => __DIR__.'/views',
'twig.class_path' => __DIR__.'/vendor/twig/lib',
'twig.class_path' => __DIR__.'/vendor/twig/lib',
));
));
...
@@ -52,7 +52,7 @@ directory::
...
@@ -52,7 +52,7 @@ directory::
Usage
Usage
-----
-----
The Twig
extension
provides a ``twig`` service::
The Twig
provider
provides a ``twig`` service::
$app->get('/hello/{name}', function ($name) use ($app) {
$app->get('/hello/{name}', function ($name) use ($app) {
return $app['twig']->render('hello.twig', array(
return $app['twig']->render('hello.twig', array(
...
...
doc/
extension
s/url_generator.rst
→
doc/
provider
s/url_generator.rst
View file @
a7894570
UrlGenerator
Extension
UrlGenerator
Provider
====================
=
====================
The *UrlGenerator
Extension
* provides a service for generating
The *UrlGenerator
Provider
* provides a service for generating
URLs for named routes.
URLs for named routes.
Parameters
Parameters
...
@@ -25,12 +25,12 @@ Registering
...
@@ -25,12 +25,12 @@ Registering
::
::
$app->register(new Silex\
Extension\UrlGeneratorExtension
());
$app->register(new Silex\
Provider\UrlGeneratorProvider
());
Usage
Usage
-----
-----
The UrlGenerator
extension
provides a ``url_generator`` service::
The UrlGenerator
provider
provides a ``url_generator`` service::
$app->get('/', function () {
$app->get('/', function () {
return 'welcome to the homepage';
return 'welcome to the homepage';
...
...
doc/
extension
s/validator.rst
→
doc/
provider
s/validator.rst
View file @
a7894570
Validator
Extension
Validator
Provider
=================
====
=================
The *Validator
Extension
* provides a service for validating data. It is
The *Validator
Provider
* provides a service for validating data. It is
most useful when used with the *Form
Extension
*, but can also be used
most useful when used with the *Form
Provider
*, but can also be used
standalone.
standalone.
Parameters
Parameters
...
@@ -35,14 +35,14 @@ Registering
...
@@ -35,14 +35,14 @@ Registering
Make sure you place a copy of the Symfony2 Validator component in
Make sure you place a copy of the Symfony2 Validator component in
``vendor/symfony/src``. You can simply clone the whole Symfony2 into vendor::
``vendor/symfony/src``. You can simply clone the whole Symfony2 into vendor::
$app->register(new Silex\
Extension\ValidatorExtension
(), array(
$app->register(new Silex\
Provider\ValidatorProvider
(), array(
'validator.class_path' => __DIR__.'/vendor/symfony/src',
'validator.class_path' => __DIR__.'/vendor/symfony/src',
));
));
Usage
Usage
-----
-----
The Validator
extension
provides a ``validator`` service.
The Validator
provider
provides a ``validator`` service.
Validating values
Validating values
~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~
...
@@ -93,7 +93,7 @@ getters::
...
@@ -93,7 +93,7 @@ getters::
});
});
You will have to handle the display of these violations yourself. You can
You will have to handle the display of these violations yourself. You can
however use the *Form
Extension* which can make use of the *ValidatorExtension
*.
however use the *Form
Provider* which can make use of the *ValidatorProvider
*.
For more information, consult the `Symfony2 Validation documentation
For more information, consult the `Symfony2 Validation documentation
<http://symfony.com/doc/2.0/book/validation.html>`_.
<http://symfony.com/doc/2.0/book/validation.html>`_.
doc/services.rst
View file @
a7894570
...
@@ -254,7 +254,7 @@ Core parameters
...
@@ -254,7 +254,7 @@ Core parameters
Defaults to 80.
Defaults to 80.
This parameter can be used by the ``UrlGenerator
Extension
``.
This parameter can be used by the ``UrlGenerator
Provider
``.
* **request.https_port** (optional): Allows you to override the default port
* **request.https_port** (optional): Allows you to override the default port
for HTTPS URLs. If the current request is HTTPS, it will always use the
for HTTPS URLs. If the current request is HTTPS, it will always use the
...
@@ -262,7 +262,7 @@ Core parameters
...
@@ -262,7 +262,7 @@ Core parameters
Defaults to 443.
Defaults to 443.
This parameter can be used by the ``UrlGenerator
Extension
``.
This parameter can be used by the ``UrlGenerator
Provider
``.
* **debug** (optional): Returns whether or not the application is running in
* **debug** (optional): Returns whether or not the application is running in
debug mode.
debug mode.
...
...
doc/usage.rst
View file @
a7894570
...
@@ -312,10 +312,10 @@ have the value ``index``.
...
@@ -312,10 +312,10 @@ have the value ``index``.
Named routes
Named routes
~~~~~~~~~~~~
~~~~~~~~~~~~
Certain extensions (such as ``UrlGenerato
r``) can make use of named routes.
Some providers (such as ``UrlGeneratorProvide
r``) can make use of named routes.
Silex generates a default route name for each controller but you can overrid
e
By default Silex will generate a route name for you, that cannot really b
e
it by calling ``bind`` on the ``Controller`` object that is returned by the
used. You can give a route a name by calling ``bind`` on the ``Controller``
routing methods::
object that is returned by the
routing methods::
$app->get('/', function () {
$app->get('/', function () {
...
...
...
@@ -330,7 +330,7 @@ routing methods::
...
@@ -330,7 +330,7 @@ routing methods::
.. note::
.. note::
It only makes sense to name routes if you use
extension
s that make use
It only makes sense to name routes if you use
provider
s that make use
of the ``RouteCollection``.
of the ``RouteCollection``.
Before and after filters
Before and after filters
...
@@ -405,8 +405,8 @@ once a response is returned, the following handlers are ignored.
...
@@ -405,8 +405,8 @@ once a response is returned, the following handlers are ignored.
.. note::
.. note::
Silex ships with a
n extension
for `Monolog <https://github.com/Seldaek/monolog>`_
Silex ships with a
provider
for `Monolog <https://github.com/Seldaek/monolog>`_
which handles logging of errors. Check out the *
Extension
s* chapter
which handles logging of errors. Check out the *
Provider
s* chapter
for details.
for details.
.. tip::
.. tip::
...
...
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