Commit de9c57a9 authored by Fabien Potencier's avatar Fabien Potencier

minor #1461 Update the documentation (SpacePossum)

This PR was merged into the 2.1.x-dev branch.

Discussion
----------

Update the documentation

Hi all!

I've made a few minor changes to the docs ~to get those back into shape.
However I could use help finishing the `routing.rst`, this describes the `RoutingServiceProvider`.
The provider is powerful and awesome, but I struggle getting any good copy in there.
So if you have time please help out :)~

Commits
-------

75dcc3b9 Update documentation.
parents 002a6a6e 75dcc3b9
...@@ -6,7 +6,7 @@ often desirable and allows you to configure them independently, allowing for fin ...@@ -6,7 +6,7 @@ often desirable and allows you to configure them independently, allowing for fin
grained control of where your logging goes and in what detail. grained control of where your logging goes and in what detail.
This simple example allows you to quickly configure several monolog instances, This simple example allows you to quickly configure several monolog instances,
using the bundled handler, but each with a different channel. using the bundled handler, but each with a different channel.
.. code-block:: php .. code-block:: php
......
...@@ -45,8 +45,7 @@ With a dedicated PDO service ...@@ -45,8 +45,7 @@ With a dedicated PDO service
$app['session.storage.handler'] = function () use ($app) { $app['session.storage.handler'] = function () use ($app) {
return new PdoSessionHandler( return new PdoSessionHandler(
$app['pdo'], $app['pdo'],
$app['session.db_options'], $app['session.db_options']
$app['session.storage.options']
); );
}; };
...@@ -62,19 +61,16 @@ have to make another database connection, simply pass the getWrappedConnection m ...@@ -62,19 +61,16 @@ have to make another database connection, simply pass the getWrappedConnection m
$app->register(new Silex\Provider\SessionServiceProvider()); $app->register(new Silex\Provider\SessionServiceProvider());
$app['session.db_options'] = array(
'db_table' => 'session',
'db_id_col' => 'session_id',
'db_data_col' => 'session_value',
'db_lifetime_col' => 'session_lifetime',
'db_time_col' => 'session_time',
);
$app['session.storage.handler'] = function () use ($app) { $app['session.storage.handler'] = function () use ($app) {
return new PdoSessionHandler( return new PdoSessionHandler(
$app['db']->getWrappedConnection(), $app['db']->getWrappedConnection(),
$app['session.db_options'], array(
$app['session.storage.options'] 'db_table' => 'session',
'db_id_col' => 'session_id',
'db_data_col' => 'session_value',
'db_lifetime_col' => 'session_lifetime',
'db_time_col' => 'session_time',
)
); );
}; };
......
...@@ -51,9 +51,13 @@ Included providers ...@@ -51,9 +51,13 @@ Included providers
There are a few providers that you get out of the box. All of these are within There are a few providers that you get out of the box. All of these are within
the ``Silex\Provider`` namespace: the ``Silex\Provider`` namespace:
* :doc:`AssetServiceProvider <providers/asset>`
* :doc:`CsrfServiceProvider <providers/csrf>`
* :doc:`DoctrineServiceProvider <providers/doctrine>` * :doc:`DoctrineServiceProvider <providers/doctrine>`
* :doc:`FormServiceProvider <providers/form>` * :doc:`FormServiceProvider <providers/form>`
* :doc:`HttpCacheServiceProvider <providers/http_cache>` * :doc:`HttpCacheServiceProvider <providers/http_cache>`
* :doc:`HttpFragmentServiceProvider <providers/http_fragment>`
* :doc:`LocaleServiceProvider <providers/locale>`
* :doc:`MonologServiceProvider <providers/monolog>` * :doc:`MonologServiceProvider <providers/monolog>`
* :doc:`RememberMeServiceProvider <providers/remember_me>` * :doc:`RememberMeServiceProvider <providers/remember_me>`
* :doc:`SecurityServiceProvider <providers/security>` * :doc:`SecurityServiceProvider <providers/security>`
...@@ -64,6 +68,7 @@ the ``Silex\Provider`` namespace: ...@@ -64,6 +68,7 @@ the ``Silex\Provider`` namespace:
* :doc:`TranslationServiceProvider <providers/translation>` * :doc:`TranslationServiceProvider <providers/translation>`
* :doc:`TwigServiceProvider <providers/twig>` * :doc:`TwigServiceProvider <providers/twig>`
* :doc:`ValidatorServiceProvider <providers/validator>` * :doc:`ValidatorServiceProvider <providers/validator>`
* :doc:`VarDumperServiceProvider <providers/var_dumper>`
.. note:: .. note::
...@@ -93,7 +98,7 @@ Providers must implement the ``Pimple\ServiceProviderInterface``:: ...@@ -93,7 +98,7 @@ Providers must implement the ``Pimple\ServiceProviderInterface``::
This is very straight forward, just create a new class that implements the This is very straight forward, just create a new class that implements the
register method. In the ``register()`` method, you can define services on the register method. In the ``register()`` method, you can define services on the
application which then may make use of other services and parameters. application which then may make use of other services and parameters.
.. tip:: .. tip::
...@@ -149,13 +154,13 @@ Here is an example of such a provider:: ...@@ -149,13 +154,13 @@ Here is an example of such a provider::
public function boot(Application $app) public function boot(Application $app)
{ {
// do something // do something
} }
public function subscribe(Container $app, EventDispatcherInterface $dispatcher) public function subscribe(Container $app, EventDispatcherInterface $dispatcher)
{ {
$dispatcher->addListener(KernelEvents::REQUEST, function(FilterResponseEvent $event) use ($app) { $dispatcher->addListener(KernelEvents::REQUEST, function(FilterResponseEvent $event) use ($app) {
// do something // do something
}); });
} }
} }
......
...@@ -47,12 +47,12 @@ Registering ...@@ -47,12 +47,12 @@ Registering
composer require symfony/form composer require symfony/form
If you are going to use the validation extension with forms, you must also If you are going to use the validation extension with forms, you must also
add a dependency to the ``symfony/config`` and ``symfony/translation`` add a dependency to the ``symfony/validator`` and ``symfony/config``
components: components:
.. code-block:: bash .. code-block:: bash
composer require symfony/validator symfony/config symfony/translation composer require symfony/validator symfony/config
If you want to use forms in your Twig templates, you can also install the If you want to use forms in your Twig templates, you can also install the
Symfony Twig Bridge. Make sure to install, if you didn't do that already, Symfony Twig Bridge. Make sure to install, if you didn't do that already,
...@@ -60,7 +60,7 @@ Registering ...@@ -60,7 +60,7 @@ Registering
.. code-block:: bash .. code-block:: bash
composer require symfony/twig-bridge symfony/config symfony/translation composer require symfony/twig-bridge
Usage Usage
----- -----
...@@ -68,8 +68,9 @@ Usage ...@@ -68,8 +68,9 @@ Usage
The FormServiceProvider provides a ``form.factory`` service. Here is a usage The FormServiceProvider provides a ``form.factory`` service. Here is a usage
example:: example::
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
$app->match('/form', function (Request $request) use ($app) { $app->match('/form', function (Request $request) use ($app) {
// some default data for when the form is displayed the first time // some default data for when the form is displayed the first time
...@@ -82,9 +83,12 @@ example:: ...@@ -82,9 +83,12 @@ example::
->add('name') ->add('name')
->add('email') ->add('email')
->add('billing_plan', ChoiceType::class, array( ->add('billing_plan', ChoiceType::class, array(
'choices' => array(1 => 'free', 2 => 'small_business', 3 => 'corporate'), 'choices' => array('free' => 1, 'small business' => 2, 'corporate' => 3),
'expanded' => true, 'expanded' => true,
)) ))
->add('submit', SubmitType::class, [
'label' => 'Save',
])
->getForm(); ->getForm();
$form->handleRequest($request); $form->handleRequest($request);
...@@ -115,9 +119,10 @@ And here is the ``index.twig`` form template (requires ``symfony/twig-bridge``): ...@@ -115,9 +119,10 @@ And here is the ``index.twig`` form template (requires ``symfony/twig-bridge``):
If you are using the validator provider, you can also add validation to your If you are using the validator provider, you can also add validation to your
form by adding constraints on the fields:: form by adding constraints on the fields::
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\FormType; use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
$app->register(new Silex\Provider\ValidatorServiceProvider()); $app->register(new Silex\Provider\ValidatorServiceProvider());
...@@ -133,10 +138,13 @@ form by adding constraints on the fields:: ...@@ -133,10 +138,13 @@ form by adding constraints on the fields::
'constraints' => new Assert\Email() 'constraints' => new Assert\Email()
)) ))
->add('billing_plan', ChoiceType::class, array( ->add('billing_plan', ChoiceType::class, array(
'choices' => array(1 => 'free', 2 => 'small_business', 3 => 'corporate'), 'choices' => array('free' => 1, 'small business' => 2, 'corporate' => 3),
'expanded' => true, 'expanded' => true,
'constraints' => new Assert\Choice(array(1, 2, 3)), 'constraints' => new Assert\Choice(array(1, 2, 3)),
)) ))
->add('submit', SubmitType::class, [
'label' => 'Save',
])
->getForm(); ->getForm();
You can register form types by extending ``form.types``:: You can register form types by extending ``form.types``::
...@@ -194,11 +202,15 @@ Traits ...@@ -194,11 +202,15 @@ Traits
``Silex\Application\FormTrait`` adds the following shortcuts: ``Silex\Application\FormTrait`` adds the following shortcuts:
* **form**: Creates a FormBuilder instance. * **form**: Creates a FormBuilderInterface instance.
* **namedForm**: Creates a FormBuilderInterface instance (named).
.. code-block:: php .. code-block:: php
$app->form($data); $app->form($data);
$app->namedForm($name, $data, $options, $type);
For more information, consult the `Symfony Forms documentation For more information, consult the `Symfony Forms documentation
<http://symfony.com/doc/2.8/book/forms.html>`_. <http://symfony.com/doc/2.8/book/forms.html>`_.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment