diff --git a/book/controller.rst b/book/controller.rst index 2d3f2ec6561..51be9a36891 100644 --- a/book/controller.rst +++ b/book/controller.rst @@ -119,7 +119,7 @@ This controller is pretty straightforward: * *line 4*: Symfony2 takes advantage of PHP 5.3 namespace functionality to namespace the entire controller class. The ``use`` keyword imports the - ``Response`` class, which our controller must return. + ``Response`` class, which the controller must return. * *line 6*: The class name is the concatenation of a name for the controller class (i.e. ``Hello``) and the word ``Controller``. This is a convention @@ -218,7 +218,7 @@ passed to that method:: } The controller has a single argument, ``$name``, which corresponds to the -``{name}`` parameter from the matched route (``ryan`` in our example). In +``{name}`` parameter from the matched route (``ryan`` in the example). In fact, when executing your controller, Symfony2 matches each argument of the controller with a parameter from the matched route. Take the following example: diff --git a/book/from_flat_php_to_symfony2.rst b/book/from_flat_php_to_symfony2.rst index aed3fca5bf6..9ff206520ee 100644 --- a/book/from_flat_php_to_symfony2.rst +++ b/book/from_flat_php_to_symfony2.rst @@ -131,7 +131,7 @@ is known as a "controller". The term :term:`controller` is a word you'll hear a lot, regardless of the language or framework you use. It refers simply to the area of *your* code that processes user input and prepares the response. -In this case, our controller prepares data from the database and then includes +In this case, the controller prepares data from the database and then includes a template to present that data. With the controller isolated, you could easily change *just* the template file if you needed to render the blog entries in some other format (e.g. ``list.json.php`` for JSON format). diff --git a/book/http_cache.rst b/book/http_cache.rst index 21ce0a641d0..f2f5c5e7f38 100644 --- a/book/http_cache.rst +++ b/book/http_cache.rst @@ -410,7 +410,7 @@ on a cache to store and return "fresh" responses. The HTTP specification defines a simple but powerful language in which clients and servers can communicate. As a web developer, the request-response - model of the specification dominates our work. Unfortunately, the actual + model of the specification dominates your work. Unfortunately, the actual specification document - `RFC 2616`_ - can be difficult to read. There is an on-going effort (`HTTP Bis`_) to rewrite the RFC 2616. It does @@ -550,8 +550,7 @@ would return. An ``ETag`` is like a fingerprint and is used to quickly compare if two different versions of a resource are equivalent. Like fingerprints, each ``ETag`` must be unique across all representations of the same resource. -Let's walk through a simple implementation that generates the ETag as the -md5 of the content:: +To see a simple implementation, generate the ETag as the md5 of the content:: public function indexAction() { @@ -868,7 +867,7 @@ independent of the rest of the page. } In this example, the full-page cache has a lifetime of ten minutes. -Next, let's include the news ticker in the template by embedding an action. +Next, include the news ticker in the template by embedding an action. This is done via the ``render`` helper (See :ref:`templating-embedding-controller` for more details). @@ -889,7 +888,7 @@ By setting ``standalone`` to ``true``, you tell Symfony2 that the action should be rendered as an ESI tag. You might be wondering why you would want to use a helper instead of just writing the ESI tag yourself. That's because using a helper makes your application work even if there is no gateway cache -installed. Let's see how it works. +installed. When standalone is ``false`` (the default), Symfony2 merges the included page content within the main one before sending the response to the client. But diff --git a/book/http_fundamentals.rst b/book/http_fundamentals.rst index 4160d209d12..eeda35a751c 100644 --- a/book/http_fundamentals.rst +++ b/book/http_fundamentals.rst @@ -118,7 +118,7 @@ from the xkcd web server: :align: center Translated into HTTP, the response sent back to the browser will look something -like this: +like this: .. code-block:: text @@ -145,7 +145,7 @@ known as HTTP headers. For example, one important HTTP response header is ``Content-Type``. The body of the same resource could be returned in multiple different formats like HTML, XML, or JSON and the ``Content-Type`` header uses Internet Media Types like ``text/html`` to tell the client which format is -being returned. A list of common media types can be found on Wikipedia's +being returned. A list of common media types can be found on Wikipedia's `List of common media types`_ article. Many other headers exist, some of which are very powerful. For example, certain @@ -259,9 +259,9 @@ the user is connecting via a secured connection (i.e. ``https``). :method:`Symfony\\Component\\HttpFoundation\\ParameterBag::all` and more. In fact, every public property used in the previous example is some instance of the ParameterBag. - + .. _book-fundamentals-attributes: - + The Request class also has a public ``attributes`` property, which holds special data related to how the application works internally. For the Symfony2 framework, the ``attributes`` holds the values returned by the @@ -269,7 +269,7 @@ the user is connecting via a secured connection (i.e. ``https``). wildcard), and even the name of the matched route (``_route``). The ``attributes`` property exists entirely to be a place where you can prepare and store context-specific information about the request. - + Symfony also provides a ``Response`` class: a simple PHP representation of an HTTP response message. This allows your application to use an object-oriented @@ -400,7 +400,7 @@ with many other tools Symfony makes available - to create and return a ``Respons object. In other words, the controller is where *your* code goes: it's where you interpret the request and create a response. -It's that easy! Let's review: +It's that easy! To review: * Each request executes a front controller file; @@ -413,7 +413,7 @@ It's that easy! Let's review: A Symfony Request in Action ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Without diving into too much detail, let's see this process in action. Suppose +Without diving into too much detail, here is this process in action. Suppose you want to add a ``/contact`` page to your Symfony application. First, start by adding an entry for ``/contact`` to your routing configuration file: @@ -465,14 +465,14 @@ specific PHP method ``contactAction`` inside a class called ``MainController``:: } } -In this very simple example, the controller simply creates a -:class:`Symfony\\Component\\HttpFoundation\\Response` object with the HTML +In this very simple example, the controller simply creates a +:class:`Symfony\\Component\\HttpFoundation\\Response` object with the HTML "``

Contact us!

"``. In the :doc:`controller chapter`, you'll learn how a controller can render templates, allowing your "presentation" code (i.e. anything that actually writes out HTML) to live in a separate template file. This frees up the controller to worry only about the hard stuff: interacting with the database, handling submitted data, or sending -email messages. +email messages. Symfony2: Build your App, not your Tools. ----------------------------------------- diff --git a/book/page_creation.rst b/book/page_creation.rst index 1a6c303e222..09c26b24341 100644 --- a/book/page_creation.rst +++ b/book/page_creation.rst @@ -22,15 +22,13 @@ HTTP response. Symfony2 follows this philosophy and provides you with tools and conventions to keep your application organized as it grows in users and complexity. -Sounds simple enough? Let's dive in! - .. index:: single: Page creation; Example The "Hello Symfony!" Page ------------------------- -Let's start with a spin off of the classic "Hello World!" application. When +Start by building a spin-off of the classic "Hello World!" application. When you're finished, the user will be able to get a personal greeting (e.g. "Hello Symfony") by going to the following URL: @@ -347,7 +345,7 @@ controller, and ``index.html.twig`` the template: Hello escape($name) ?>! -Let's step through the Twig template line-by-line: +Step through the Twig template line-by-line: * *line 2*: The ``extends`` token defines a parent template. The template explicitly defines a layout file inside of which it will be placed. diff --git a/book/propel.rst b/book/propel.rst index bcd56b2b932..879d6addada 100644 --- a/book/propel.rst +++ b/book/propel.rst @@ -4,7 +4,7 @@ Databases and Propel ==================== -Let's face it, one of the most common and challenging tasks for any application +One of the most common and challenging tasks for any application involves persisting and reading information to and from a database. Symfony2 does not come integrated with any ORMs but the Propel integration is easy. To get started, read `Working With Symfony2`_. @@ -18,8 +18,8 @@ persist it to the database and fetch it back out. .. sidebar:: Code along with the example If you want to follow along with the example in this chapter, create an - ``AcmeStoreBundle`` via: - + ``AcmeStoreBundle`` via: + .. code-block:: bash $ php app/console generate:bundle --namespace=Acme/StoreBundle @@ -171,19 +171,19 @@ Fetching Objects from the Database Fetching an object back from the database is even easier. For example, suppose you've configured a route to display a specific ``Product`` based on its ``id`` value:: - + // ... use Acme\StoreBundle\Model\ProductQuery; - + public function showAction($id) { $product = ProductQuery::create() ->findPk($id); - + if (!$product) { throw $this->createNotFoundException('No product found for id '.$id); } - + // ... do something, like pass the $product object into a template } @@ -192,22 +192,22 @@ Updating an Object Once you've fetched an object from Propel, updating it is easy. Suppose you have a route that maps a product id to an update action in a controller:: - + // ... use Acme\StoreBundle\Model\ProductQuery; - + public function updateAction($id) { $product = ProductQuery::create() ->findPk($id); - + if (!$product) { throw $this->createNotFoundException('No product found for id '.$id); } - + $product->setName('New product name!'); $product->save(); - + return $this->redirect($this->generateUrl('homepage')); } @@ -227,12 +227,12 @@ method on the object:: Querying for Objects -------------------- - + Propel provides generated ``Query`` classes to run both basic and complex queries without any work:: - + \Acme\StoreBundle\Model\ProductQuery::create()->findPk($id); - + \Acme\StoreBundle\Model\ProductQuery::create() ->filterByName('Foo') ->findOne(); @@ -287,13 +287,13 @@ Start by adding the ``category`` definition in your ``schema.xml``: - + - + @@ -320,29 +320,29 @@ Your database has been updated, you can continue to write your application. Saving Related Objects ~~~~~~~~~~~~~~~~~~~~~~ -Now, let's see the code in action. Imagine you're inside a controller:: +Now, try the code in action. Imagine you're inside a controller:: // ... use Acme\StoreBundle\Model\Category; use Acme\StoreBundle\Model\Product; use Symfony\Component\HttpFoundation\Response; - + class DefaultController extends Controller { public function createProductAction() { $category = new Category(); $category->setName('Main Products'); - + $product = new Product(); $product->setName('Foo'); $product->setPrice(19.99); // relate this product to the category $product->setCategory($category); - + // save the whole $product->save(); - + return new Response( 'Created product id: '.$product->getId().' and category id: '.$category->getId() ); @@ -363,15 +363,15 @@ before. First, fetch a ``$product`` object and then access its related // ... use Acme\StoreBundle\Model\ProductQuery; - + public function showAction($id) { $product = ProductQuery::create() ->joinWithCategory() ->findPk($id); - + $categoryName = $product->getCategory()->getName(); - + // ... } @@ -395,7 +395,7 @@ inserted, updated, deleted, etc). To add a hook, just add a new method to the object class:: // src/Acme/StoreBundle/Model/Product.php - + // ... class Product extends BaseProduct { diff --git a/book/security.rst b/book/security.rst index 57a8d121071..2ccd0b8e591 100644 --- a/book/security.rst +++ b/book/security.rst @@ -20,7 +20,8 @@ perform a certain action. .. image:: /images/book/security_authentication_authorization.png :align: center -Since the best way to learn is to see an example, let's dive right in. +Since the best way to learn is to see an example, start by securing your +application with HTTP Basic authentication. .. note:: diff --git a/book/service_container.rst b/book/service_container.rst index 0d59e1c37fa..c5f0c296785 100644 --- a/book/service_container.rst +++ b/book/service_container.rst @@ -336,7 +336,7 @@ for importing service configuration from third-party bundles. Importing Configuration with ``imports`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -So far, you've placed our ``my_mailer`` service container definition directly +So far, you've placed your ``my_mailer`` service container definition directly in the application configuration file (e.g. ``app/config/config.yml``). Of course, since the ``Mailer`` class itself lives inside the ``AcmeHelloBundle``, it makes more sense to put the ``my_mailer`` container definition inside the @@ -535,12 +535,12 @@ If you want to expose user friendly configuration in your own bundles, read the Referencing (Injecting) Services -------------------------------- -So far, our original ``my_mailer`` service is simple: it takes just one argument +So far, the original ``my_mailer`` service is simple: it takes just one argument in its constructor, which is easily configurable. As you'll see, the real power of the container is realized when you need to create a service that depends on one or more other services in the container. -Let's start with an example. Suppose you have a new service, ``NewsletterManager``, +As an example, suppose you have a new service, ``NewsletterManager``, that helps to manage the preparation and delivery of an email message to a collection of addresses. Of course the ``my_mailer`` service is already really good at delivering email messages, so you'll use it inside ``NewsletterManager`` @@ -576,7 +576,7 @@ fairly easily from inside a controller:: This approach is fine, but what if you decide later that the ``NewsletterManager`` class needs a second or third constructor argument? What if you decide to -refactor our code and rename the class? In both cases, you'd need to find every +refactor your code and rename the class? In both cases, you'd need to find every place where the ``NewsletterManager`` is instantiated and modify it. Of course, the service container gives you a much more appealing option: @@ -810,9 +810,9 @@ other third-party bundles to perform tasks such as rendering templates (``templa sending emails (``mailer``), or accessing information on the request (``request``). You can take this a step further by using these services inside services that -you've created for your application. Let's modify the ``NewsletterManager`` +you've created for your application. Beginning by modifying the ``NewsletterManager`` to use the real Symfony2 ``mailer`` service (instead of the pretend ``my_mailer``). -Let's also pass the templating engine service to the ``NewsletterManager`` +Also pass the templating engine service to the ``NewsletterManager`` so that it can generate the email content via a template:: namespace Acme\HelloBundle\Newsletter; diff --git a/book/templating.rst b/book/templating.rst index 7b4b77cefcb..2f8237488a8 100644 --- a/book/templating.rst +++ b/book/templating.rst @@ -697,8 +697,8 @@ To link to the page, just use the ``path`` Twig function and refer to the route: Home -As expected, this will generate the URL ``/``. Let's see how this works with -a more complicated route: +As expected, this will generate the URL ``/``. Now for a more complicated +route: .. configuration-block:: @@ -724,7 +724,7 @@ a more complicated route: return $collection; In this case, you need to specify both the route name (``article_show``) and -a value for the ``{slug}`` parameter. Using this route, let's revisit the +a value for the ``{slug}`` parameter. Using this route, revisit the ``recentList`` template from the previous section and link to the articles correctly: diff --git a/book/testing.rst b/book/testing.rst index 6972af66b80..2755487e056 100644 --- a/book/testing.rst +++ b/book/testing.rst @@ -76,7 +76,7 @@ of your bundle:: $calc = new Calculator(); $result = $calc->add(30, 12); - // assert that our calculator added the numbers correctly! + // assert that your calculator added the numbers correctly! $this->assertEquals(42, $result); } } diff --git a/components/serializer.rst b/components/serializer.rst index 9dadc2841d7..e9c9ce7e324 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -50,8 +50,8 @@ which Encoders and Normalizer are going to be available:: Serializing an object ~~~~~~~~~~~~~~~~~~~~~ -For the sake of this example, let's assume the following class already -exists in our project:: +For the sake of this example, assume the following class already +exists in your project:: namespace Acme; @@ -128,4 +128,4 @@ annotations (as well as YML, XML and PHP), integration with the Doctrine ORM, and handling of other complex cases (e.g. circular references). .. _`JMSSerializationBundle`: https://github.com/schmittjoh/JMSSerializerBundle -.. _Packagist: https://packagist.org/packages/symfony/serializer \ No newline at end of file +.. _Packagist: https://packagist.org/packages/symfony/serializer diff --git a/cookbook/security/acl.rst b/cookbook/security/acl.rst index b4c3e706846..39d167b8a87 100644 --- a/cookbook/security/acl.rst +++ b/cookbook/security/acl.rst @@ -141,7 +141,7 @@ example, you are granting the user who is currently logged in owner access to the Comment. The ``MaskBuilder::MASK_OWNER`` is a pre-defined integer bitmask; don't worry the mask builder will abstract away most of the technical details, but using this technique you can store many different permissions in one -database row which gives us a considerable boost in performance. +database row which gives a considerable boost in performance. .. tip:: diff --git a/cookbook/security/acl_advanced.rst b/cookbook/security/acl_advanced.rst index 3e741572ae2..52c7687db00 100644 --- a/cookbook/security/acl_advanced.rst +++ b/cookbook/security/acl_advanced.rst @@ -60,8 +60,8 @@ tables are ordered from least rows to most rows in a typical application: referenced from other tables. - *acl_object_identities*: Each row in this table represents a single domain object instance. -- *acl_object_identity_ancestors*: This table allows us to determine all the - ancestors of an ACL in a very efficient way. +- *acl_object_identity_ancestors*: This table allows all the ancestors of + an ACL to be determined in a very efficient way. - *acl_entries*: This table contains all ACEs. This is typically the table with the most rows. It can contain tens of millions without significantly impacting performance. diff --git a/cookbook/service_container/event_listener.rst b/cookbook/service_container/event_listener.rst index 1ad40b1106d..459cd994e72 100644 --- a/cookbook/service_container/event_listener.rst +++ b/cookbook/service_container/event_listener.rst @@ -11,7 +11,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, you will create a service that will act as an Exception Listener, allowing -you to modify how exceptions are shown by our application. The ``KernelEvents::EXCEPTION`` +you to modify how exceptions are shown by your application. The ``KernelEvents::EXCEPTION`` event is just one of the core kernel events:: // src/Acme/DemoBundle/Listener/AcmeExceptionListener.php diff --git a/reference/forms/types/collection.rst b/reference/forms/types/collection.rst index dd2fca2d3df..d302801e56b 100644 --- a/reference/forms/types/collection.rst +++ b/reference/forms/types/collection.rst @@ -171,12 +171,12 @@ you need is the JavaScript: // grab the prototype template var newWidget = emailList.attr('data-prototype'); // replace the "$$name$$" used in the id and name of the prototype - // with a number that's unique to our emails + // with a number that's unique to your emails // end name attribute looks like name="contact[emails][2]" newWidget = newWidget.replace(/\$\$name\$\$/g, emailCount); emailCount++; - // create a new list element and add it to our list + // create a new list element and add it to the list var newLi = jQuery('
  • ').html(newWidget); newLi.appendTo(jQuery('#email-fields-list')); diff --git a/reference/forms/types/file.rst b/reference/forms/types/file.rst index b03a56bb728..06d6c50bba7 100644 --- a/reference/forms/types/file.rst +++ b/reference/forms/types/file.rst @@ -22,7 +22,7 @@ The ``file`` type represents a file input in your form. Basic Usage ----------- -Let's say you have this form definition: +Say you have this form definition: .. code-block:: php @@ -47,7 +47,7 @@ used to move the ``attachment`` file to a permanent location: if ($form->isValid()) { $someNewFilename = ... - + $form['attachment']->getData()->move($dir, $someNewFilename); // ... @@ -89,4 +89,4 @@ These options inherit from the :doc:`field` type: .. include:: /reference/forms/types/options/read_only.rst.inc -.. include:: /reference/forms/types/options/error_bubbling.rst.inc \ No newline at end of file +.. include:: /reference/forms/types/options/error_bubbling.rst.inc