Skip to content

be keen to newcomers #11044

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion best_practices/business-logic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ This practice is cumbersome and completely unnecessary for your own services.
Don't define parameters for the classes of your services.

This practice was wrongly adopted from third-party bundles. When Symfony
introduced its service container, some developers used this technique to easily
introduced its service container, some developers used this technique to
allow overriding services. However, overriding a service by just changing its
class name is a very rare use case because, frequently, the new service has
different constructor arguments.
Expand Down
8 changes: 4 additions & 4 deletions best_practices/controllers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Fetching Services

If you extend the base ``Controller`` class, you can access services directly from
the container via ``$this->container->get()`` or ``$this->get()``. But instead, you
should use dependency injection to fetch services: most easily done by
should use dependency injection to fetch services by
:ref:`type-hinting action method arguments <controller-accessing-services>`:

.. best-practice::
Expand Down Expand Up @@ -208,9 +208,9 @@ flexible::
// ...
}

The point is this: the ParamConverter shortcut is great for simple situations.
But you shouldn't forget that querying for entities directly is still very
easy.
The point is this: the ParamConverter shortcut is great for most situations.
However, there is nothing wrong with querying for entities directly if the
ParamConverter would get complicated.

Pre and Post Hooks
------------------
Expand Down
7 changes: 3 additions & 4 deletions best_practices/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ The @Security Annotation
------------------------

For controlling access on a controller-by-controller basis, use the ``@Security``
annotation whenever possible. It's easy to read and is placed consistently
above each action.
annotation whenever possible. Placing it above each action makes it consistent and readable.

In our application, you need the ``ROLE_ADMIN`` in order to create a new post.
Using ``@Security``, this looks like:
Expand Down Expand Up @@ -156,7 +155,7 @@ Notice that this requires the use of the `ParamConverter`_, which automatically
queries for the ``Post`` object and puts it on the ``$post`` argument. This
is what makes it possible to use the ``post`` variable in the expression.

This has one major drawback: an expression in an annotation cannot easily
This has one major drawback: an expression in an annotation cannot
be reused in other parts of the application. Imagine that you want to add
a link in a template that will only be seen by authors. Right now you'll
need to repeat the expression code using Twig syntax:
Expand All @@ -167,7 +166,7 @@ need to repeat the expression code using Twig syntax:
<a href=""> ... </a>
{% endif %}

The easiest solution - if your logic is simple enough - is to add a new method
A good solution - if your logic is simple enough - can be to add a new method
to the ``Post`` entity that checks if a given user is its author::

// src/AppBundle/Entity/Post.php
Expand Down
2 changes: 1 addition & 1 deletion best_practices/templates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ scattered through lots of bundles.
Use a prefixed underscore for partial templates in template names.

You often want to reuse template code using the ``include`` function to avoid
redundant code. To determine those partials easily in the filesystem you should
redundant code. To determine those partials in the filesystem you should
prefix partials and any other template without HTML body or ``extends`` tag
with a single underscore.

Expand Down
10 changes: 5 additions & 5 deletions best_practices/web-assets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ Using Assetic

.. include:: /assetic/_standard_edition_warning.rst.inc

These days, you probably can't simply create static CSS and JavaScript files
and include them in your template. Instead, you'll probably want to combine
and minify these to improve client-side performance. You may also want to
use LESS or Sass (for example), which means you'll need some way to process
these into CSS files.
These days, you probably can't create static CSS and JavaScript files and
include them in your template without much effort. Instead, you'll probably
want to combine and minify these to improve client-side performance. You may
also want to use LESS or Sass (for example), which means you'll need some way
to process these into CSS files.

A lot of tools exist to solve these problems, including pure-frontend (non-PHP)
tools like GruntJS.
Expand Down
4 changes: 2 additions & 2 deletions bundles/best_practices.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ There are two types of bundles:
* Application-specific bundles: only used to build your application;
* Reusable bundles: meant to be shared across many projects.

This article is all about how to structure your **reusable bundles** so that
they're easy to configure and extend. Many of these recommendations do not
This article is all about how to structure your **reusable bundles** to be
configurable and extendable. Many of these recommendations do not
apply to application bundles because you'll want to keep those as simple
as possible. For application bundles, just follow the practices shown throughout
the guides.
Expand Down
8 changes: 4 additions & 4 deletions bundles/inheritance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ Then, register the third-party FOSUserBundle as the "parent" of your bundle::
}
}

By making this simple change, you can now override several parts of the FOSUserBundle
simply by creating a file with the same name.
By making this small change, you can now override several parts of the FOSUserBundle
by creating a file with the same name.

.. note::

Expand Down Expand Up @@ -82,8 +82,8 @@ original method, and change its functionality::
Overriding Resources: Templates, Routing, etc
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Most resources can also be overridden, simply by creating a file in the same
location as your parent bundle.
Most resources can also be overridden by creating a file in the same location
as your parent bundle.

For example, it's very common to need to override the FOSUserBundle's
``layout.html.twig`` template so that it uses your application's base layout.
Expand Down
2 changes: 1 addition & 1 deletion configuration/configuration_organization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ How to Organize Configuration Files

The default Symfony Standard Edition defines three
:doc:`execution environments </configuration/environments>` called
``dev``, ``prod`` and ``test``. An environment simply represents a way to
``dev``, ``prod`` and ``test``. An environment represents a way to
execute the same codebase with different configurations.

In order to select the configuration file to load for each environment, Symfony
Expand Down
3 changes: 1 addition & 2 deletions configuration/external_parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ How to Set external Parameters in the Service Container
In the article :doc:`/configuration`, you learned how to manage your application
configuration. At times, it may benefit your application to store certain
credentials outside of your project code. Database configuration is one such
example. The flexibility of the Symfony service container allows you to easily
do this.
example. The flexibility of the Symfony service container allows you to do this.

Environment Variables
---------------------
Expand Down
4 changes: 2 additions & 2 deletions configuration/front_controllers_and_kernel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The front controller can be chosen by requesting URLs like:
http://localhost/app_dev.php/some/path/...

As you can see, this URL contains the PHP script to be used as the front
controller. You can use that to easily switch the front controller or use
controller. You can use that to switch the front controller or use
a custom one by placing it in the ``web/`` directory (e.g. ``app_cache.php``).

When using Apache and the `RewriteRule shipped with the Symfony Standard Edition`_,
Expand Down Expand Up @@ -153,7 +153,7 @@ front controller to the ``AppKernel``'s constructor. This name can then be
used in the :method:`Symfony\\Component\\HttpKernel\\KernelInterface::registerContainerConfiguration`
method to decide which configuration files to load.

The Symfony Standard Edition's `AppKernel`_ class implements this method by simply
The Symfony Standard Edition's `AppKernel`_ class implements this method by
loading the ``app/config/config_*environment*.yml`` file. You are, of course,
free to implement this method differently if you need a more sophisticated
way of loading your configuration.
Expand Down
2 changes: 1 addition & 1 deletion configuration/micro_kernel_trait.rst
Original file line number Diff line number Diff line change
Expand Up @@ -350,4 +350,4 @@ Then see webpage in browser:

Hey, that looks a lot like a *traditional* Symfony application! You're right: the
``MicroKernelTrait`` *is* still Symfony: but you can control your structure and
features quite easily.
features with less boilerplate configuration and code.
8 changes: 4 additions & 4 deletions configuration/override_dir_structure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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
override this directory structure to create your own. The default
directory structure is:

.. code-block:: text
Expand Down Expand Up @@ -140,9 +140,9 @@ Override the ``web`` Directory

If you need to rename or move your ``web`` directory, the only thing you
need to guarantee is that the path to the ``var`` directory is still correct
in your ``app.php`` and ``app_dev.php`` front controllers. If you simply
renamed the directory, you're fine. But if you moved it in some way, you
may need to modify these paths inside those files::
in your ``app.php`` and ``app_dev.php`` front controllers. If you renamed
the directory, you're fine. But if you moved it in some way, you may need
to modify these paths inside those files::

require_once __DIR__.'/../path/to/app/autoload.php';

Expand Down
6 changes: 3 additions & 3 deletions console/style.rst
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ User Input Methods

$io->ask('What is your name?');

You can pass the default value as the second argument so the user can simply
You can pass the default value as the second argument so the user can
hit the <Enter> key to select that value::

$io->ask('Where are you from?', 'United States');
Expand Down Expand Up @@ -262,7 +262,7 @@ User Input Methods

$io->confirm('Restart the web server?');

You can pass the default value as the second argument so the user can simply
You can pass the default value as the second argument so the user can
hit the <Enter> key to select that value::

$io->confirm('Restart the web server?', true);
Expand All @@ -273,7 +273,7 @@ User Input Methods

$io->choice('Select the queue to analyze', ['queue1', 'queue2', 'queue3']);

You can pass the default value as the third argument so the user can simply
You can pass the default value as the third argument so the user can
hit the <Enter> key to select that value::

$io->choice('Select the queue to analyze', ['queue1', 'queue2', 'queue3'], 'queue1');
Expand Down
12 changes: 6 additions & 6 deletions create_framework/http_foundation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ As you can see for yourself, the simple code we had written first is not that
simple anymore if we want to avoid PHP warnings/notices and make the code
more secure.

Beyond security, this code is not even easily testable. Even if there is not
Beyond security, this code can be complex to test. Even if there is not
much to test, it strikes me that writing unit tests for the simplest possible
snippet of PHP code is not natural and feels ugly. Here is a tentative PHPUnit
unit test for the above code::
Expand Down Expand Up @@ -126,10 +126,10 @@ containing the new requirement.
.. sidebar:: Class Autoloading

When installing a new dependency, Composer also generates a
``vendor/autoload.php`` file that allows any class to be easily
`autoloaded`_. Without autoloading, you would need to require the file
where a class is defined before being able to use it. But thanks to
`PSR-4`_, we can just let Composer and PHP do the hard work for us.
``vendor/autoload.php`` file that allows any class to be `autoloaded`_.
Without autoloading, you would need to require the file where a class
is defined before being able to use it. But thanks to `PSR-4`_,
we can just let Composer and PHP do the hard work for us.

Now, let's rewrite our application by using the ``Request`` and the
``Response`` classes::
Expand Down Expand Up @@ -201,7 +201,7 @@ You can also simulate a request::

$request = Request::create('/index.php?name=Fabien');

With the ``Response`` class, you can easily tweak the response::
With the ``Response`` class, you can tweak the response::

$response = new Response();

Expand Down
2 changes: 1 addition & 1 deletion deployment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ There are also tools to help ease the pain of deployment. Some of them have been
specifically tailored to the requirements of Symfony.

`EasyDeployBundle`_
A Symfony bundle that adds easy deploy tools to your application.
A Symfony bundle that adds deploy tools to your application.

`Deployer`_
This is another native PHP rewrite of Capistrano, with some ready recipes for
Expand Down
6 changes: 3 additions & 3 deletions email/cloud.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ option. If setting up and maintaining your own reliable mail server causes
you a headache there's a simple solution: Leverage the cloud to send your
emails.

This article shows how easy it is to integrate
`Amazon's Simple Email Service (SES)`_ into Symfony.
This article shows how to integrate `Amazon's Simple Email Service (SES)`_
into Symfony.

.. note::

Expand Down Expand Up @@ -75,7 +75,7 @@ and complete the configuration with the provided ``username`` and ``password``:
]);

The ``port`` and ``encryption`` keys are not present in the Symfony Standard
Edition configuration by default, but you can simply add them as needed.
Edition configuration by default, but you can add them if needed.

And that's it, you're ready to start sending emails through the cloud!

Expand Down
8 changes: 4 additions & 4 deletions email/dev_environment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ How to Work with Emails during Development
When developing an application which sends email, you will often
not want to actually send the email to the specified recipient during
development. If you are using the SwiftmailerBundle with Symfony, you
can easily achieve this through configuration settings without having to
make any changes to your application's code at all. There are two main
choices when it comes to handling email during development: (a) disabling the
can achieve this through configuration settings without having to make
any changes to your application's code at all. There are two main choices
when it comes to handling email during development: (a) disabling the
sending of email altogether or (b) sending all email to a specific
address (with optional exceptions).

Expand Down Expand Up @@ -51,7 +51,7 @@ will not be sent when you run tests, but will continue to be sent in the
'disable_delivery' => "true",
]);

If you'd also like to disable deliver in the ``dev`` environment, simply
If you'd also like to disable deliver in the ``dev`` environment,
add this same configuration to the ``config_dev.yml`` file.

.. _sending-to-a-specified-address:
Expand Down
6 changes: 3 additions & 3 deletions email/gmail.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ How to Use Gmail to Send Emails
===============================

During development, instead of using a regular SMTP server to send emails, you
might find using Gmail easier and more practical. The SwiftmailerBundle makes
it really easy.
might find using Gmail easier and more practical. You can achieve this with the
SwiftmailerBundle without much effort.

In the development configuration file, change the ``transport`` setting to
``gmail`` and set the ``username`` and ``password`` to the Google credentials:
Expand Down Expand Up @@ -105,7 +105,7 @@ In the development configuration file, change the ``transport`` setting to
Redefining the Default Configuration Parameters
-----------------------------------------------

The ``gmail`` transport is simply a shortcut that uses the ``smtp`` transport
The ``gmail`` transport is a shortcut that uses the ``smtp`` transport
and sets these options:

============== ==================
Expand Down
2 changes: 1 addition & 1 deletion email/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SwiftmailerBundle, which leverages the power of the `Swift Mailer`_ library.
To functionally test that an email was sent, and even assert the email subject,
content or any other headers, you can use :doc:`the Symfony Profiler </profiler>`.

Start with an easy controller action that sends an email::
Start with a controller action that sends an email::

public function sendEmailAction($name, \Swift_Mailer $mailer)
{
Expand Down
4 changes: 2 additions & 2 deletions form/create_custom_field_type.rst
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ link for details), create a ``shipping_widget`` block to handle this:
Using the Field Type
--------------------

You can now use your custom field type immediately, simply by creating a
new instance of the type in one of your forms::
You can now use your custom field type by creating a new instance
of the type in one of your forms::

// src/AppBundle/Form/Type/OrderType.php
namespace AppBundle\Form\Type;
Expand Down
7 changes: 3 additions & 4 deletions form/data_transformers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ Harder Example: Transforming an Issue Number into an Issue Entity
Say you have a many-to-one relation from the Task entity to an Issue entity (i.e. each
Task has an optional foreign key to its related Issue). Adding a listbox with all
possible issues could eventually get *really* long and take a long time to load.
Instead, you decide you want to add a textbox, where the user can simply enter the
issue number.
Instead, you decide you want to add a textbox, where the user can enter the issue number.

Start by setting up the text field like normal::

Expand Down Expand Up @@ -300,9 +299,9 @@ know to pass your ``TaskType`` an instance of the ``IssueToNumberTransformer``.
For more information about defining form types as services, read
:doc:`register your form type as a service </form/form_dependencies>`.

Now, you can easily use your ``TaskType``::
Now, you can use your ``TaskType``::

// e.g. in a controller somewhere
// e.g. somewhere in a controller
$form = $this->createForm(TaskType::class, $task);

// ...
Expand Down
3 changes: 1 addition & 2 deletions form/direct_submit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
How to Use the submit() Function to Handle Form Submissions
===========================================================

With the ``handleRequest()`` method, it is really easy to handle form
submissions::
Handle the form submission with the ``handleRequest()`` method::

use Symfony\Component\HttpFoundation\Request;
// ...
Expand Down
3 changes: 1 addition & 2 deletions form/dynamic_form_modification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,7 @@ Using an event listener, your form might look like this::
The problem is now to get the current user and create a choice field that
contains only this user's friends.

Luckily it is pretty easy to inject a service inside of the form. This can be
done in the constructor::
The service can be injected into the form via its constructor::

use Symfony\Component\Security\Core\Security;
// ...
Expand Down
4 changes: 2 additions & 2 deletions form/embedded.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ How to Embed Forms

Often, you'll want to build a form that will include fields from many different
objects. For example, a registration form may contain data belonging to
a ``User`` object as well as many ``Address`` objects. Fortunately, this
is easy and natural with the Form component.
a ``User`` object as well as many ``Address`` objects. Fortunately this can
be achieved by the Form component.

.. _forms-embedding-single-object:

Expand Down
Loading