Quantcast
Channel: Symfony Blog
Viewing all 3103 articles
Browse latest View live

New in Symfony 3.3: WebLink component

$
0
0
Kévin Dunglas

Contributed by
Kévin Dunglas
in #22273.

A few weeks ago, we added support for asset preloading with HTTP/2 Push. The feedback was so enthusiastic that we decided to improve and expand this feature. In fact, we decided to create a whole new component for it: WebLink.

This new component manages links between resources, not only assets; advising browsers to preload and prefetch resources through HTTP and HTTP/2 pushes. The component implements these specifications: HTML5 Links, Preload, andResource Hints

All these new features can be used via several Twig functions:

  • link(), adds the Link HTTP header;
  • preload(), preload resources (not only assets);
  • dns_prefetch(), resolves a resource origin as early as possible;
  • preconnect(), initiates a early connection to a resource (including DNS resolution, TCP handshake, and TLS negotiation);
  • prefetch(), indicates to the client that it should prefetch the given resource;
  • prerender(), indicates to the client that it should prerender the given resource.

Unlike the previous preloading feature, this component is not only useful for web assets. Being a standalone component means that it can also be used for example to replace resource embedding by HTTP/2 pushes in your APIs.


Be trained by Symfony experts - 2017-05-02 Paris - 2017-05-02 Paris - 2017-05-04 Paris

A week of symfony #538 (17-23 April 2017)

$
0
0

This week, the upcoming Symfony 3.3 version introduced the "autoconfigure" option for automatic configuration of "_instanceof". Meanwhile, Symfony Flex continued unveiling some of its features, such as recipes from the community and opening the main and contrib recipe repositories.

Symfony development highlights

2.7 changelog:

  • bc6128b: folded Travis CI output by component

3.2 changelog:

  • c9a614e: [VarDumper] minor tweaks to html/css dumps

Master changelog:

  • 9296a10: [HttpKernel] fixed identifier in request data collector
  • b72c11f: [Form] renamed getTypedExtensions() to getTypeExtensions
  • 86dbbde: [Workflow] deprecated the default type of a workflow
  • 6c7bced: [Security] allowed to set a check_path on json_login listener
  • 610a238: [HttpKernel] fixed deprecation of Extension::addClassesToCompile() / AddClassesToCachePass
  • df155dd: [SecurityBundle] conditionally register user checker FQCN alias
  • 9c0067b: [Console] fixed fatal error when logging console.error without command
  • f9bb4dc: [DependencyInjection] reduced memory overhead of id normalization
  • ad86e2d: Persist app bootstrapping logs for logger datacollector
  • f730ffa: [DependencyInjection] introducing "autoconfigure" option for automatic _instanceof configuration

Newest issues and pull requests

Twig development highlights

Master changelog:

  • 0db54be: fixed edge case in the method cache for Twig attributes

SwiftMailer development highlights

Master changelog:

  • fca6ebc: avoid clobbering bcmath scale in NTLMAuthenticator

They talked about us


Be trained by Symfony experts - 2017-05-02 Paris - 2017-05-02 Paris - 2017-05-04 Paris

New in Symfony 3.3: Persisted deprecation logs

$
0
0
Thomas PerezNicolas Grekas

Contributed by
Thomas Perez andNicolas Grekas
in #21502.

Backward compatibility promise is one of the best features of Symfony. This promise ensures that your applications will always work when upgrading them using the same Symfony branch (e.g. an app using Symfony 3.0 will work when upgrading Symfony to 3.1, 3.2, 3.3 and 3.4).

The key of the backward compatibility promise are the deprecation messages. Whenever you use a feature that will be changed or removed in the next versions of Symfony, you get a log message warning you about this and providing alternative solutions. For example, this image shows the Web Debug Toolbar warning you about five deprecation messages:

However, some of those deprecation messages are only generated during the compilation of the service container. That's why they disappear if you reload the page and they only appear again if you delete the cache to force a new compilation of the container.

In Symfony 3.3 we decided to fix this problem and now all deprecation messages are persisted. No matter if they were generated during the compilation phase or while serving the request. The Web Debug Toolbar and the Profiler now always display all the deprecation messages:

In addition to persisting the deprecation messages, Symfony 3.3 will also display the full logs generated during the compilation phase. You don't usually need to care about those messages, but they can help you with hard to debug issues:


Be trained by Symfony experts - 2017-05-02 Paris - 2017-05-02 Paris - 2017-05-04 Paris

New in Symfony 3.3: Service autoconfiguration

$
0
0
Ryan Weaver

Contributed by
Ryan Weaver
in #22234.

In Symfony 3.3, configuring services is much simpler thanks to these new configuration options:

  • _defaults: defines the default value for the public, tags andautowire options of the services defined in a given file;
  • _instanceof: defines the default configuration of services depending on their classes (e.g. add the twig.extension tag to any service that implements Twig_ExtensionInterface).

The evolution of this simplification is the new autoconfigure option, which is like an automated version of _instanceof. If enabled, this option adds some default configuration depending on the class implemented by the service.

Let's suppose that you want to add tags automatically to your security voters:

1
2
3
4
5
6
7
8
9
services:_defaults:autowire:true_instanceof:Symfony\Component\Security\Core\Authorization\Voter\VoterInterface:tags:[security.voter]AppBundle\Security\PostVoter:~

Now ask yourself: if you are registering a service with a class that implementsVoterInterface, when would you ever not want that to be tagged withsecurity.voter? In other words, a service implementing VoterInterface can only be a security voter, unless you are doing some seriously weird things.

The same example using autoconfigure looks like this:

1
2
3
4
5
6
services:_defaults:autowire:trueautoconfigure:trueAppBundle\Security\PostVoter:~

This works because each enabled bundle has the opportunity to add one or more automated _instanceof definitions. Of course we've already enabled this for all the common Symfony services: commands, form types, event subscribers, etc.

It's not magic

Whenever we introduce a new feature to automatize the configuration of services, some developers quickly discredit it for being "magic". For us, "magic" means that something happened without you explicitly asking for it. Magic is bad because it leads to WTF moments and hard-to-debug issues.

However, this feature won't work unless you explicitly include theautoconfigure option in your configuration file. Besides, it only applies to the services defined in the same file where you include autoconfigure, so there will be no side-effects. In short, this is not magic, just automation.


Be trained by Symfony experts - 2017-05-09 Paris - 2017-05-15 Cologne - 2017-05-15 Cologne

A week of symfony #539 (24-30 April 2017)

$
0
0

This week Symfony continued fixing and polishing the new features introduced for Symfony 3.3, like the use of autoconfigure or defaults for ChildDefinition ,improving the way command services are registered and allowing to pass CSV encoder options in context. In addition, a Symfony Flex screencast was published to showcase how easy can API applications be developed with Flex.

Symfony development highlights

2.7 changelog:

  • 93b7530: [Serializer] fixed negative int and large numbers handling in XmlEncoder
  • 81f48b8: [Console] fixed dispatching throwables from ConsoleEvents::COMMAND
  • fc1fe8d: [Asset] preventing the base path or absolute URL from being prefixed incorrectly
  • c669b88: [Asset] starting slash should indicate no basePath wanted

2.8 changelog:

  • 76dd7b0: [WebProfilerBundle] improved the profiler design to avoid flickering
  • e9e4c79: [EventDispatcher] fixed unwrapping listeners to get their priorities
  • 04e48bd: [VarDumper] added missing iconv dependency
  • 07fc060: [Serializer] allowed Upper Case property names in ObjectNormalizer

3.2 changelog:

  • 2145f56: [Console] fixed bar width with multilines ProgressBar's format

Master changelog:

  • 3d4b212: [Security] fixed json_login default success/failure handling
  • 3471b58: [DependencyInjection] fixed inlining conflict by restricting IteratorArgument to Reference[]
  • 11ac234: [DotEnv] don't override existing $_SERVER vars
  • b9ee33f: [DependencyInjection] allowed service subscribers to leverage autowiring to know where their locator should be injected
  • d696b39: [Cache] keep only hit/miss (not values) in TraceableAdapter/Cache
  • 8974b52: [FrameworkBundle] removed deprecated session listener from class compilation
  • 143b5ff: [TwigBundle] fixes twig bundle project root dir discovery
  • ceabf11: [DependencyInjection] fixed problem where _defaults set to null was seen as a service
  • 8806628: [Console, HttpKernel] avoid reflection-based registration for command public services
  • 89979ca: [DependencyInjection] not allowing autoconfigure, instanceofConditionals or defaults for ChildDefinition
  • 288d55f: [Process] ecaping of CLI arguments containing slashes on Windows
  • 460fcbf: [Security] handled bad request format in json auth listener
  • 1cef186: [Serializer] allowed to pass csv encoder options in context
  • 8872833: [DependencyInjection] throw useful exception on bad XML argument tags

Newest issues and pull requests

They talked about us


Be trained by Symfony experts - 2017-05-09 Paris - 2017-05-15 Cologne - 2017-05-15 Cologne

Symfony 2.7.27 released

$
0
0

Symfony 2.7.27 has just been released. Here is a list of the most important changes:

  • bug #22528 [Asset] Starting slash should indicate no basePath wanted (@weaverryan)
  • bug #22526 [Asset] Preventing the base path or absolute URL from being prefixed incorrectly (@weaverryan)
  • bug #22435 [Console] Fix dispatching throwables from ConsoleEvents::COMMAND (@nicolas-grekas)
  • bug #22478 [Serializer] XmlEncoder: fix negative int and large numbers handling (@dunglas)
  • bug #22424 [Debug] Set exit status to 255 on error (@nicolas-grekas)
  • bug #22396 Prevent double registrations related to tag priorities (@nicolas-grekas)
  • bug #22352 [HttpFoundation] Add use_strict_mode in validOptions for session (@sstok)
  • bug #22351 [Yaml] don't keep internal state between parser runs (@xabbuh)
  • bug #22307 [Debug] Fix php notice (@enumag)
  • bug #22109 [Validator] check for empty host when calling checkdnsrr() (@apetitpa)
  • bug #22280 [DI] Fix the xml schema (@GuilhemN)
  • bug #22255 [Translation] avoid creating cache files for fallback locales. (@aitboudad)
  • bug #22292 Fixes #22264 - add support for Chrome headless (@redthor)

Want to upgrade to this new release? Fortunately, because Symfony protects backwards-compatibility very closely, this should be quite easy.Read our upgrade documentation to learn more.

Want to be notified whenever a new Symfony release is published? Or when a version is not maintained anymore? Or only when a security issue is fixed? Consider subscribing to the Symfony Roadmap Notifications.


Be trained by Symfony experts - 2017-05-09 Paris - 2017-05-15 Cologne - 2017-05-15 Cologne

Symfony 2.8.20 released

$
0
0

Symfony 2.8.20 has just been released. Here is a list of the most important changes:

  • bug #22550 Allow Upper Case property names in ObjectNormalizer (@insekticid)
  • bug #22528 [Asset] Starting slash should indicate no basePath wanted (@weaverryan)
  • bug #22541 [EventDispatcher] fix: unwrap listeners for correct info (@dmaicher)
  • bug #22526 [Asset] Preventing the base path or absolute URL from being prefixed incorrectly (@weaverryan)
  • bug #22523 [WebProfilerBundle] Fixed the flickering when loading complex profiler panels (@javiereguiluz)
  • bug #22435 [Console] Fix dispatching throwables from ConsoleEvents::COMMAND (@nicolas-grekas)
  • bug #22478 [Serializer] XmlEncoder: fix negative int and large numbers handling (@dunglas)
  • bug #22424 [Debug] Set exit status to 255 on error (@nicolas-grekas)
  • bug #22426 [PropertyInfo] Prevent returning int values in some cases (@dunglas)
  • bug #22399 Prevent double registrations related to tag priorities (@nicolas-grekas)
  • bug #22396 Prevent double registrations related to tag priorities (@nicolas-grekas)
  • bug #22352 [HttpFoundation] Add use_strict_mode in validOptions for session (@sstok)
  • bug #22351 [Yaml] don't keep internal state between parser runs (@xabbuh)
  • bug #22307 [Debug] Fix php notice (@enumag)
  • bug #22311 [DI] Fix second auto-registration (@nicolas-grekas)
  • bug #22109 [Validator] check for empty host when calling checkdnsrr() (@apetitpa)
  • bug #22280 [DI] Fix the xml schema (@GuilhemN)
  • bug #22282 [DI] Prevent AutowirePass from triggering irrelevant deprecations (@chalasr)
  • bug #22255 [Translation] avoid creating cache files for fallback locales. (@aitboudad)
  • bug #22292 Fixes #22264 - add support for Chrome headless (@redthor)

Want to upgrade to this new release? Fortunately, because Symfony protects backwards-compatibility very closely, this should be quite easy.Read our upgrade documentation to learn more.

Want to be notified whenever a new Symfony release is published? Or when a version is not maintained anymore? Or only when a security issue is fixed? Consider subscribing to the Symfony Roadmap Notifications.


Be trained by Symfony experts - 2017-05-09 Paris - 2017-05-15 Cologne - 2017-05-15 Cologne

Symfony 3.2.8 released

$
0
0

Symfony 3.2.8 has just been released. Here is a list of the most important changes:

  • bug #22550 Allow Upper Case property names in ObjectNormalizer (@insekticid)
  • bug #22528 [Asset] Starting slash should indicate no basePath wanted (@weaverryan)
  • bug #22568 [EventDispatcher] fix getting priorities of listeners during dispatch (@dmaicher)
  • bug #22541 [EventDispatcher] fix: unwrap listeners for correct info (@dmaicher)
  • bug #22526 [Asset] Preventing the base path or absolute URL from being prefixed incorrectly (@weaverryan)
  • bug #22523 [WebProfilerBundle] Fixed the flickering when loading complex profiler panels (@javiereguiluz)
  • bug #21958 [Console] Fix bar width with multilines ProgressBar's format (@maidmaid)
  • bug #22435 [Console] Fix dispatching throwables from ConsoleEvents::COMMAND (@nicolas-grekas)
  • bug #22478 [Serializer] XmlEncoder: fix negative int and large numbers handling (@dunglas)
  • bug #22424 [Debug] Set exit status to 255 on error (@nicolas-grekas)
  • bug #22426 [PropertyInfo] Prevent returning int values in some cases (@dunglas)
  • bug #22401 Prevent double registrations related to tag priorities (@nicolas-grekas)
  • bug #22399 Prevent double registrations related to tag priorities (@nicolas-grekas)
  • bug #22396 Prevent double registrations related to tag priorities (@nicolas-grekas)
  • bug #22374 [Cache] Remove exception false-positive from FilesystemAdapterTrait (@nicolas-grekas)
  • bug #22377 [Console] Allow terminal dimensions to be set to 0 (unbounded) (@duncan3dc)
  • bug #22352 [HttpFoundation] Add use_strict_mode in validOptions for session (@sstok)
  • bug #22351 [Yaml] don't keep internal state between parser runs (@xabbuh)
  • bug #22304 Moved $this->setDate() before the deprecation handling. (@mpdonadio)
  • bug #22307 [Debug] Fix php notice (@enumag)
  • bug #22311 [DI] Fix second auto-registration (@nicolas-grekas)
  • bug #22109 [Validator] check for empty host when calling checkdnsrr() (@apetitpa)
  • bug #22280 [DI] Fix the xml schema (@GuilhemN)
  • bug #22282 [DI] Prevent AutowirePass from triggering irrelevant deprecations (@chalasr)
  • bug #22255 [Translation] avoid creating cache files for fallback locales. (@aitboudad)
  • bug #22292 Fixes #22264 - add support for Chrome headless (@redthor)

Want to upgrade to this new release? Fortunately, because Symfony protects backwards-compatibility very closely, this should be quite easy.Read our upgrade documentation to learn more.

Want to be notified whenever a new Symfony release is published? Or when a version is not maintained anymore? Or only when a security issue is fixed? Consider subscribing to the Symfony Roadmap Notifications.


Be trained by Symfony experts - 2017-05-09 Paris - 2017-05-15 Cologne - 2017-05-15 Cologne

Symfony 3.3.0-BETA1 released

$
0
0

Symfony 3.3.0-BETA1 has just been released. Here is a list of the most important changes:

  • feature #22530 Making tags under _defaults always apply (@weaverryan)
  • feature #22590 [Lock] remove the component from 3.3 (@fabpot)
  • feature #22527 [DI] Throw useful exception on bad XML argument tags (@nicolas-grekas)
  • feature #22537 [Serializer] Allow to pass csv encoder options in context (@ogizanagi)
  • feature #22563 Not allowing autoconfigure, instanceofConditionals or defaults for ChildDefinition (@weaverryan)
  • feature #22441 [Console] Review console.ERROR related behavior (@nicolas-grekas)
  • feature #22234 [DI] Introducing autoconfigure: automatic _instanceof configuration (@weaverryan)
  • feature #21502 Persist app bootstrapping logs for logger datacollector (@ScullWM, @nicolas-grekas)
  • feature #22459 [HttpKernel] Fix deprecation of Extension::addClassesToCompile() / AddClassesToCachePass (@nicolas-grekas)
  • feature #22416 [FrameworkBundle][Workflow] Deprecate the default type of a workflow (@lyrixx)
  • feature #22313 [Workflow] Move ValidateWorkflowsPass to the Workflow component (@chalasr)
  • feature #22420 [DI] Make tagged abstract services throw earlier (@nicolas-grekas)
  • feature #22384 [DI] Replace autowiring BC break by regular deprecation (@nicolas-grekas)
  • feature #22383 added a more specialized exception for a better error message (@fabpot)
  • feature #22356 [DI] Rework config hierarchy: defaults > instanceof > service config (@weaverryan, @nicolas-grekas)
  • feature #22362 [DI] Populate class of ChildDefinition when its id matches an existing FQCN (@nicolas-grekas)
  • feature #22239 [Finder] Glob wildcard while using double-star without ending slash (@sroze)
  • feature #22273 Add a new Link component (@dunglas)
  • feature #22315 Add Kernel::getProjectDir() (@fabpot)
  • feature #22314 [HttpKernel][FrameworkBundle] Dump container logs in Kernel, to have them also on errors (@nicolas-grekas)
  • feature #22316 [WebServerBundle] added a way to dump current status host/port/address when getting the status (@fabpot)
  • feature #22323 [DI] Report cascades of autowiring error messages (@nicolas-grekas)
  • feature #22306 [DI] Restrict autowired registration to "same-vendor" namespaces (@nicolas-grekas)
  • feature #22295 [BC BREAK][DI] Always autowire "by id" instead of using reflection against all existing services (@nicolas-grekas)
  • feature #20951 Redesigned the exception pages (@javiereguiluz)
  • feature #21919 [Form] Deprecated usage of "choices" option in sub types (@HeahDude)
  • feature #22274 [Yaml] report deprecations when linting YAML files (@xabbuh)
  • feature #22286 [DI/Yaml] Remove @experimental flag from "instanceof" and "prototype" (@nicolas-grekas)
  • feature #22181 [Console] Allow to catch CommandNotFoundException (@chalasr)
  • feature #22296 Bump monolog to 1.19 and use the agent regex const from parent (@redthor)
  • feature #21437 [Security] Use IteratorArgument for voters (@jvasseur)
  • feature #22277 [DI] Add "factory" support to named args and autowiring (@nicolas-grekas)
  • feature #22276 [FrameworkBundle] Returns the kernel instance in KernelTestCase::bootKernel (@lyrixx)
  • feature #22256 [DI] Reduce complexity of autowiring (@nicolas-grekas)
  • feature #22238 [BC BREAK][HttpFoundation] Request::setTrustedProxies() takes a new required $trustedHeaderSet argument (@nicolas-grekas)
  • feature #22175 [DI] add ServiceLocatorTagPass::register() to share service locators (@nicolas-grekas)
  • feature #22180 [Workflow] Added 'workflow_marked_places' twig function (@lyrixx)
  • feature #22185 [DI] Enhance DX by throwing instead of triggering a deprecation notice (@nicolas-grekas)
  • feature #22060 [DI] Add "by-id" autowiring: a side-effect free variant of it based on the class<>id convention (@nicolas-grekas)
  • feature #22158 Revert "feature #20973 [DI] Add getter injection (nicolas-grekas)" (@nicolas-grekas)
  • feature #22157 [FrameworkBundle] Introduce AbstractController, replacing ControllerTrait (@nicolas-grekas)
  • feature #22046 [Asset] Adding a new version strategy that reads from a manifest JSON file (@weaverryan)
  • feature #22129 [WebProfilerBundle] Improve cache panel (@ro0NL)
  • feature #21819 [Twig Bridge] A simpler way to retrieve flash messages (@javiereguiluz)
  • feature #19026 [Security] Strengthen comparison of target_url vs login_path (@mrzard)
  • feature #19496 [DX][Form][Validator] Add ability check if cocrete constraint fails. (@Koc)
  • feature #18140 [Console] Add console.ERROR event and deprecate console.EXCEPTION (@wouterj)
  • feature #22120 [FrameworkBundle] Multiple services on one Command class (@SenseException)
  • feature #21771 [FrameworkBundle] Add new "controller.service_arguments" tag to inject services into actions (@nicolas-grekas)
  • feature #22114 [lock] Rename Quorum into Strategy (@jderusse)
  • feature #20516 [Security][SecurityBundle] Enhance automatic logout url generation (@ogizanagi)
  • feature #22081 [FrameworkBundle][Validator] Move Validator passes to the component (@chalasr)
  • feature #20567 [WebProfilerBundle] Improved cookie traffic (@ro0NL)
  • feature #19887 Sort alternatives alphabetically when a command is not found (@javiereguiluz)
  • feature #20851 [Cache] Add CacheItem::getPreviousTags() (@nicolas-grekas)
  • feature #21830 [HttpFoundation] Add $trustedHeaderSet arg to Request::setTrustedProxies() - deprecate not setting it (@nicolas-grekas)
  • feature #21924 [FrameworkBundle] Allow to configure Serializer mapping paths (@chalasr)
  • feature #19278 [FrameworkBundle] Added about command (@ro0NL)
  • feature #21708 [DI] Add and wire ServiceSubscriberInterface - aka explicit service locators (@nicolas-grekas)
  • feature #22011 [FrameworkBundle][Serializer] Add option to register a circular_reference_handler (@lyrixx)
  • feature #19673 [DI] Deprecate Container::isFrozen and introduce isCompiled (@ro0NL)
  • feature #19954 [Console] Exclude empty namespaces in text descriptor (@ro0NL)
  • feature #21093 [Lock] Create a lock component (@jderusse)
  • feature #21007 [WebProfilerBundle] Improve AJAX toolbar panel (@ro0NL)
  • feature #20642 [FrameworkBundle] Add project directory default for installing assets (@Noah Heck)
  • feature #20365 [TwigBridge] Handle form label attributes like others (@ro0NL)
  • feature #22010 [FrameworkBundle][Translator] Make the Translator works with any PSR-11 container (@chalasr)
  • feature #21038 [FrameworkBundle] deprecated cache:clear with warmup (@fabpot)
  • feature #22098 [Bundle] Add autowiring aliases for common services (@nicolas-grekas)
  • feature #22095 [DI] Add logging and better failure recovery to AutowirePass (@nicolas-grekas)
  • feature #21889 Deprecate the special SYMFONY environment variables (@javiereguiluz)
  • feature #22059 [Yaml] deprecate "? " starting unquoted strings (@xabbuh)
  • feature #22030 [DI] Remove skipping magic for autowired methods (@nicolas-grekas)
  • feature #22024 [DI] Introduce "container.service_locator" tag, replaces ServiceLocatorArgument (@nicolas-grekas)
  • feature #21837 [FrameworkBundle] Lazy configuration of annotations' loader and @required (@nicolas-grekas)
  • feature #21970 [DependencyInjection] Support anonymous services in Yaml (@GuilhemN)
  • feature #21979 [FrameworkBundle][TwigBundle] Require PSR-11 container instead of Symfony container (@enumag)
  • feature #21935 [FrameworkBundle][Workflow] Add a way to register a guard expression in the configuration (@lyrixx)
  • feature #21080 [FrameworkBundle][Monolog] Added a new way to follow logs (@lyrixx)
  • feature #21978 [DoctrineBridge][Routing] Require PSR-11 container instead of Symfony container (@enumag)
  • feature #21950 [Workflow] Added fluent interface to the DefinitionBuilder (@lyrixx)
  • feature #21933 [FrameworkBundle][Workflow] Add a way to enable the AuditTrail Logger (@lyrixx)
  • feature #21925 [Workflow] Added the workflow name to all events dispatched (@lyrixx)
  • feature #21774 [Yaml] deprecate implicit string casting of mapping keys (@xabbuh)
  • feature #21780 [DX] [Form] Add helper method to register form extensions during unit testing (@pierredup)
  • feature #21842 [HttpKernel] Allow signing URIs with a custom query string parameter (@thewilkybarkid)
  • feature #21705 [Bridge/Monolog] Enhance the Console Handler (@lyrixx)
  • feature #21893 Added a castToArray() config helper (@javiereguiluz)
  • feature #21421 Use proper error message when session write fails #20807 (@digilist)
  • feature #21770 [DI] Allow extensions to create ServiceLocator as services (@nicolas-grekas)
  • feature #21767 [DI][Router][DX] Invalidate routing cache when container parameters changed (@ogizanagi)
  • feature #21835 [FrameworkBundle][Routing] Move RoutingResolverPass to the Routing component (@chalasr)
  • feature #21815 [FrameworkBundle][HttpKernel] Move ControllerArgumentValueResolverPass to the HttpKernel component (@chalasr)
  • feature #21824 Add deprecation note on routing class parameters (@lepiaf)
  • feature #21854 [Router] Follow symlinks and skip dots in the annotation directory loader (@jakzal)
  • feature #18193 [FrameworkBundle] Introduce autowirable ControllerTrait (@dunglas)
  • feature #20680 DoctrineDataCollector: taught sanitizeParam to support classes with toString implemented. (@FractalizeR)
  • feature #21828 [PhpUnitBridge] include expected deprecations in assertion counter (@xabbuh)
  • feature #21763 [DI] Replace wildcard-based methods autowiring by @required annotation (@nicolas-grekas)
  • feature #21730 [DependencyInjection] Use a service locator in AddConstraintValidatorsPass (@GuilhemN)
  • feature #21118 [Yaml] parse omitted inlined mapping values as null (@xabbuh)
  • feature #21806 [FrameworkBundle][PropertyInfo] Move PropertyInfoPass to the PropertyInfo component (@chalasr)
  • feature #19822 [HttpKernel] Deprecate X-Status-Code for better alternative (@jameshalsall)
  • feature #21228 [Console] Explicitly passed options without value (or empty) should remain empty (@chalasr)
  • feature #21723 [Routing][DX] Add full route definition for invokable controller/class (@yceruto)
  • feature #21768 [HttpKernel] Add a ContainerControllerResolver (psr-11) (@ogizanagi)
  • feature #21690 [Form] allow form types + form type extensions + form type guessers to be private services (@hhamon)
  • feature #21755 [Routing] Optimised dumped router matcher, prevent unneeded function calls. (@frankdejonge)
  • feature #21375 [FrameworkBundle][Config] Move ConfigCachePass from FrameworkBundle to Config (@Deamon)
  • feature #21786 [PhpUnitBridge] testing for deprecations is not risky (@xabbuh)
  • feature #21792 [Security] deprecate multiple providers in context listener (@xabbuh)
  • feature #21625 Remove some container injections in favor of service locators (@nicolas-grekas, @chalasr)
  • feature #21539 Introduce weak vendors mode (@greg0ire)
  • feature #21638 [VarDumper] Allow seamless use of Data clones (@nicolas-grekas)
  • feature #21164 [HttpKernel] Added the SessionValueResolver (@iltar)
  • feature #21718 [SecurityBundle] Don't normalize username of in-memory users (@chalasr)
  • feature #20107 Added a build method to the kernel to replace Bundle::build() (@iltar)
  • feature #21694 [Bridge/PhpUnit] Add PHPUnit 6 support (@nicolas-grekas)
  • feature #21122 [ExpressionLanguage] Create an ExpressionFunction from a PHP function name (@maidmaid)
  • feature #21653 [VarDumper] Added a way to print or not comma separator and/or trailing comma (@lyrixx)
  • feature #21471 [Yaml] Allow dumping empty array as YAML sequence (@c960657)
  • feature #21478 [Asset] Add support for preloading with links and HTTP/2 push (@dunglas)
  • feature #20632 [FrameworkBundle] Make use of stderr for non reliable output (@chalasr, @ogizanagi)
  • feature #21664 [Console] simplify the implementation of SymfonyStyle::comment() (@fabpot)
  • feature #21578 [Translation] Added a lint:xliff command for XLIFF files (@javiereguiluz)
  • feature #21635 added support for glob loaders in Config (@fabpot)
  • feature #21654 [PropertyInfo] Use iterators for PropertyInfoExtractor (@GuilhemN)
  • feature #21655 [PropertyInfo] Make classes final (@GuilhemN)
  • feature #21530 [DependencyInjection] Add "instanceof" section for local interface-defined configs (@nicolas-grekas, @dunglas)
  • feature #21643 [Yaml] deprecate parsing mappings without keys (@xabbuh)
  • feature #20677 [DX][SecurityBundle] UserPasswordEncoderCommand: ask user class choice question (@ogizanagi)
  • feature #21283 [Form][FrameworkBundle] Move FormPass to the Form component (@chalasr)
  • feature #21293 [FrameworkBundle][Serializer] Move SerializerPass to the Serializer (@chalasr)
  • feature #21450 [Security] Lazy load guard authenticators and authentication providers (@chalasr)
  • feature #21484 [DI] Deprecate underscore-services in YamlFileLoader (@nicolas-grekas)
  • feature #21270 [DependencyInjection] Use glob pattern to load config files (@pierredup)
  • feature #19815 [WebProfilerBundle] Make the IP address in the profiler header clickable (@jameshalsall)
  • feature #21383 [DependencyInjection] Add support for named arguments (@dunglas, @nicolas-grekas)
  • feature #19371 [Serializer] Give access to the context to support methods (@dunglas)
  • feature #21553 [DI] Replace container injection by explicit service locators (@chalasr)
  • feature #18834 [Serializer] Add the possibility to filter attributes (@dunglas)
  • feature #20787 [Workflow] Added an entered event (@Padam87)
  • feature #21289 [DI] Add prototype services for PSR4-based discovery and registration (@nicolas-grekas)
  • feature #21465 [Debug] Support @final on methods (@GuilhemN)
  • feature #21505 [Config][DI] Add ComposerResource to track the runtime engine + deps (@nicolas-grekas)
  • feature #21533 [DI] Deprecate (un)setting pre-defined services (@ro0NL)
  • feature #21194 [Yaml] Add tags support (@GuilhemN)
  • feature #21460 [DI] ContainerBuilder::compile() can optionally resolve env vars in parameter bag (@nicolas-grekas)
  • feature #21572 [Finder] Add double-star matching to Glob::toRegex() (@nicolas-grekas)
  • feature #21265 [DI] Implement PSR-11 (@greg0ire)
  • feature #21474 [Process] Accept command line arrays and per-run env vars, fixing signaling and escaping (@nicolas-grekas)
  • feature #21517 [FrameworkBundle] Add missing autowiring aliases for common interfaces (@chalasr)
  • feature #21516 [HttpKernel][FrameworkBundle] Lazy load argument value resolvers (@chalasr)
  • feature #21031 [DI] Getter autowiring (@dunglas)
  • feature #21419 [DI][Config] Add & use ReflectionClassResource (@nicolas-grekas)
  • feature #21455 [DI] Allow to count on lazy collection arguments (@ogizanagi)
  • feature #21408 [DI] Add ContainerBuilder::fileExists() for checking/tracking resource existence (@chalasr)
  • feature #21470 [Process] Deprecate not inheriting env vars + compat related settings (@nicolas-grekas)
  • feature #21494 [DI] Deprecate autowiring-types in favor of aliases (@nicolas-grekas)
  • feature #21451 [SecurityBundle] Lazy load request matchers in FirewallMap (@chalasr)
  • feature #20973 [DI] Add getter injection (@nicolas-grekas)
  • feature #21396 [DI] Enhance logging in compiler passes (@nicolas-grekas)
  • feature #21402 [Security] make LdapBindAuthenticationProvider capable of searching for the DN (@lsmith77, @nietonfir)
  • feature #21404 [DI] Generalize constructor autowiring to partial method calls (@nicolas-grekas)
  • feature #21388 [Debug] Deprecate ContextErrorException (@nicolas-grekas)
  • feature #20943 [DependencyInjection] Use current class as default class for factory declarations (@ogizanagi)
  • feature #21003 [Console][FrameworkBundle] Log console exceptions (@jameshalsall, @chalasr)
  • feature #21313 [DI] Add Yaml syntax for short services definition (@ogizanagi)
  • feature #20694 [Cache] Implement PSR-16 SimpleCache v1.0 (@nicolas-grekas)
  • feature #21327 [DI] Factorize compiler passes around new AbstractRecursivePass (@nicolas-grekas)
  • feature #19086 [FrameworkBundle] add "mapping" configuration key at validation secti… (@davewwww)
  • feature #21350 [Yaml] Remove internal arguments from the api (@GuilhemN)
  • feature #21353 [ClassLoader] Deprecated the component (@nicolas-grekas)
  • feature #21334 [Workflow] Introduce concept of SupportStrategyInterface (@andesk, @lyrixx)
  • feature #20390 [Ldap] added Ldap entry rename for ExtLdap adapter (@fruitwasp)
  • feature #21065 Added cache data collector and profiler page (@Nyholm)
  • feature #21306 [DependencyInjection] Always autowire the constructor (@dunglas)
  • feature #20493 [Debug] Trigger deprecation on @final annotation in DebugClassLoader - prepare making some classes final (@GuilhemN)
  • feature #21244 [DI] Remove synthetic services from methodMap + generated methods (@nicolas-grekas)
  • feature #21238 [VarDumper] Add search keyboard shortcuts (@ogizanagi)
  • feature #21290 [FrameworkBundle] Fix debug:container --show-arguments missing cases (@chalasr)
  • feature #21263 [DI] Mark generated containers as final (@nicolas-grekas)
  • feature #21253 [TwigBridge][Worklow] Added a new workflow_has_place function (@Padam87, @lyrixx)
  • feature #21234 Add a new Dotenv component (@fabpot)
  • feature #20861 Add a --show-arguments flag to the debug:container command (@Cydonia7)
  • feature #21223 [DI] Deprecate case insentivity of service identifiers (@nicolas-grekas)
  • feature #20887 [Form] DateIntervalType: Allow to configure labels & enhance form theme (@ogizanagi)
  • feature #19443 [Console] Move AddConsoleCommandPass from FrameworkBundle to Console. (@bcremer)
  • feature #21231 [FrameworkBundle] allow to reference files directly from kernel.root_dir (@fabpot)
  • feature #20611 [DI] FileLoaders: Allow to explicit type to load (@ogizanagi)
  • feature #20689 [Config][FrameworkBundle] Allow to dump extension config reference sub-path (@ogizanagi)
  • feature #21188 [HttpFoundation] Add FileStream for size-unknown BinaryFileResponse (@nicolas-grekas)
  • feature #21214 [DI] Allow ~ instead of {} for services in Yaml (@wouterj)
  • feature #20612 [Filesystem] Add appendToFile() (@chalasr)
  • feature #20612 [Filesystem] Add appendToFile() (@chalasr)
  • feature #21114 [Yaml] parse multi-line strings (@xabbuh)
  • feature #21196 [FrameworkBundle] changed some default configs from canBeEnabled to canBeDisabled (@fabpot)
  • feature #20937 [EventDispatcher] Deprecate ContainerAwareEventDispatcher (@nicolas-grekas)
  • feature #21190 [WebServerBundle] Decouple server commands from the container (@chalasr)
  • feature #21071 [DI] Add "inherit-tags" with configurable defaults + same for "public", "tags" & "autowire" (@nicolas-grekas, @ogizanagi)
  • feature #21133 [DI] Optional class for named services (@hason, @nicolas-grekas)
  • feature #20953 [DI][EventDispatcher] Add & wire closure-proxy argument type (@nicolas-grekas)
  • feature #20586 [Console] Ease writing to stderr using SymfonyStyle (@chalasr)
  • feature #20547 [FrameworkBundle] Allowed symlinks when searching for translation, searialization and validation files (@tifabien)
  • feature #20735 Deprecate ClassCollectionLoader and Kernel::loadClassCache (@dbrumann)
  • feature #21140 [PhpUnitBridge] deprecate the testLegacy test name prefix (@xabbuh)
  • feature #21109 [Profiler][VarDumper] Add a search feature to the HtmlDumper (@ogizanagi)
  • feature #21039 Web server bundle (@fabpot)
  • feature #20907 [DependencyInjection] Implement lazy collection type using generators (@tgalopin, @nicolas-grekas)
  • feature #21075 [Console] Show hidden commands in json & xml descriptors (@ogizanagi)
  • feature #21129 [FrameworkBundle] Display original definition for aliases in debug:container (@chalasr)
  • feature #21108 [Cache] Add DSN, createClient & better error reporting to MemcachedAdapter (@nicolas-grekas, @robfrawley)
  • feature #21147 [PhpUnitBridger] Bump simple-phpunit to PHPUnit 5.7 by default (@nicolas-grekas)
  • feature #21112 [PhpUnitBridge] run PHPUnit in the same process (@xabbuh)
  • feature #21106 [Validator] support DateTimeInterface instances for times (@xabbuh)
  • feature #20809 [FrameworkBundle] Display the controller class name in 'debug:router' (@lyrixx)
  • feature #21082 [Cache] TraceableAdapter (@Nyholm)
  • feature #20938 [DI] Prepare dropping "strict" handling in loaders (@nicolas-grekas)
  • feature #20971 [WebProfilerBundle] Split PHP version if needed (@ro0NL)
  • feature #20634 [DI] Deprecate dumping an uncompiled container (@ro0NL)
  • feature #20923 #20921 [Config] Provide shorthand methods for ArrayNodeDefinition::pr… (@skafandri)
  • feature #20569 [HttpFoundation] Create cookie from string + synchronize response cookies (@ro0NL)
  • feature #20618 [DI] Make ContainerBuilder::resolveEnvPlaceholders() able to inline the values of referenced env vars. (@nicolas-grekas)
  • feature #20962 Request exceptions (@thewilkybarkid, @fabpot)
  • feature #20928 [FrameworkBundle] don't load translator services if not required (@xabbuh)
  • feature #20644 [HttpFoundation] Compute cookie max-age attribute (@ro0NL)
  • feature #20167 [DependencyInjection] Make method (setter) autowiring configurable (@dunglas)
  • feature #20663 [DependencyInjection] replace DefinitionDecorator by ChildDefinition (@xabbuh)
  • feature #20197 [WebProfilerBundle] Improve Ajax Profiling Performance (javascript) (@patrick-mcdougle)
  • feature #20487 [Console] Disallow inheritance from ProgressBar (@a-ast)
  • feature #20651 [DependencyInjection] Added Yaml syntax shortcut for name-only tags (@wouterj)
  • feature #20648 [DependencyInjection] Added a shortcut method for autowired definitions (@wouterj)
  • feature #20697 Updated the "PHP config" panel in the profiler (@javiereguiluz)
  • feature #20773 [FrameworkBundle] Added GlobalVariables::getToken() (@HeahDude)
  • feature #20866 [Console] Improve markdown format (@ro0NL)
  • feature #20867 [Console] Include application name/version in JSON descriptions (@ro0NL)
  • feature #20869 [Console] Improve UX on not found namespace/command (@Seldaek)
  • feature #20858 [Cache] Simple Memcached Adapter (@robfrawley)
  • feature #20881 [VarDumper] Add SymfonyCaster::castRequest() (@nicolas-grekas)
  • feature #20810 [FrameworkBundle] Allow clearing private cache pools in cache:pool:clear (@chalasr)
  • feature #20417 [SecurityBundle] Rename FirewallContext#getContext() (@chalasr)
  • feature #20801 [Security] deprecate the RoleInterface (@xabbuh)
  • feature #20260 [DependencyInjection] Support autowiring for EventDispatcher/EventDispatcherInterface (@chalasr)
  • feature #20777 [ClassLoader] Deprecate Apc/WinCache/Xcache class loaders (@nicolas-grekas)
  • feature #20524 [Serializer][XmlEncoder] Allow removing empty tags in generated XML (@amoiraud)
  • feature #19958 [Serializer] Throw exception when extra attributes are used during an object denor… (@juliendidier)
  • feature #20310 [Ldap] Allow search scoping (@xunto)
  • feature #18952 [Security] Add a JSON authentication listener (@dunglas)
  • feature #20161 add toolbar & profiler SVG style classes (@havvg)
  • feature #20467 [DomCrawler] Add support for formaction and formmethod attributes (@stof)
  • feature #20509 [Serializer] Allow to specify a single value in @Groups (@dunglas)
  • feature #20722 Updated the "Symfony Config" panel in the profiler (@javiereguiluz)

Want to upgrade to this new release? Fortunately, because Symfony protects backwards-compatibility very closely, this should be quite easy.Read our upgrade documentation to learn more.

Want to be notified whenever a new Symfony release is published? Or when a version is not maintained anymore? Or only when a security issue is fixed? Consider subscribing to the Symfony Roadmap Notifications.


Be trained by Symfony experts - 2017-05-09 Paris - 2017-05-15 Cologne - 2017-05-15 Cologne

Symfony 4: A new way to develop applications

$
0
0

During the last weeks, I published a series of blog posts about my vision for Symfony 4 on my personal blog. The last article of the series so far demonstrates how to bootstrap a project with Symfony 4 (by using Symfony 3.3).

If you want to learn more, here is the full list of the currently published blog posts:

Have a good read!


Be trained by Symfony experts - 2017-05-09 Paris - 2017-05-15 Cologne - 2017-05-15 Cologne

New in Symfony 3.3: Service locators

$
0
0
Robin ChalasNicolas Grekas

Contributed by
Robin ChalasNicolas Grekas
in #21553 and #22024.

In Symfony applications, some services need access to several other services although some of them will not be actually used (e.g. the FirewallMap class). Instantiating all those unused services is useless, but it's not possible to turn them into lazy services using explicit dependency injection.

The traditional solution in those cases was to inject the entire service container to get only the services really needed. However, this is not recommended because it gives services a too broad access to the rest of the application and it hides the actual dependencies of the services.

Service locators are a design pattern that "encapsulate the processes involved in obtaining a service [...] using a central registry known as the service locator". This pattern is often discouraged, but it's useful in these cases and it's way better than injecting the entire service container.

Consider a CommandBus class that maps commands and their handlers. This class handles only one command at a time, so it's useless to instantiate all of them. First, define a service locator service with the new container.service_locator tag and add all the commands as arguments:

# app/config/services.ymlservices:app.command_handler_locator:class:Symfony\Component\DependencyInjection\ServiceLocatortags:['container.service_locator']arguments:-AppBundle\FooCommand:'@app.command_handler.foo'AppBundle\BarCommand:'@app.command_handler.bar'

Then, inject the service locator into the service defined for the command bus:

# app/config/services.ymlservices:AppBundle\CommandBus:arguments:['@app.command_handler_locator']

The injected service locator is an instance of Symfony\Component\DependencyInjection\ServiceLocator. This class implements the PSR-11 ContainerInterface, which includes thehas() and get() methods to check and get services from the locator:

// ...usePsr\Container\ContainerInterface;classCommandBus{/** @var ContainerInterface */private$handlerLocator;// ...publicfunctionhandle(Command$command){$commandClass=get_class($command);// check if some service is included in the service locatorif(!$this->handlerLocator->has($commandClass)){return;}// get the service from the service locator (and instantiate it)$handler=$this->handlerLocator->get($commandClass);return$handler->handle($command);}}

Be trained by Symfony experts - 2017-05-09 Paris - 2017-05-15 Cologne - 2017-05-15 Cologne

Symfony Community Survey 2017 Results

$
0
0

A few weeks ago, we launched the Symfony Community Survey 2017 to know more about you and how do you use Symfony. We received 2,811 answers and these are the summarized results:

We'd like to thank you all for taking the time to fill in the survey. These results are invaluable for us and they will help us make better decisions.


Be trained by Symfony experts - 2017-05-09 Paris - 2017-05-15 Cologne - 2017-05-15 Cologne

A week of symfony #540 (1-7 May 2017)

$
0
0

This week, Symfony released the 2.7.27, 2.8.20 and 3.2.8 maintenance versions and the first beta of Symfony 3.3. Meanwhile, we continued making changes related to the services and the dependency injection: services in config files now default to being private, tags under _defaults always apply and a new --types option was added to the debug:container command.

Symfony development highlights

Master changelog:

  • 2d88787: [DependencyInjection] made tags under _defaults always apply
  • c89d2f9: [DependencyInjection] defaults to public=false in all service config files
  • 09f22f4: [FrameworkBundle] show private aliases in debug:container
  • deda9ea: [WebServerBundle] added some missing docs for the web server bundle
  • f583291: [Config] fixed resource tracking with new GlobResource
  • 0f526c9: [WebServerBundle] made commands private
  • f6043bb: [FramewrokBundle] added "debug:container --types" to show classes/interfaces
  • e5bb8fa: [DependencyInjection] improved autowire exception when you type-hint a class & alias is available

Newest issues and pull requests

Silex development highlights

Master changelog:

  • 1a0b1e1: fixed deprecation notice with symfony/twig-bridge 3.2+ in TwigServiceProvider
  • 24ad5c3: added parameters to configure the Twig core extension behavior
  • 590ca76: added WebLink component integration
  • 284533e: added more options to security.firewalls
  • d5a9d9a: Released the 2.1.0 version

SwiftMailer development highlights

Master changelog:

  • a2caa64: fixed sorting MIME children when their types are equal
  • a773780: fixed addPart() does not inherit encoding

They talked about us


Be trained by Symfony experts - 2017-05-09 Paris - 2017-05-15 Cologne - 2017-05-15 Cologne

A week of symfony #541 (8-14 May 2017)

$
0
0

This week, Symfony continued tweaking and polishing the new Dependency Injection features introduced for Symfony 3.3. Meanwhile, the KernelTestCase class added a feature to define the kernel class instead of the kernel directory, which will be useful when using Symfony Flex.

Symfony development highlights

2.7 changelog:

  • 62cb443: [DependencyInjection] fixed PhpDumper blank lines around namespace
  • 71efe3f: [FrameworkBundle] adding the XML extension as a requirement
  • 0ad2f2e: [FrameworkBundle] do not try registering bundles twice in AbstractConfigCommand
  • 05240ce: [Console] fixed errors not rethrown even if not handled by console.error listeners
  • 2a288db: [Security] avoid unnecessary route lookup for empty logout path

3.2 changelog:

  • 8f4eb92: [Yaml] respect inline level when dumping objects as maps

Master changelog:

  • 3646d08: [FrameworkBundle] allow to provide the kernel class with a var in KernelTestCase
  • f389fa3: [Workflow] moved Twig extension registration to Twig Bundle
  • ca509ea: [DependencyInjection] fixed index args bug with ResolveNamedArgumentsPass
  • ae9bda1: [FrameworkBundle] fiex "Locale class not found" in AboutCommand
  • a3f7860: [DependencyInjection] do not throw autowiring exceptions for a service that will be removed
  • b33f1df: [DependencyInjection] fixed a bug where abstract classes were wired with the prototype loader
  • 83114ad: [Security] fixed TraceableAccessDecisionManager / DebugAccessDecisionManager BC layer
  • 1503f3d: [DependencyInjection] made the RegisterControllerArgumentLocatorsPass throw exception on bad types
  • 8d27128: [TwigBundle] removed ClassExistenceResource usage
  • 489fd07: [DependencyInjection] added autowire alias for AuthenticationUtils
  • d975419: [TwigBundle] service workflow.twig_extension should stay public

Newest issues and pull requests

Twig development highlights

Master changelog:

Silex development highlights

Master changelog:

  • 74a6de7: fixed WebTestCase compatibility with PHPUnit 6+

They talked about us


Be trained by Symfony experts - 2017-05-15 Cologne - 2017-05-15 Cologne - 2017-05-15 Paris

New in Symfony 3.3: PSR-4 based Service Discovery

$
0
0
Nicolas GrekasRyan Weaver

Contributed by
Nicolas GrekasRyan Weaver
in #21289 and #22680.

Symfony 3.3 will introduce lots of features to simplify the way you work with services in your applications, such as simpler configuration and autoconfig. This article explains the last big feature related to Dependency Injection:PSR-4 based service discovery and registration.

The idea is to look for PHP classes in some given directories and register them as services if their namespaces meet the PSR-4 naming syntax. This feature is configured using the resource option, which accepts a directory path or a Glob expression to match multiple directories. Example:

services:App\:resource:../src/{Controller,Command}# ...

This config looks for PHP files in the src/Controller/ and src/Command/ directories of the application, infers the PSR-4 class names from those files and uses class_exist() to check that they exist before registering those classes as Symfony services (using the class FQCN as the service id).

This feature is so convenient that Symfony Flex uses it by default in theapp.yaml config file that will be used in Symfony 4 applications:

services:# ...# this creates a service per class whose id is the fully-qualified class nameApp\:resource:'../../src/{Command,Form,EventSubscriber,Twig,Security}'App\Controller\:resource:'../../src/Controller'public:truetags:['controller.service_arguments']

If your application contains lots of directories, you can include all of them using a * value in the resource option and then use the exclude option to exclude some directories if needed:

services:# ...AppBundle\:# discover services in all AppBundle/ sub-directories...resource:'../../src/AppBundle/*'# ... except in those matching this Glob expressionexclude:'../../src/AppBundle/{AppBundle.php,Entity}'

Be trained by Symfony experts - 2017-05-15 Cologne - 2017-05-15 Cologne - 2017-05-15 Paris

Preparing your Applications for PHP 7 with Symfony Polyfills

$
0
0

According to the May 2017 PHP Stats, 53% of PHP developers use PHP 7.0 or 7.1, but only 10% of Composer packages require PHP 7.0 or higher. In fact, 1 in 4 packages still require PHP 5.3, which is used by less than 1% of developers.

Symfony Flex, the new way to create and manage Symfony applications, already requires to have PHP 7.1 installed in your development machines. Symfony 4, to be released in November 2017, will require to have PHP 7.1 in your production servers. Other popular PHP projects have announced similar plans, so if you don't upgrade to PHP 7 soon, you won't be able to install the new versions of the most important PHP projects.

Upgrading your development machines is usually a simple task, but upgrading the rest of the infrastructure (servers, tools, etc.) usually requires more resources. This is where Symfony Polyfills can help you preparing the code of your application for PHP 7.

A polyfill is a PHP 5.3 package that implements functions and features of higher PHP versions. For example, functions such as boolval(), array_column() and password_*() are only available in PHP 5.5 or higher. However, if you install the Symfony Polyfill / Php55 package, you can use them in your PHP 5.3 application:

$ cd your-project/$ composer require symfony/polyfill-php55

Symfony Polyfills check if a function exists in your PHP version and if it doesn't exist, it registers a new global PHP function with that name. This means that you can use the latest PHP features in your PHP 5.3 applications and when you finally upgrade them to PHP 7, the code will be already using the latest PHP features.

We have created polyfills for PHP 5.4, 5.5, 5.6, 7.0 and 7.1 andyou can use them in any PHP application, not only in Symfony applications. In addition, we've created other polyfills for popular PHP extensions, so you can use those features without actually having installed those extensions:APCu, Mbstring, Iconv, Intl ICU, Intl Grapheme, Intl Normalizer, and XML.

In summary, you have just a few months to upgrade your infrastructure to PHP 7, but you can already start using modern PHP features in your PHP 5.3 applications thanks to the Symfony Polyfills.


Be trained by Symfony experts - 2017-05-29 Paris - 2017-05-29 Paris - 2017-05-31 Paris

Symfony 3.3.0-RC1 released

$
0
0

Symfony 3.3.0-RC1 has just been released. Here is a list of the most important changes:

  • bug #22715 [FrameworkBundle] remove Security deps from the require section (@xabbuh)
  • bug #22613 [Process] Fix incorrectly calling PHP process when path contains space (@maryo)
  • feature #22680 [DI] Fixing missing "exclude" functionality from PSR4 loader (@weaverryan)
  • bug #22699 [TwigBundle] service workflow.twig_extension should stay public (@ogizanagi)
  • feature #22708 Adding autowire alias for AuthenticationUtils (@weaverryan)
  • bug #22695 [WebServerBundle] fix dependencies (@xabbuh)
  • bug #22647 [VarDumper] Fix dumping of non-nested stubs (@nicolas-grekas)
  • bug #22409 [Yaml] respect inline level when dumping objects as maps (@goetas, @xabbuh)
  • bug #22584 [Security] Avoid unnecessary route lookup for empty logout path (@ro0NL)
  • bug #22642 [DX] Making the RegisterControllerArgumentLocatorsPass throw exception on bad types (@weaverryan)
  • bug #22664 [Security] Fix TraceableAccessDecisionManager / DebugAccessDecisionManager BC layer (@ogizanagi)
  • bug #22690 [Console] Fix errors not rethrown even if not handled by console.error listeners (@chalasr)
  • bug #22681 Fixing a bug where abstract classes were wired with the prototype loader (@weaverryan)
  • feature #22665 [DI] Do not throw autowiring exceptions for a service that will be removed (@weaverryan)
  • bug #22669 [FrameworkBundle] AbstractConfigCommand: do not try registering bundles twice (@ogizanagi)
  • bug #22676 [FrameworkBundle] Adding the extension XML (@flug)
  • bug #22611 [FrameworkBundle] Fix "Locale class not found" in AboutCommand (@rubenrua)
  • bug #22677 [DI] Fixed index args bug with ResolveNamedArgumentsPass (@weaverryan)
  • bug #22652 [Workflow] Move twig extension registration to twig bundle (@ogizanagi)
  • feature #22668 [FrameworkBundle] KernelTestCase: allow to provide the kernel class with a var (@ogizanagi)
  • bug #22639 [WebLink][TwigBundle] Fix registration of the twig extension (@ogizanagi)
  • bug #22658 Make the exception pages work when the WebProfilerBundle is not installed (@javiereguiluz)
  • bug #22657 [DI] Fix Cannot declare class ...DefinitionDecorator, because the name is already in use (@ogizanagi)
  • feature #22624 debug:container --types (classes/interfaces) (@weaverryan)
  • bug #22626 Fix missing parenthesis (@yceruto)
  • bug #22621 [Config] Fix resource tracking with new GlobResource (@nicolas-grekas)
  • feature #22385 [DX][FrameworkBundle] Show private aliases in debug:container (@chalasr)
  • bug #22615 [DI] Defaults to public=false in all service config files (@nicolas-grekas)

Want to upgrade to this new release? Fortunately, because Symfony protects backwards-compatibility very closely, this should be quite easy.Read our upgrade documentation to learn more.

Want to be notified whenever a new Symfony release is published? Or when a version is not maintained anymore? Or only when a security issue is fixed? Consider subscribing to the Symfony Roadmap Notifications.


Be trained by Symfony experts - 2017-05-29 Paris - 2017-05-29 Paris - 2017-05-31 Paris

An open-source web platform for the new President of France

$
0
0

This Case Study is a guest post written by Titouan Galopin, lead engineer and product lead at EnMarche project. Please note that this is a strictly technical article; any political comment will be automatically deleted.

Want your company featured on the official Symfony blog? Send a proposal or case study to fabien.potencier@sensiolabs.com


Project Background

In April 2016, Emmanuel Macron, now President of France, created a political movement called "En Marche!" ("On the Move" in English), initially as a door-to-door operation to ask the public what was wrong with France.

Unlike established political parties, En Marche! didn't have any infrastructure, budget or members to support its cause. That's why En Marche! relied on the power of Internet since its very beginning to find supporters, promote events and collect donations.

I started to work for En Marche! as a volunteer in October 2016. The team was small and the all of the IT operations were maintained by just one person. So they gladly accepted my proposal to help them. At that time, the platform was created with WordPress, but we needed to replace it with something that allowed faster and more customized development. The choice of Symfony was natural: it fits the project size well, I have experience with it and it scales easily to handle the large number of users we have.

Architecture overview

Scalability was the top priority of the project, especially after the issues they faced with the first version of the platform that wasn't built with Symfony. The following diagram shows an overview of the project architecture, which is extremely scalable and redundant where needed:

We use Google Container Engine and Kubernetes to provide scalability, rolling updates and load balancing.

The Symfony app is built from the ground as a Dockerized application. The configuration uses environment variables and the application is read-only to keep it scalable: we don't generate any files at run-time in the container. The application cache is generated when building the Docker image and then is synchronized amongst the servers using the Symfony Cache component combined with a Redis instance.

There are two workers, managed by RabbitMQ, to process some heavy operations in the background: sending emails (sometimes we have to send 45k emails in a single request) and building the serialized JSON users lists that are used by several parts of the application to avoid dealing with slow and complex SQL queries.

The database uses Google Cloud SQL, a centralized MySQL database we don’t have to manage. To connect to it, we use the Cloud SQL proxy Docker image.

Deployment

The project uses a Continuous Delivery strategy, which is different from the Continuous Deployment approach: each commit is automatically deployed on a staging server but the production deployment is manual. Google Container Engine and Kubernetes are the key components to our deployment flow.

The Continuous Delivery process, as well as the unit and functional tests, is handled by CircleCI. We also use StyleCI (to ensure that new code matches the coding style of the rest of the project) and SensioLabsInsight (to perform automatic code quality analyses). These three services are configured as checks that each Pull Request must pass before merging it.

When a Pull Request is merged, the Continuous Delivery process starts (see theconfiguration file):

  1. Authenticate on Google Cloud using a Circle CI environment variable.
  2. Build the Javascript files for production.
  3. Build the three Docker images of the project (app, mails worker, users lists worker).
  4. Push the built images to Google Container Registry.
  5. Use the kubectl command line tool to update the staging server (a rolling update).

The only process performed manually (on purpose) is the SQL migration. Even if that can be automated, we prefer to carefully review those migrations before applying them to prevent serious errors on production.

Front-end

The application front-end doesn't follow the single-page application pattern. In fact, we wanted to use the least amount of Javascript possible to improve performance and rely on the native browser features.

React + Webpack

The JavaScript code of the application is implemented using React compiled with Webpack. We don't use Redux - or even React-Router - but pure React code, and we load the components only in specific containers on the page, instead of building the whole page with them. This is useful for two reasons:

  • The HTML content is fully rendered before React is loaded, and then React modifies the page contents as needed. This makes the application usable without JavaScript, even when the page is still loading on slow networks. This technique is called "progressive enhancement" and it dramatically improves the perceived performance.
  • We use Webpack 2 with tree shaking and chunks loading, so the components of each page are only loaded when necessary and therefore do not bloat the minified application code.

This technique lead us to organize the front-end code as following:

  • A front/ directory at the root of the application stores all the SASS and JavaScript files.
  • A tiny kernel.js file loads the JavaScript vendors and application code in parallel.
  • An app.js file loads the different application components.
  • In the Twig templates, we load the components needed for each page (for example, the address autocomplete component.

Front-end performance

Front-end performance is often overlooked, but the network is usually the biggest bottleneck of your application. Saving a few milliseconds in the backend won't take you too far, but saving 3 or more seconds of loading time for the images will change the perception of your web site.

Images were the main front-end performance issue. Campaign managers wanted to publish lots of images, but the users want fast-loading pages. The solution was to use powerful compression algorithms and apply other tricks.

First, we stored the image contents on Google Cloud Storage and their metadata in the database (using a Doctrine entity called Media). This allows us, for example, to know the image dimensions without needing to load it. This helps us creating a web page design that doesn't jump around while images load.

Second, we combined the Media entity date with the Glide library to implement:

  • Contextual image resizing: for example, the images displayed on the small grid blocks in the homepage can be much smaller and of lower resolutions than the same images displayed as the main article image.
  • Better image compression: all images are encoded as progressive jpegs with a quality of 70%. This change improved the loading time dramatically compared to other formats such as PNG.

The integration of Glide into Symfony was made with a simple endpoint in theAssetController and we used signatures and the cache to mitigate DDoS attacks on this endpoint.

Third, we lazy loaded all images below the scroll, which consists in three steps:

  1. Load all the elements above the scroll as fast as possible, and wait for the ones below it.
  2. Load ultra low resolution versions of the images below the scroll (generated with Glide) and use local JavaScript code to apply a gaussian blur filter to them.
  3. Replace these blurred placeholders when the high quality images are loaded.

We implemented an application wide Javascript listener to apply this behavior everywhere on the web site.

Forms

The project includes some interesting forms. The first one is theform to sign up for the web: depending upon the country and postal code fields, the city field changes from an input text to a prepopulated select list.

Technically there are two fields: “cityName” and “city” (the second one is the code assigned to the city according to the French regulations). The Form component populates these two fields from the request, as usual.

On the view side, only the cityName field is displayed initially. If the selected country is France, we use some JavaScript code to show the select list of cities. This JavaScript code also listens to the change event of the postal code field and makes an AJAX request to get the list of related cities. On the server side, if the selected country is France, we require a city code to be provided and otherwise we use the cityName field.

This technique is a good example of the progressive enhancement technique discussed a bit earlier in this article. The JavaScript code, as everything else, is just a helper to make some things nicer, but it's not critical to make the feature work.

As these of address fields are used a lot in the application, we abstracted it to an AddressType form type associated with an address Javascript component.

The other interesting form is the one that lets you send an email to someone trying to convince them to vote for the candidate. It's a multi-step form that asks some questions about that other person (gender, age, job type, topics of interest, etc.) and then generates customized content that can be sent by email.

Technically the form combines a highly dynamic Symfony Form with the Workflow component, which is a good example of how to integrate both. The implementation is based on a model class called InvitationProcessor populated from a multi-step and dynamic form type and storing the contents in the session. The Workflow component was used to ensure that the model object is valid, defining which transitions were allowed for each model state: see InvitationProcessorHandler and workflows.yml config.

Search Engine

The search engine, which is blazing fast and provides real-time search results, is powered by Algolia. The integration to index the application entities (articles, pages, committees, events, etc.) is made with the AlgoliaSearchBundle.

This bundle is really useful. We just added a few annotations to the Doctrine entities and after that, the search index was automatically updated whenever an entity is created, updated or deleted. Technically, the bundle listens to the Doctrine events, so you don't need to do anything to keep the search contents always updated.

Security

As any other high-profile web site, we were the target of some attacks coordinated and carried out by powerful organizations. Most of the attacks were of brute-force nature and the aim was to take the web site down rather than infiltrate it.

The web site was targeted by DDoS attacks eight times in the whole campaign, five of them in the final two weeks. They had no impact on the Symfony app because of the Cloudflare mitigation and our on-demand scalability based on Kubernetes.

First, we suffered three attacks based on WordPress pingbacks. The attackers used thousands of hacked WordPress websites to send pingback requests to our website, quickly overloading it. We addedsome checks in the nginx configuration to mitigate this attack.

The other attacks were more sophisticated and required both Cloudflare and Varnish to mitigate them. Using Cloudfare to cache assets was so efficient that we thought there was no need for a reverse proxy. However, a reverse proxy was proven necessary during DDoS attacks: in the last days of the campaign, the attacks were huge (up to 300,000 requests per second) and we had to disable the user system and enable the "Cache Everything" flag on Cloudfare.

There's nothing you can do to prevent security attacks, but you can mitigate them by complying with the best practices of Symfony, which, by the way, is one of the few open source projects that hasconducted a public security audit.

Open Source

The en-marche.fr web platform and its related projects have been open sourced in the@EnMarche GitHub account. We didn't promote this idea much though, because open source is pretty complex to explain to non-technical people. However, we received some contributions from people that found the project and were glad that it was open source.

We are also thinking about giving back to Symfony by contributing some elements developed for the project. For example, theUnitedNationsCountryType form type could be useful for some projects. We also developed an integration with the Mailjet service that could be released as a Symfony bundle.


Be trained by Symfony experts - 2017-05-29 Paris - 2017-05-29 Paris - 2017-05-31 Paris

A week of symfony #542 (15-21 May 2017)

$
0
0

This week, Symfony activity was intense: HHVM support was dropped, Symfony 4 bumped its minimum requirement to PHP 7.1, Symfony 3.3.0 RC1 was released, and the 3.3 and 3.4 branches were created in the repository. In addition, it was announced that SymfonyCon 2017 conference will take place in Cluj (Romania) on November 16-18.

Symfony development highlights

2.7 changelog:

  • c4abc15: [Intl] updated ICU data to 59.1

2.8 changelog:

  • 80e2e1f: [WebProfilerBundle] improved how profiler errors are displayed on small screens

3.2 changelog:

  • 401c550: [FrameworkBundle] removed Security deps from the require section

3.3 changelog:

  • 03914e9: [Process] fixed incorrectly calling PHP process when path contains space
  • 649ad8c: [WebServerBundle] use 0.0.0.0 as the server log command host default
  • 159f3c5: [MonologBridge] fixed the Monolog ServerLogHandler from hanging on Windows

3.4 changelog:

  • 27852a0: allowed individual bridges, bundles and components to be used with 4.0

Master changelog:

  • 15b7cdb: bumped minimum version to PHP 7.1 for Symfony 4
  • 8514e22: [Serializer] removed deprecated DoctrineCache support
  • a91a7de: [Workflow] removed deprecated features
  • 79bc327: [Debug, VarDumper] removed the symfony_debug C extension
  • d25d340: [DependencyInjection] removed dead code with PHP 7+
  • 5ed9cb3: removed BC layers for ControllerResolver::getArguments()
  • da61abd: [ExpressionLanguage] removed deprecated features

Newest issues and pull requests

SwiftMailer development highlights

Master changelog:

  • 772b15b: update to PHPUnit 6 and php7 only
  • 7745581: Improved and updated docs
  • 375a15d: added Swift_Transport::ping()
  • 341960e: added support for private key passprases
  • 5e58f2e: dependency-inject local-domain into AbstractSmtpTransport
  • 74e20ce: prepared the 6.0.0 release
  • fb4800d: migrated to PHP 7

They talked about us


Be trained by Symfony experts - 2017-05-29 Paris - 2017-05-29 Paris - 2017-05-31 Paris

Symfony 4: End of HHVM support

$
0
0

We started working on HHVM compatibility on December 2013. On July 2015, we proudly announced full support for HHVM. Symfony 2.3 and all other maintained Symfony branches were compatible. It was a long journey and it took us a lot of time to get there. We also got support from the HHVM team as they fixed bugs we weren't able to work around in Symfony.

Back then, the most attractive selling point of HHVM compared to PHP was performance. HHVM was way faster than PHP. But soon enough, the PHP team embarked on a quest to find ways to drastically improve the performance of PHP. PHP 7 was born. Nowadays, the performance difference between HHVM and PHP is not significant anymore.

After a poll on Twitter, we have decided to drop support for HHVM as of Symfony 4.0. Results show that HHVM adoption is very low in the Symfony community (less than 4% said they were using HHVM and wanted it to be supported by Symfony).

But if Symfony supports HHVM today, why do we want to remove it in 4.0? If HHVM and PHP were equivalent (same features, same bugs, same behaviors, ...), that would not be a problem. But the reality is very different. Some PHP 7+ features are not (yet) available in HHVM. Symfony's code has quite a few workarounds for HHMV. Nobody in the extended core team uses HHVM. But more importantly, when we decided to bump the minimum PHP version to 7+ in composer.json, we realized that there were no way to make our tests pass. The first blocker is that evenComposer is not compatible with HHVM when using PHP 7. And the issue was created about a year ago. I knew it as I tried to make it work back when I was about to release Twig 2.0 about 6 months ago. Nothing changed. It looks like PHP compatibility is not much of a priority anymore for the HHVM team.

Given the low adoption, compatibility issues, insignificant performance differences, we had no choices but to officially drop support for Symfony 4.

We will keep HHVM workarounds in Symfony 3.4 though, which means that projects using HHVM will still be able to use HHVM with Symfony until November 2020 (three years from now as 3.4 is a LTS version). That gives plenty of time to migrate away from HHVM or Symfony.

Symfony is not the first PHP project to drop HHVM support. Doctrine, CakePHP, and MongoDB dropped or will soon drop HHVM support (as commented on the Twitter poll). Laravel also dropped support as of version 5.3 (released 9 months ago). I can imagine that more PHP libraries will drop support as they will face the same issues as Symfony when requiring PHP 7.

That's also why I have decided to drop HHVM support for all my other significant projects like Twig (as of version 2), Silex, and Swiftmailer.

I have also created a pull request on the HHVM repository to remove my projects from the HHVM compatibility test matrix as we don't want people to think that Symfony is still compatible with HHVM while it's not properly tested. It is even more important as tests run on an old and unmaintained Symfony version (2.4.8). I think other projects should do the same to avoid confusion.


Be trained by Symfony experts - 2017-05-29 Paris - 2017-05-29 Paris - 2017-05-31 Paris
Viewing all 3103 articles
Browse latest View live