diff --git a/cookbook/assetic/asset_management.rst b/cookbook/assetic/asset_management.rst index 54ce75f608d..c541be4ac64 100644 --- a/cookbook/assetic/asset_management.rst +++ b/cookbook/assetic/asset_management.rst @@ -173,7 +173,7 @@ and deployment processes. To use a filter, you first need to specify it in the Assetic configuration. Adding a filter here doesn't mean it's being used - it just means that it's -available to use (we'll use the filter below). +available to use (you'll use the filter below). For example to use the JavaScript YUI Compressor the following config should be added: diff --git a/cookbook/bundles/override.rst b/cookbook/bundles/override.rst index 984f1b319f0..2846f2a0764 100644 --- a/cookbook/bundles/override.rst +++ b/cookbook/bundles/override.rst @@ -84,8 +84,8 @@ something beyond just the class name, you should use a compiler pass:: } } -In this example we fetch the service definition of the original service, and set -its class name to our own class. +In this example you fetch the service definition of the original service, and set +its class name to your own class. See :doc:`/cookbook/service_container/compiler_passes` for information on how to use compiler passes. If you want to do something beyond just overriding the class - diff --git a/cookbook/configuration/apache_router.rst b/cookbook/configuration/apache_router.rst index 23e0f6dd828..c2e5d79a4c9 100644 --- a/cookbook/configuration/apache_router.rst +++ b/cookbook/configuration/apache_router.rst @@ -10,11 +10,11 @@ One of these ways is by letting apache handle routes directly, rather than using Change Router Configuration Parameters -------------------------------------- -To dump Apache routes we must first tweak some configuration parameters to tell +To dump Apache routes you must first tweak some configuration parameters to tell Symfony2 to use the ``ApacheUrlMatcher`` instead of the default one: .. code-block:: yaml - + # app/config/config_prod.yml parameters: router.options.matcher.cache_class: ~ # disable router cache @@ -26,27 +26,27 @@ Symfony2 to use the ``ApacheUrlMatcher`` instead of the default one: extends :class:`Symfony\\Component\\Routing\\Matcher\\UrlMatcher` so even if you don't regenerate the url_rewrite rules, everything will work (because at the end of ``ApacheUrlMatcher::match()`` a call to ``parent::match()`` - is done). - + is done). + Generating mod_rewrite rules ---------------------------- - + To test that it's working, let's create a very basic route for demo bundle: .. code-block:: yaml - + # app/config/routing.yml hello: pattern: /hello/{name} defaults: { _controller: AcmeDemoBundle:Demo:hello } - - -Now we generate **url_rewrite** rules: - + + +Now generate **url_rewrite** rules: + .. code-block:: bash $ php app/console router:dump-apache -e=prod --no-debug - + Which should roughly output the following: .. code-block:: apache @@ -59,7 +59,7 @@ Which should roughly output the following: RewriteCond %{REQUEST_URI} ^/hello/([^/]+?)$ RewriteRule .* app.php [QSA,L,E=_ROUTING__route:hello,E=_ROUTING_name:%1,E=_ROUTING__controller:AcmeDemoBundle\:Demo\:hello] -You can now rewrite `web/.htaccess` to use the new rules, so with our example +You can now rewrite `web/.htaccess` to use the new rules, so with this example it should look like this: .. code-block:: apache @@ -82,7 +82,7 @@ it should look like this: That's it! You're now all set to use Apache Route rules. - + Additional tweaks ----------------- @@ -90,7 +90,7 @@ To save a little bit of processing time, change occurrences of ``Request`` to ``ApacheRequest`` in ``web/app.php``:: // web/app.php - + require_once __DIR__.'/../app/bootstrap.php.cache'; require_once __DIR__.'/../app/AppKernel.php'; //require_once __DIR__.'/../app/AppCache.php'; diff --git a/cookbook/configuration/override_dir_structure.rst b/cookbook/configuration/override_dir_structure.rst index 93914de9c83..90601930976 100644 --- a/cookbook/configuration/override_dir_structure.rst +++ b/cookbook/configuration/override_dir_structure.rst @@ -4,8 +4,8 @@ How to override Symfony's Default Directory Structure ===================================================== -Symfony automatically ships with a default directory structure. You can -easily override this directory structure to create your own. The default +Symfony automatically ships with a default directory structure. You can +easily override this directory structure to create your own. The default directory structure is: .. code-block:: text @@ -26,7 +26,7 @@ directory structure is: Override the ``cache`` directory -------------------------------- -You can override the cache directory by overriding the ``getCacheDir`` method +You can override the cache directory by overriding the ``getCacheDir`` method in the ``AppKernel`` class of you application:: // app/AppKernel.php @@ -43,7 +43,7 @@ in the ``AppKernel`` class of you application:: } ``$this->rootDir`` is the absolute path to the ``app`` directory and ``$this->environment`` -is the current environment (i.e. ``dev``). In this case we have changed +is the current environment (i.e. ``dev``). In this case you have changed the location of the cache directory to ``app/{environment}/cache``. .. caution:: @@ -56,8 +56,8 @@ the location of the cache directory to ``app/{environment}/cache``. Override the ``logs`` directory ------------------------------- -Overriding the ``logs`` directory is the same as overriding the ``cache`` -directory, the only difference is that you need to override the ``getLogDir`` +Overriding the ``logs`` directory is the same as overriding the ``cache`` +directory, the only difference is that you need to override the ``getLogDir`` method:: // app/AppKernel.php @@ -73,7 +73,7 @@ method:: } } -Here we have changed the location of the directory to ``app/{environment}/logs``. +Here you have changed the location of the directory to ``app/{environment}/logs``. Override the ``web`` directory ------------------------------ @@ -98,7 +98,7 @@ may need to modify the paths inside these files:: .. note:: - If you use the AsseticBundle you need to configure this, so it can use + If you use the AsseticBundle you need to configure this, so it can use the correct ``web`` directory: .. code-block:: yaml @@ -110,7 +110,7 @@ may need to modify the paths inside these files:: # ... read_from: "%kernel.root_dir%/../../public_html" - Now you just need to dump the assets again and your application should + Now you just need to dump the assets again and your application should work: .. code-block:: bash diff --git a/cookbook/controller/error_pages.rst b/cookbook/controller/error_pages.rst index af60f1fb737..a82f81b9ba0 100644 --- a/cookbook/controller/error_pages.rst +++ b/cookbook/controller/error_pages.rst @@ -28,7 +28,7 @@ control you need: information, see :ref:`kernel-kernel.exception`. All of the error templates live inside ``TwigBundle``. To override the -templates, we simply rely on the standard method for overriding templates that +templates, simply rely on the standard method for overriding templates that live inside a bundle. For more information, see :ref:`overriding-bundle-templates`. diff --git a/cookbook/controller/service.rst b/cookbook/controller/service.rst index bc886fe9169..3291ce3a1a2 100644 --- a/cookbook/controller/service.rst +++ b/cookbook/controller/service.rst @@ -10,8 +10,8 @@ extends the base this works fine, controllers can also be specified as services. To refer to a controller that's defined as a service, use the single colon (:) -notation. For example, suppose we've defined a service called -``my_controller`` and we want to forward to a method called ``indexAction()`` +notation. For example, suppose you've defined a service called +``my_controller`` and you want to forward to a method called ``indexAction()`` inside the service:: $this->forward('my_controller:indexAction', array('foo' => $bar)); @@ -62,4 +62,4 @@ service, you need to specify your service as follows:: In this example, ``my_bundle.annot_controller`` should be the id of the ``AnnotController`` instance defined in the service container. This is documented in the :doc:`/bundles/SensioFrameworkExtraBundle/annotations/routing` -chapter. \ No newline at end of file +chapter. diff --git a/cookbook/doctrine/file_uploads.rst b/cookbook/doctrine/file_uploads.rst index 5ebb1c29a46..abb042bbd4a 100644 --- a/cookbook/doctrine/file_uploads.rst +++ b/cookbook/doctrine/file_uploads.rst @@ -210,9 +210,9 @@ object, which is what's returned after a ``file`` field is submitted:: return; } - // we use the original file name here but you should + // use the original file name here but you should // sanitize it at least to avoid any security issues - + // move takes the target directory and then the target filename to move to $this->file->move($this->getUploadRootDir(), $this->file->getClientOriginalName()); diff --git a/cookbook/doctrine/reverse_engineering.rst b/cookbook/doctrine/reverse_engineering.rst index 7f5fac8dd7f..c3ae948f75a 100644 --- a/cookbook/doctrine/reverse_engineering.rst +++ b/cookbook/doctrine/reverse_engineering.rst @@ -49,7 +49,7 @@ to a post record thanks to a foreign key constraint. Before diving into the recipe, be sure your database connection parameters are correctly setup in the ``app/config/parameters.ini`` file (or wherever your database configuration is kept) and that you have initialized a bundle that -will host your future entity class. In this tutorial, we will assume that +will host your future entity class. In this tutorial it's assumed that an ``AcmeBlogBundle`` exists and is located under the ``src/Acme/BlogBundle`` folder. diff --git a/cookbook/event_dispatcher/before_after_filters.rst b/cookbook/event_dispatcher/before_after_filters.rst index 4bebee88d79..7ca34c3013a 100755 --- a/cookbook/event_dispatcher/before_after_filters.rst +++ b/cookbook/event_dispatcher/before_after_filters.rst @@ -275,6 +275,6 @@ event: That's it! The ``TokenListener`` is now notified before every controller is executed (``onKernelController``) and after every controller returns a response (``onKernelResponse``). By making specific controllers implement the ``TokenAuthenticatedController`` -interface, our listener knows which controllers it should take action on. +interface, your listener knows which controllers it should take action on. And by storing a value in the request's "attributes" bag, the ``onKernelResponse`` method knows to add the extra header. Have fun! diff --git a/cookbook/event_dispatcher/class_extension.rst b/cookbook/event_dispatcher/class_extension.rst index 7cc52c65210..6ae1edc88bd 100644 --- a/cookbook/event_dispatcher/class_extension.rst +++ b/cookbook/event_dispatcher/class_extension.rst @@ -97,7 +97,7 @@ and *add* the method ``bar()``: { public function onFooMethodIsNotFound(HandleUndefinedMethodEvent $event) { - // we only want to respond to the calls to the 'bar' method + // only respond to the calls to the 'bar' method if ('bar' != $event->getMethod()) { // allow another listener to take care of this unknown method return; diff --git a/cookbook/logging/monolog.rst b/cookbook/logging/monolog.rst index 38d669b940b..f9f92e3f25d 100644 --- a/cookbook/logging/monolog.rst +++ b/cookbook/logging/monolog.rst @@ -33,7 +33,7 @@ To log a message simply get the logger service from the container in your controller:: $logger = $this->get('logger'); - $logger->info('We just got the logger'); + $logger->info('I just got the logger'); $logger->err('An error occurred'); .. tip:: diff --git a/cookbook/routing/redirect_in_config.rst b/cookbook/routing/redirect_in_config.rst index 42fa0274cfd..ba92db3ac5b 100644 --- a/cookbook/routing/redirect_in_config.rst +++ b/cookbook/routing/redirect_in_config.rst @@ -28,7 +28,7 @@ Your configuration will look like this: Your ``AppBundle`` is registered to handle all requests under ``/app``. -We configure a route for the ``/`` path and let :class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\RedirectController` +You configure a route for the ``/`` path and let :class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\RedirectController` handle it. This controller is built-in and offers two methods for redirecting request: * ``redirect`` redirects to another *route*. You must provide the ``route`` diff --git a/cookbook/service_container/event_listener.rst b/cookbook/service_container/event_listener.rst index 3621490364b..4ec53df4fcd 100644 --- a/cookbook/service_container/event_listener.rst +++ b/cookbook/service_container/event_listener.rst @@ -10,7 +10,7 @@ component and can be viewed in the :class:`Symfony\\Component\\HttpKernel\\Kerne To hook into an event and add your own custom logic, you have to create a service that will act as an event listener on that event. In this entry, -we will create a service that will act as an Exception Listener, allowing +you will create a service that will act as an Exception Listener, allowing us to modify how exceptions are shown by our application. The ``KernelEvents::EXCEPTION`` event is just one of the core kernel events:: @@ -25,11 +25,11 @@ event is just one of the core kernel events:: { public function onKernelException(GetResponseForExceptionEvent $event) { - // We get the exception object from the received event + // You get the exception object from the received event $exception = $event->getException(); $message = 'My Error says: ' . $exception->getMessage() . ' with code: ' . $exception->getCode(); - // Customize our response object to display our exception details + // Customize your response object to display the exception details $response = new Response(); $response->setContent($message); @@ -42,7 +42,7 @@ event is just one of the core kernel events:: $response->setStatusCode(500); } - // Send our modified response object to the event + // Send the modified response object to the event $event->setResponse($response); } } @@ -53,7 +53,7 @@ event is just one of the core kernel events:: the ``kernel.exception`` event, it is :class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent`. To see what type of object each event listener receives, see :class:`Symfony\\Component\\HttpKernel\\KernelEvents`. -Now that the class is created, we just need to register it as a service and +Now that the class is created, you just need to register it as a service and notify Symfony that it is a "listener" on the ``kernel.exception`` event by using a special "tag": diff --git a/cookbook/service_container/scopes.rst b/cookbook/service_container/scopes.rst index acbfc5503ff..7da0e98254f 100644 --- a/cookbook/service_container/scopes.rst +++ b/cookbook/service_container/scopes.rst @@ -37,7 +37,7 @@ when compiling the container. Read the sidebar below for more details. the scope of the service, so it defaults to `container`. In other words, everytime you ask the container for the `my_mailer` service, you get the same object back. This is usually how you want your services to work. - + Imagine, however, that you need the `request` service in your `my_mailer` service, maybe because you're reading the URL of the current request. So, you add it as a constructor argument. Let's look at why this presents @@ -67,7 +67,7 @@ when compiling the container. Read the sidebar below for more details. .. note:: A service can of course depend on a service from a wider scope without - any issue. + any issue. Setting the Scope in the Definition ----------------------------------- @@ -116,7 +116,7 @@ new service in the `request` scope. But this is not always possible (for instance, a twig extension must be in the `container` scope as the Twig environment needs it as a dependency). In these cases, you should pass the entire container into your service and -retrieve your dependency from the container each time we need it to be sure +retrieve your dependency from the container each time you need it to be sure you have the right instance:: // src/Acme/HelloBundle/Mail/Mailer.php diff --git a/cookbook/symfony1.rst b/cookbook/symfony1.rst index 4e8463579e4..ffede093e4a 100644 --- a/cookbook/symfony1.rst +++ b/cookbook/symfony1.rst @@ -10,12 +10,12 @@ at its core, the skills used to master a symfony1 project continue to be very relevant when developing in Symfony2. Sure, ``app.yml`` is gone, but routing, controllers and templates all remain. -In this chapter, we'll walk through the differences between symfony1 and Symfony2. +This chapter walks through the differences between symfony1 and Symfony2. As you'll see, many tasks are tackled in a slightly different way. You'll come to appreciate these minor differences as they promote stable, predictable, testable and decoupled code in your Symfony2 applications. -So, sit back and relax as we take you from "then" to "now". +So, sit back and relax as your taken from "then" to "now". Directory Structure ------------------- @@ -61,7 +61,7 @@ In other words, the code that drives your application lives in many different places. In Symfony2, life is much simpler because *all* Symfony2 code must live in -a bundle. In our pretend symfony1 project, all the code *could* be moved +a bundle. In the pretend symfony1 project, all the code *could* be moved into one or more plugins (which is a very good practice, in fact). Assuming that all modules, PHP classes, schema, routing configuration, etc were moved into a plugin, the symfony1 ``plugins/`` directory would be very similar @@ -134,7 +134,7 @@ The file itself lives at ``vendor/bundle/Sensio/Bundle/FrameworkExtraBundle/SensioFrameworkExtraBundle.php``. As you can see, the location of the file follows the namespace of the class. Specifically, the namespace, ``Sensio\Bundle\FrameworkExtraBundle``, spells out -the directory that the file should live in +the directory that the file should live in (``vendor/bundle/Sensio/Bundle/FrameworkExtraBundle``). This is because, in the ``app/autoload.php`` file, you'll configure Symfony to look for the ``Sensio`` namespace in the ``vendor/bundle`` directory: @@ -251,7 +251,7 @@ In Symfony2, the bundles are activated inside the application kernel:: ..., new Acme\DemoBundle\AcmeDemoBundle(), ); - + return $bundles; } diff --git a/cookbook/templating/PHP.rst b/cookbook/templating/PHP.rst index 456a9fcb84c..635e08926b9 100644 --- a/cookbook/templating/PHP.rst +++ b/cookbook/templating/PHP.rst @@ -18,7 +18,7 @@ your application configuration file: .. configuration-block:: .. code-block:: yaml - + # app/config/config.yml framework: # ... @@ -42,7 +42,7 @@ your application configuration file: 'templating' => array( 'engines' => array('twig', 'php'), ), - )); + )); You can now render a PHP template instead of a Twig one simply by using the ``.php`` extension in the template name instead of ``.twig``. The controller @@ -82,7 +82,7 @@ Decorating Templates -------------------- More often than not, templates in a project share common elements, like the -well-known header and footer. In Symfony2, we like to think about this problem +well-known header and footer. In Symfony2, this problem is thought about differently: a template can be decorated by another one. The ``index.html.php`` template is decorated by ``layout.html.php``, thanks to diff --git a/cookbook/templating/global_variables.rst b/cookbook/templating/global_variables.rst index 9cbe2b36039..93dddeaefb3 100644 --- a/cookbook/templating/global_variables.rst +++ b/cookbook/templating/global_variables.rst @@ -19,7 +19,7 @@ Now, the variable ``ga_tracking`` is available in all Twig templates: .. code-block:: html+jinja -
Our google tracking code is: {{ ga_tracking }}
+The google tracking code is: {{ ga_tracking }}
It's that easy! You can also take advantage of the built-in :ref:`book-service-container-parameters` system, which lets you isolate or reuse the value: diff --git a/cookbook/templating/twig_extension.rst b/cookbook/templating/twig_extension.rst index 144da793e36..8bb744941cd 100644 --- a/cookbook/templating/twig_extension.rst +++ b/cookbook/templating/twig_extension.rst @@ -1,11 +1,11 @@ .. index:: single: Twig extensions - + How to write a custom Twig Extension ==================================== The main motivation for writing an extension is to move often used code -into a reusable class like adding support for internationalization. +into a reusable class like adding support for internationalization. An extension can define tags, filters, tests, operators, global variables, functions, and node visitors. @@ -16,12 +16,12 @@ your code faster. .. tip:: Before writing your own extensions, have a look at the `Twig official extension repository`_. - + Create the Extension Class --------------------------- +-------------------------- -To get your custom functionality you must first create a Twig Extension class. -As an example we will create a price filter to format a given number into price:: +To get your custom functionality you must first create a Twig Extension class. +As an example you'll create a price filter to format a given number into price:: // src/Acme/DemoBundle/Twig/AcmeExtension.php namespace Acme\DemoBundle\Twig; @@ -51,8 +51,8 @@ As an example we will create a price filter to format a given number into price: .. tip:: - Along with custom filters, you can also add custom `functions` and register `global variables`. - + Along with custom filters, you can also add custom `functions` and register `global variables`. + Register an Extension as a Service ---------------------------------- @@ -61,7 +61,7 @@ Now you must let Service Container know about your newly created Twig Extension: .. configuration-block:: .. code-block:: xml - +