Skip to content

Updated the Best Practices for Symfony 4 and Flex #8599

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

Merged
merged 4 commits into from
Nov 12, 2017

Conversation

javiereguiluz
Copy link
Member

@javiereguiluz javiereguiluz commented Nov 7, 2017

Still WIP. Some chapters have not been reviewed yet.

Copy link
Member

@yceruto yceruto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! :)

Probably the section "Template Locations" needs changes too.

yield ['/post/fixture-post-1'];
yield ['/blog/category/fixture-category'];
yield ['/archives'];
yield [.];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yield [.] => // ...?

@javiereguiluz javiereguiluz changed the title (WIP) Updated the Best Practices for Symfony 4 and Flex Updated the Best Practices for Symfony 4 and Flex Nov 8, 2017
@javiereguiluz
Copy link
Member Author

javiereguiluz commented Nov 8, 2017

This is now ready for review. Here is the list of added/removed/changed best practices:

Added

  • Use the Symfony Skeleton to create new Symfony-based projects.
  • Use autowiring to automate the configuration of application services.
  • Don't add the Action suffix to the methods of the controller actions.

Removed

  • Don't define parameters for the classes of your services.
  • Create only one bundle called AppBundle for your application logic.

Changed

-Use the Symfony Installer to create new Symfony-based projects.
+Use Composer and Symfony Flex to create and manage Symfony applications.
-Make your controller extend the FrameworkBundle base controller...
+Make your controller extend the ``AbstractController`` base controller...
-Store the translation files in the ``app/Resources/translations/`` directory.
+Store the translation files in the ``translations/`` directory at the root of your project.
-Store all your application's templates in ``app/Resources/views/`` directory.
+Store the application templates in the ``templates/`` directory at the root of your project.
-Define your Twig extensions in the ``AppBundle/Twig/`` directory.
+Define your Twig extensions in the ``src/Twig/`` directory.
-Store your assets in the ``public/`` directory.
+Store your assets in the ``assets/`` directory at the root of your project.
-Use Assetic to compile, combine and minimize web assets, unless you're
-comfortable with frontend tools like GruntJS.
+Use `Webpack Encore`_ to compile, combine and minimize web assets.
-For fine-grained restrictions, define a custom security voter;
-For restricting access to *any* object by *any* user via an admin
-interface, use the Symfony ACL.
+Define a custom security voter to implement fine-grained restrictions.

@xabbuh xabbuh added this to the 4.0 milestone Nov 8, 2017
:doc:`Service autowiring </service_container/autowiring>` is a feature provided
by Symfony's Service Container to manage services with minimal configuration.
It reads the type-hints on your constructor (or other methods) and automatically
passes you the correct services. It can also add :doc:`service tags </service_container/tags>`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It passes the correct services to the methods, not 'you'.

the class is auto-registered as a service.
If you're using the :ref:`default services.yaml configuration <service-container-services-load-example>`,
this class is auto-registered as a service whose ID is ``App\Utils\Slugger`` (or
simply ``Slugger::class`` if the class is already imported in your code).

Traditionally, the naming convention for a service was a short, but unique
snake case key - e.g. ``app.utils.slugger``. But for most services, you should now
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this paragraph.

Use Composer and Symfony Flex to create and manage Symfony applications.

`Composer`_ is the package manager used by modern PHP application to manage their
dependencies. `Symfony Flex`_ is a Composer plugin designed to automatize some
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

automate?

`public checksums repository`_ and follow `these steps`_ to verify the
signatures.
The technical requirements to run Symfony are simple. If you want to check
if your system meets those requirements, read :doc:`/reference/requirements`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about recommending using the req-checker for that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree! The linked article (https://symfony.com/doc/master/reference/requirements.html) was revamped recently to remove everything and just explain how to use req-checker.

weaverryan added a commit that referenced this pull request Nov 10, 2017
This PR was merged into the 3.3 branch.

Discussion
----------

Minor reword in autowiring introduction

I used this in the reword of the Best Practices docs and Fabien [added this comment](#8599 (comment)) because he didn't like a phrase of this paragraph. This PR changes that too here.

Commits
-------

c84cff8 Minor reword in autowiring introduction
Copy link
Member

@wouterj wouterj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff!

@weaverryan
Copy link
Member

This is huge work Javier. THANK YOU!!!

@weaverryan weaverryan merged commit 335e461 into symfony:master Nov 12, 2017
weaverryan added a commit that referenced this pull request Nov 12, 2017
…ereguiluz)

This PR was squashed before being merged into the master branch (closes #8599).

Discussion
----------

Updated the Best Practices for Symfony 4 and Flex

Still WIP. Some controllers have not been reviewed yet.

Commits
-------

335e461 Fixed after Fabien's review
68b7a18 Fixed some missing references
9794c0b Updated more contents
b997c1e Updated the Best Practices for Symfony 4 and Flex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants