Permalink
Browse files

Merge branch '2.1' into 2.2

  • Loading branch information...
weaverryan committed Apr 4, 2013
2 parents 4140805 + 0d62bfc commit 71de41aed869d8dae2d9934eb5035a2a4cddd042
View
@@ -68,7 +68,7 @@ you:
In this example, you have one configured connection, named ``default``. If
you want to configure more than one connection, read the `PropelBundle
- configuration section <Working With Symfony2 - Configuration>`_.
+ configuration section`_.
Creating a Model Class
~~~~~~~~~~~~~~~~~~~~~~
@@ -434,7 +434,7 @@ Commands
You should read the dedicated section for `Propel commands in Symfony2`_.
.. _`Working With Symfony2`: http://propelorm.org/cookbook/symfony2/working-with-symfony2.html#installation
-.. _`Working With Symfony2 - Configuration`: http://propelorm.org/cookbook/symfony2/working-with-symfony2.html#configuration
+.. _`PropelBundle configuration section`: http://propelorm.org/cookbook/symfony2/working-with-symfony2.html#configuration
.. _`Relationships`: http://propelorm.org/documentation/04-relationships.html
.. _`Behaviors reference section`: http://propelorm.org/documentation/#behaviors_reference
.. _`Propel commands in Symfony2`: http://propelorm.org/cookbook/symfony2/working-with-symfony2#the_commands
View
@@ -345,6 +345,16 @@ or perform more complex requests::
// Directly submit a form (but using the Crawler is easier!)
$client->request('POST', '/submit', array('name' => 'Fabien'));
+ // Submit a raw JSON string in the requst body
+ $client->request(
+ 'POST',
+ '/submit',
+ array(),
+ array(),
+ array('CONTENT_TYPE' => 'application/json'),
+ '{"name":"Fabien"}'
+ );
+
// Form submission with a file upload
use Symfony\Component\HttpFoundation\File\UploadedFile;
@@ -160,6 +160,39 @@ You can also set these colors and options inside the tagname::
// bold text on a yellow background
$output->writeln('<bg=yellow;options=bold>foo</bg=yellow;options=bold>');
+Verbosity Levels
+~~~~~~~~~~~~~~~~
+
+The console has 3 levels of verbosity. These are defined in the
+:class:`Symfony\\Component\\Console\\Output\\OutputInterface`:
+
+================================== ===============================
+Option Value
+================================== ===============================
+OutputInterface::VERBOSITY_QUIET Do not output any messages
+OutputInterface::VERBOSITY_NORMAL The default verbosity level
+OutputInterface::VERBOSITY_VERBOSE Increased verbosity of messages
+================================== ===============================
+
+You can specify the quiet verbosity level with the ``--quiet`` or ``-q``
+option. The ``--verbose`` or ``-v`` option is used when you want an increased
+level of verbosity.
+
+.. tip::
+
+ The full exception stacktrace is printed if the ``VERBOSITY_VERBOSE``
+ level is used.
+
+It is possible to print a message in a command for only a specific verbosity
+level. For example::
+
+ if (OutputInterface::VERBOSITY_VERBOSE === $output->getVerbosity()) {
+ $output->writeln(...);
+ }
+
+When the quiet level is used, all output is suppressed as the default
+:method:`Symfony\Component\Console\Output::write<Symfony\\Component\\Console\\Output::write>`
+method returns without actually printing.
Using Command Arguments
-----------------------
@@ -316,7 +316,10 @@ something needed in everyday use.
The compiler pass must have the ``process`` method which is passed the container
being compiled::
- class CustomCompilerPass
+ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
+ use Symfony\Component\DependencyInjection\ContainerBuilder;
+
+ class CustomCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
@@ -278,16 +278,16 @@ To work with multi-dimensional fields::
<input name="multi[dimensional]" />
</form>
-You must specify the fully qualified name of the field::
+Pass an array of values::
// Set a single field
- $form->setValue('multi[0]', 'value');
+ $form->setValues(array('multi' => array('value')));
// Set multiple fields at once
- $form->setValue('multi', array(
+ $form->setValues(array('multi' => array(
1 => 'value',
'dimensional' => 'an other value'
- ));
+ )));
This is great, but it gets better! The ``Form`` object allows you to interact
with your form like a browser, selecting radio values, ticking checkboxes,
@@ -90,7 +90,11 @@ use the Serializer service created before::
$person->setName('foo');
$person->setAge(99);
- $serializer->serialize($person, 'json'); // Output: {"name":"foo","age":99}
+ $jsonContent = $serializer->serialize($person, 'json');
+
+ // $jsonContent contains {"name":"foo","age":99}
+
+ echo $jsonContent; // or return it in a Response
The first parameter of the :method:`Symfony\\Component\\Serializer\\Serializer::serialize`
is the object to be serialized and the second is used to choose the proper encoder,
@@ -4,6 +4,7 @@ Bundles
.. toctree::
:maxdepth: 2
+ installation
best_practices
inheritance
override
@@ -0,0 +1,146 @@
+.. index::
+ single: Bundle; Installation
+
+How to install 3rd party Bundles
+================================
+
+Most bundles provide their own installation instructions. However, the
+basic steps for installing a bundle are the same.
+
+Add Composer Dependencies
+-------------------------
+
+Starting from Symfony 2.1, dependencies are managed with Composer. It's
+a good idea to learn some basics of Composer in `their documentation`_.
+
+Before you can use composer to install a bundle, you should look for a
+`Packagist`_ package of that bundle. For example, if you search for the popular
+`FOSUserBundle`_ you will find a packaged called `friendsofsymfony/user-bundle`_.
+
+.. note::
+
+ Packagist is the main archive for Composer. If you are searching
+ for a bundle, the best thing you can do is check out
+ `KnpBundles`_, it is the unofficial achive of Symfony Bundles. If
+ a bundle contains a ``README`` file, it is displayed there and if it
+ has a Packagist package it shows a link to the package. It's a
+ really useful site to begin searching for bundles.
+
+Now that you have the package name, you should determine the version
+you want to use. Usually different versions of a bundle correspond to
+a particular version of Symfony. This information should be in the ``README``
+file. If it isn't, you can use the version you want. If you choose an incompatible
+version, Composer will throw dependency errors when you try to install. If
+this happens, you can try a different version.
+
+In the case of the FOSUserBundle, the ``README`` file has a caution that version
+1.2.0 must be used for Symfony 2.0 and 1.3+ for Symfony 2.1+. Packagist displays
+example ``require`` statements for all existing versions of a package. The
+current development version of FOSUserBundle is ``"friendsofsymfony/user-bundle": "2.0.*@dev"``.
+
+Now you can add the bundle to your ``composer.json`` file and update the
+dependencies. You can do this manually:
+
+1. **Add it to the composer.json file:**
+
+ .. code-block:: json
+
+ {
+ ...,
+ "require": {
+ ...,
+ "friendsofsymfony/user-bundle": "2.0.*@dev"
+ }
+ }
+
+2. **Update the dependency:**
+
+ .. code-block:: bash
+
+ $ php composer.phar update friendsofsymfony/user-bundle
+
+ or update all dependencies
+
+ .. code-block:: bash
+
+ $ php composer.phar update
+
+Or you can do this in one command:
+
+.. code-block:: bash
+
+ $ php composer.phar require friendsofsymfony/user-bundle:2.0.*@dev
+
+Enable the Bundle
+-----------------
+
+At this point, the bundle is installed in your Symfony project (in
+``vendor/friendsofsymfony/``) and the autoloader recognizes its classes.
+The only thing you need to do now is register the bundle in ``AppKernel``::
+
+ // app/AppKernel.php
+
+ // ...
+ class AppKernel extends Kernel
+ {
+ // ...
+
+ public function registerBundles()
+ {
+ $bundles = array(
+ // ...,
+ new FOS\UserBundle\FOSUserBundle(),
+ );
+
+ // ...
+ }
+ }
+
+Configure the Bundle
+--------------------
+
+Usually a bundle requires some configuration to be added to app's
+``app/config/config.yml`` file. The bundle's documentation will likely
+describe that configuration. But you can also get a reference of the
+bundle's config via the ``config:dump-reference`` command.
+
+For instance, in order to look the reference of the ``assetic`` config you
+can use this:
+
+.. code-block:: bash
+
+ $ app/console config:dump-reference AsseticBundle
+
+or this:
+
+.. code-block:: bash
+
+ $ app/console config:dump-reference assetic
+
+The output will look like this:
+
+.. code-block:: text
+
+ assetic:
+ debug: %kernel.debug%
+ use_controller:
+ enabled: %kernel.debug%
+ profiler: false
+ read_from: %kernel.root_dir%/../web
+ write_to: %assetic.read_from%
+ java: /usr/bin/java
+ node: /usr/local/bin/node
+ node_paths: []
+ # ...
+
+Other Setup
+-----------
+
+At this point, check the ``README`` file of your brand new bundle to see
+what do to next.
+
+.. _their documentation: http://getcomposer.org/doc/00-intro.md
+.. _Packagist: https://packagist.org
+.. _FOSUserBundle: https://github.com/FriendsOfSymfony/FOSUserBundle
+.. _`friendsofsymfony/user-bundle`: https://packagist.org/packages/friendsofsymfony/user-bundle
+.. _KnpBundles: http://knpbundles.com/
@@ -56,7 +56,7 @@ end-user, create a new template located at
by your error pages), because the router runs before the firewall. If
the router throws an exception (for instance, when the route does not
match), then using ``is_granted`` will throw a further exception. You
- can use ``is_granted`` safely by saying ``{% if app.security and is_granted('...') %}``.
+ can use ``is_granted`` safely by saying ``{% if app.user and is_granted('...') %}``.
.. tip::
@@ -1,7 +1,6 @@
.. index::
single: Doctrine; File uploads
-
How to handle File Uploads with Doctrine
========================================
@@ -120,7 +119,7 @@ look like this::
Next, create this property on your ``Document`` class and add some validation
rules::
-use Symfony\Component\HttpFoundation\File\UploadedFile;
+ use Symfony\Component\HttpFoundation\File\UploadedFile;
// ...
class Document
@@ -155,12 +155,11 @@ How to Dynamically Generate Forms based on user data
====================================================
Sometimes you want a form to be generated dynamically based not only on data
-from this form (see :doc:`Dynamic form generation</cookbook/dynamic_form_generation>`)
-but also on something else. For example depending on the user currently using
-the application. If you have a social website where a user can only message
-people who are his friends on the website, then the current user doesn't need to
-be included as a field of your form, but a "choice list" of whom to message
-should only contain users that are the current user's friends.
+from this form but also on something else. For example depending on the user
+currently using the application. If you have a social website where a user can
+only message people who are his friends on the website, then the current user
+doesn't need to be included as a field of your form, but a "choice list" of
+whom to message should only contain users that are the current user's friends.
Creating the form type
----------------------
View
@@ -12,3 +12,4 @@ Form
create_form_type_extension
use_virtuals_forms
unit_testing
+ use_empty_data
@@ -149,7 +149,7 @@ Adding custom Extensions
------------------------
It often happens that you use some options that are added by
-:doc:`form extensions<cookbook/form/create_form_type_extension>`. One of the
+:doc:`form extensions</cookbook/form/create_form_type_extension>`. One of the
cases may be the ``ValidatorExtension`` with its ``invalid_message`` option.
The ``TypeTestCase`` loads only the core form extension so an "Invalid option"
exception will be raised if you try to use it for testing a class that depends
Oops, something went wrong.

0 comments on commit 71de41a

Please sign in to comment.