New! Checkout our new Forums homepage! Follow the latest activity in eZ Publish Forums on Share.ez.no, Projects.ez.no and StackOverflow.com


Contributed by
Andrei Igna
in #26486.

The Accept HTTP header is added by browsers to their requests to advertise which content types they are able to understand. These content types are expressed as MIME types.

The HttpFoundation component provides several utilities in its Request class to work with request formats and MIME types (such as getMimeType(), getFormat(), getRequestFormat(), getContentType(), getAcceptableContentTypes(), etc.)

In Symfony 4.2 we added a new method called getAcceptableFormats() which returns a simplified list of formats accepted by the client based on the Accept header. This simple list is what most apps commonly need to decide which format to serve:

1
2
3
4
5
6
7
8
9
// $request is an instance of Symfony\Component\HttpFoundation\Request

// BEFORE: this was the best method to get the list of accepted content types
$request->getAcceptableContentTypes();
// returns ['text/html', 'application/xhtml+xml', 'application/xml', '*/*']

// AFTER: the list returned by the new method is easier to understand and work with
$request->getAcceptableFormats();
// returns ['html', 'xml']

Be trained by Symfony experts - 2018-11-5 Paris - 2018-11-5 Paris - 2018-11-7 Paris
10/26/2018 06:20 am   Symfony Blog   Mirror   Link  

Software developers like to write code and they like it very much. They tend to enjoy writing exhausting tests and continuous integration/continuous deployment configurations to assure top-notch quality of software. However, most of the time one part of the whole software development process somehow goes under the radar. The most overlooked part is writing documentation. We always tend to say to ourselves that we will write the documentation once the project is finished, or that we will release this version first and write the documentation later. LeBlanc’s law clearly states: Later equals never. I think this requires no explanation, but instead forces us to act.

10/26/2018 06:03 am   www.netgen.hr/eng/Blog   Mirror   Link  

Contributed by
Fabien Bourigault
in #28505.

The Serializer component is able to transform property names when serializing objects. For example, it can transform camel-cased properties like $firstName into snake-cased values like first_name.

For more complex cases, you can create name converters to map PHP property names to serialized names arbitrarily. In Symfony 4.2 we added another simpler way to do that. You can now configure name conversion rules using metadata and it works with PHP annotations (@SerializedName), XML config (serialized-name attribute) and YAML config (serialized_name key).

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
namespace App\Entity;

use Symfony\Component\Serializer\Annotation\SerializedName;

class Person
{
    /** @SerializedName("customer_name") */
    private $firstName;

    public function __construct(string $firstName)
    {
        $this->firstName = $firstName;
    }

    // ...
}

When this object is serialized, the $firstName property will be called customer_name instead of first_name:

1
2
$serialized = $serializer->serialize(new Person('Jane'));
// {"customer_name": "Jane"}

Be trained by Symfony experts - 2018-11-5 Paris - 2018-11-5 Paris - 2018-11-7 Paris
10/25/2018 06:05 am   Symfony Blog   Mirror   Link  

As part of the diversity initiative we in the beginning focused on putting systems into place to ensure that everyone can feel safe within our community. A major step was the adoption of the CoC and establishing of the CARE team, and maybe even more so by discussions within our community. We have made huge strides forward in this area with channels like #thankyou and #victory on the Symfony devs Slack. With these channels, where we celebrate all contributions and achievements no matter how small or large, we strife to create a more positive atmosphere. This has spilled over to other channels leading to open discussions about how to improve diversity and inclusion. We of course acknowledge that diversity and inclusion is a topic which requires a continuous learning process.

However, the obvious next step is to actively invite new developers to join our community and empower existing members to take the next step in making their voices heard. For this reason we published two new sections in our documentation: one for general mentoring and one for speaker mentoring.

The general #mentoring Slack channel is intended as a place where both newcomers and people seeking to take the next steps in their learning can find assistance. They can either ask questions as they come up or seek a more one-on-one approach with a mentor. A mentor can help you through anxieties during your first steps, as it is possible to discuss things outside of the public eye, building a trust relationship with an experienced community member. Aside from this, there is also the #contribs Slack channel for people that specifically seek help in contributing to the Symfony core.

As this entire concept is still quite informal, we do ask for feedback on how we can improve: Does it need more formal processes? Do we need regular “mentor meets mentee” events?

Another aspect we want to focus on is getting more people comfortable with sharing their knowledge in the community. For this purpose we have created a #speaker-mentoring Slack channel. Similar to the #mentoring Slack channel, the goal is to provide a place where beginners can ask questions and perhaps find a mentor. A mentor can help finding topics to submit to for call-for-papers and review proposals and slide decks. They can even do trial runs of your presentation with you. Remember: your first talk doesn’t have to be at a SymfonyCon, it can also be at a local user group or at your place of employment.

Once again, we are very much looking for feedback: Should we do regular virtual conferences for first time speakers? Are finances and logistics holding you back more than lack of help with getting your talk prepared?

As a final note, I wanted to mention Joni’s work as part of the Dutch PHP Conference. She contacted me recently about what we have done to document some advice for conference organizers in terms of diversity and inclusion in the Symfony community. Unfortunately, all I had to offer was a ticket with a lot of links. A week or two passed, and Joni came back with this amazing document that is now on Github. It contains a very comprehensive list of topics organizers should consider, with useful advice on how to implement these and links for further reading.

I would like to invite everyone who organizes events in the Symfony community to have a look. Even if you just implement a few of these items, it is already a step forward! Of course the reason this document was put on Github was to make it easy for people to collaborate on it and continuously improve and expand it. Semi-related, it would be cool if maybe some people from the Symfony community could help to add support for a blind review process to the opencfp platform.


Be trained by Symfony experts - 2018-11-5 Paris - 2018-11-5 Paris - 2018-11-7 Paris
10/24/2018 02:26 pm   Symfony Blog   Mirror   Link  

Although eZ Publish still has official support, with the release of eZ Platform, our community has centered around ezplatform.com and other platforms such as Slack and Discuss. Check out ez.no/Open-Source for a current list of resources.

share.ez.no is still open to contributions, such as blog posts and forum topics about eZ Publish. Important to know is that other content could be outdated.

10/24/2018 05:22 am   share.ez.no/blogs   Mirror   Link  

Symfony's Backward Compatibility Promise ensures smooth upgrades in your projects because it forbids backward compatibility breaks in minor releases. Instead of changing or removing existing features, we mark them as deprecated and change them in the next major Symfony version.

The UPGRADE-4.2.md document explains all deprecations in details and you'll see them too in the Web Debug Toolbar, the profiler and when running tests. This article summarizes the most important deprecations so you can start upgrading your Symfony 4 apps.

Deprecated a template directory

Contributed by
Yonel Ceruto
in #28891.

Storing the app templates in src/Resources/views/ is now deprecated. You must store them in the directory defined in the twig.default_path config option in config/packages/twig.yaml, which is templates/ by default.

Deprecated the Kernel name and the root dir

Contributed by
Fabien Potencier
in #28809 and #28810.

The KernelInterface::getName() method and the kernel.name parameter have been deprecated. There's no alternative to them because this is a concept that no longer makes sense in Symfony applications.

If you need a distinctive ID for the kernel of the application, you can use the KernelInterface::getContainerClass() method and the kernel.container_class parameter.

Similarly, the getRootDir() method and the kernel.root_dir parameter have been deprecated too. The alternative is to use the getProjectdir() and kernel.project_dir method introduced in Symfony 3.3:

1
2
3
4
5
6
7
8
9
# 'root_dir' is where the Kernel class is stored (src/ by default) and
# 'project_dir' is the main project directory
services:
    _defaults:
        bind:
            # Before
            $dataDir: '%kernel.root_dir%/../var/data/'
            # After
            $dataDir: '%kernel.project_dir%/var/data/'

Deprecated some console options

Contributed by
Robin Chalas
in #28653.

In Symfony 4 applications, console commands are executed in the environment defined by the APP_ENV env var. On local machines (and on some production servers) this env var is commonly defined in the .env file.

If you want to run commands in another environment, change the value in that .env file. If you want to change the environment just for some command or to do a quick test, you can set the APP_ENV and APP_DEBUG env vars before running the command.

In previous Symfony versions you could override the environment and the debug config with the --env and --no-debug command options, but they have been deprecated in Symfony 4.2:

1
2
3
4
5
# Before
$ php bin/console command_name --env=test --no-debug

# After
$ APP_ENV=test APP_DEBUG=0 php bin/console command_name

In addition to changing the commands executed locally, you may need to check your deployment commands and the cron tasks defined in your production servers.

Deprecated ContainerAwareCommand

Contributed by
Robin Chalas
in #28415.

The ContainerAwareCommand class has been deprecated. It was used in the past to create commands extending from it so they had direct access to the app service container. The alternative is to extend commands from the Command class and use proper service injection in the command constructor, as explained in the main article about the Symfony Console.

TIP: use the make:command utility provided by the MakerBundle to generate commands quickly and following the Symfony recommendations.

Deprecated the base Controller class

Contributed by
Samuel Roze
in #28243.

The base Controller class is the optional class your controllers can extend from to get access to some useful shortcut methods (such us $this->render()). This Controller class has been deprecated in favor of AbstractController.

The new AbstractController base class has the same shortcuts but it's more restrictive about services. You cannot use the $this->get() shortcut to get services. You must follow the modern practices of injecting services in your controller constructor or in the controller action.

TIP: use the make:controller utility provided by the MakerBundle to generate controllers quickly and following the Symfony recommendations.

Deprecated process commands as strings

Contributed by
Nicolas Grekas
in #27821.

Passing commands as strings to the Process class has been deprecated. The alternative is to pass an array of the command parts (name, arguments, options):

1
2
3
4
5
6
7
use Symfony\Component\Process\Process;

// Before
$process = new Process('ls -l');

// After
$process = new Process(['ls', '-l']);

Deprecated tree builders without root nodes

Contributed by
Christian Flothmann
in #27476.

This deprecation won't affect directly to most developers because it's related to the configuration classes of dependency injection. However, you'll see lots of these deprecation messages because of the bundles used in your application.

Fixing this deprecation will be simple in most cases, so you may contribute a fix to your favorite third-party bundle:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
use Symfony\Component\Config\Definition\Builder\TreeBuilder;

// Before
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('acme_root');
$rootNode->...()->...()->...();

// After
$treeBuilder = new TreeBuilder('acme_root');
$treeBuilder->getRootNode()->...()->...()->...();

Be trained by Symfony experts - 2018-11-5 Paris - 2018-11-5 Paris - 2018-11-7 Paris
10/24/2018 03:01 am   Symfony Blog   Mirror   Link  

SymfonyCon Lisbon opens its doors from December 6th to December 8th. Join us for our annual international conference in Lisbon, Portugal, to attend the international Symfony reunion and meet with members of the Symfony community from all over the world!

Secure now your ticket to the conference (including our famous Hackday) and our workshops at regular price when they are still available, some pre-conference workshops are already sold out and others only have a few seats left! Check the workshops schedule to create your personnalized combo.

You are still hesitating in joining this unmissable event? Well, here are 3 top reasons to grab your ticket and jet over to Lisbon:

  • Meet Symfony experts from all over the world! Symfony hit the Billion download milestone last year and is now approaching to the 2 Billion downloads. Our community is growing at an exponential rate and we are expecting more than 1,000 Symfony enthusiasts from around the globe. What better way to make new contacts, learn new development techniques and even better practices, exchange with partners and sponsors… this is THE place to be for open source innovation.

  • Multi-track schedule! Enjoy listening to our specially-selected speakers, all of whom will share real-life, real-project experiences, difficulties and solutions, tips and best practices for how to use the Symfony framework and PHP in the best way for your project! We have 3 tracks per day which means 3 talks per hour, you can listen to a talk from the track of your choice between: beginner, advanced, PHP on conference day 1 or the Unconference on conference day 2! Listen to top-list speakers, among them Fabien Potencier, Symfony founder/project lead; Anthony Ferrara, Diana Ungaro Arnos, Jordi Boggiano, Nicole Cordes, Ryan Weaver and many others… who will deliver their awesome talks! Check the schedule now to plan your best conference experience.

  • Unconference track! This year again, we’ll have at SymfonyCon Lisbon an Unconference track on the second day of the conference. How does it work? It's easy! If you want to speak at the Unconference, you just have to sign up for your talk on our paperboard on the first day of the conference or directly on the day of the Unconference. You can talk for 20, 30 or 40 min depending on the topic you'd like to share and you don't even need to prepare slides! The best is to sign up the day before the Unconference track on December 6th, to enable everyone to know what you'll be talking about in advance. You can talk about any topic related to Symfony, its ecosystem or its community. Never tried the Unconference experience before? That's the perfect occasion to join SymfonyCon Lisbon!

Are you in? Will you join us there? Did I already mention that the conference will be organized in Lisbon, home of the delicious Pastel de Nata, great Fado, beautiful Azulejos (Tiles), wonderful kilometers of white sand beaches and much more?

Join us in Portugal to celebrate the framework, open source innovations and the multi-faceted world of PHP! Show up, listen carefully and stay tuned to discover the latest news about Symfony and PHP! Buy your ticket now!

We’re looking forward to meeting you there!


Be trained by Symfony experts - 2018-11-5 Paris - 2018-11-5 Paris - 2018-11-7 Paris
10/23/2018 07:25 am   Symfony Blog   Mirror   Link  

Downstream — Trip 6

On the previous trip I walked from Bourne End to Staines. Staines is pretty easy to reach by a direct train from London Waterloo. Normally I would walk on a Saturday, but this time I walked on a Sunday because the weather on Saturday was rubbish, and I don't like walking in the rain.

Day 8 — Staines to Teddington Lock

Luckily, the weather had all cleared up on Sunday, and I started in Staines on another beautiful morning. It was cold when I left home in the morning, and I had actually brought a coat. Instead of the coat, I should have brought my sunglasses, as the Sun warmed me up quickly. The coat went not soon after I set of walking in earnest, as I was getting sweaty.

It was quite quiet in Staines, with only few people walking their dogs, running, and cycling. There were a lot of posh houses along the Thames on this stretch.

After walking past a new built house called "Downstream" (coincidence?) I arrived at a point where I could either take a detour along the River Wey Navigation, or take the ferry to the other bank of the Thames and continue my journey there. The Nauticalia Ferry from Shepperton to Weybridge goes once every 15 minutes, and has been in operation for about 500 years, with a short break in the eighties. The choice was easy, and after buying my £2.50 ticket I didn't have to wait long for it to set off and ferry me, and a couple with a dog, across.

Just before I arrived in Walton-on-Thames I "ran into" a bunch of people running a marathon. There was even a sign congratulating a runner with their 100th marathon. I think I'll stick to walking…

For lunch I stopped at The Swan in Walton, and sat in its garden to enjoy my fish and chips, and a half. It was still a little early and I spend a little too much time relaxing and sitting in the Sun.

A little further the Thames passes close along a few massive reservoirs, which feed into the water supply of Greater London. Slightly annoyingly, their border is a massive stone wall — and I even had to cross some tank barriers.

There was another tiny ferry at Hampton, which I ignored. Instead I crossed the Thames near Hampton Court Palace, where I walked into the forecourt to smooch and take some photos. I visited the palace with my parents a few years ago, but it is so massive that you really need a full day to visit it all. I certainly didn't have the time for that, and continued along the Thames Path. Between Hampton Court Palace and Kingston, there is a quite wide path/walking area, The Barge Walk, with at the beginning lots of flower banks.

At Kingston upon Thames I crossed the Thames for the last time on today's walk. I continued through Canberry Gardens and a little section along a raised road. Just after coming back onto a footpath my way was blocked by a massive blown-over tree. There was no way to climb over it, so I made my way up the steep bank towards the road, move 20 meters downstream, and then slide back onto the footpath. I think the tree recently blew over, as its brilliant yellow leaves hadn't fallen off yet.

I finished my walk at Teddington Lock, but not after wandering around the lock's island for a while. There are three lock gates at Teddington, instead of the usual one (or two) lock gates. I also always thought that Teddington Lock was the last (or first) lock on the Thames, but I failed to realise that there is one further downstream at Richmond as well. However, the one at Teddington is the last full lock. Beyond Teddington Lock the river Thames is tidal, and the lock at Richmond only operates on low tide—more about that in the next instalment.

After wandering around the lock, I crossed a few bridges, and made my way to Teddington station for my train back into Waterloo. Curiously, as Teddington is situated on the Kingston Loop Line, you can catch the train to Waterloo from either of its two platforms.


Photos from my Adventure on the Thames Path are available on Flickr, and all videos on Vimeo. You can also see all the photos on a map.

10/23/2018 03:15 am   derickrethans.nl   Mirror   Link  

This week, Symfony 4.2 deprecated the kernel name and the usage of getRootDir() and kernel.root_dir. Meanwhile, the Form component added a new help_attr option and the Messenger component renamed and reorganized some of its classes.

Symfony development highlights

This week, 56 pull requests were merged (37 in code and 19 in docs) and 46 issues were closed (26 in code and 20 in docs). Excluding merges, 40 authors made 3,116 additions and 4,274 deletions. See details for code and docs.

2.8 changelog:

  • 8322494: [Security] convert InsufficientAuthenticationException to HttpException with 401 status code

3.4 changelog:

  • dc11f7b: [FrameworkBundle] uniformize errors when a component is missing
  • fdc9e09: [FrameworkBundle] update translation commands for the new directory structure

4.1 changelog:

  • 72ab16d: [DependencyInjection] fixed default undefined env to empty string during compile
  • 0daf414: [Config] fixed @method annotation

Master changelog:

  • 2b34f2b: [Validator] use constraint options instead of properties
  • 76f80e9: [HttpFoundation] made ResponseHeaderBag::makeDisposition static
  • 5fda7e2: [HttpKernel] deprecated the Kernel name
  • e85f6d4: [HttpKernel] deprecated usage of getRootDir() and kernel.root_dir
  • 7048679: [FrameworkBundle] avoid calling getProjectDir() on KernelInterface
  • f0814e1: [Form, TwigBridge] added help_attr
  • bcff647: [Serializer] improved perf a bit by not using a signaling exception when not needed
  • 91a2d75: [WebProfilerBundle] redesigned the log message filter
  • 4d757b5: [Messenger] renamed "envelope items" and move them in the "Stamp" namespace
  • 915870e: [Serializer] fixed MetadataAwareNameConverter break denormalization
  • c620a3b: [TwigBundle] deprecated support for legacy templates directories
  • 316e95c: [WebProfilerBundle] replay referer URL

Newest issues and pull requests

They talked about us

Upcoming Symfony Events

Call to Action


Be trained by Symfony experts - 2018-10-24 Clichy - 2018-11-5 Paris - 2018-11-5 Paris
10/21/2018 04:32 am   Symfony Blog   Mirror   Link  

News

[Webinar] Bridging the Gap Between Commerce and Content

Join us on October 24th, 2018 at 10:00am ET/ 3:00pm CET as eZ's Product Marketing Manager, Amit takes us on a tour of eZ Commerce.

What you'll learn: Live demo of eZ Commerce and its new features. Learn about the limitations of commerce solutions on the market possess and how a unified solution can be ideal for complex B2B projects. Who should attend: CMO, CTO/CIO, Marketer/Editors.

You can register here.

Support Open Source and eZ Platform, join Hacktoberfest 2018

Hacktoberfest is open to anyone in the open source ecosystem. You can sign up any time between October 1st and October 31st. What do you have to do? Sign up, and make five pull requests (PRs) between October 1st - 31st in any timezone, on any public repository.

Of course we welcome you to search for issues on our issue tracker, work on a solution, and make a pull request on one of our repo's on GitHub.

eZ Platform 2.3.1 released

eZ Platform 2.3.1 has been released, fixing several bugs. Check out the release notes to find out which bugs. As always, update your current installation using Composer, or download the release from our developer hub.

In Other News:

Resources

Discover eZ Platform v2.3

Last week we presented eZ Platform 2.3, the latest Fast Track release. The recording of this webinar is available on our YouTube channel.

Looking for a bundle compatible with eZ Platform? Check out: https://ezplatform.com/Bundles.

Social Media

Follow us on Twitter, Facebook, LinkedIn, Google+, or YouTube, and join our Community for any help with eZ Platform or community-related questions.

Find eZ at These Events

For more events, make sure to check out this list.

Each week we publish a roundup of highlights from the eZ ecosystem. If you have any news or events to share, please contact me.

(Lead image credit: Kmeron, CC)

10/19/2018 10:13 am   ez.no/About-eZ/Blog   Mirror   Link  

News

[Webinar] Bridging the Gap Between Commerce and Content

Join us on October 24th, 2018 at 10:00am ET/ 3:00pm CET as eZ's Product Marketing Manager, Amit takes us on a tour of eZ Commerce.

What you'll learn: Live demo of eZ Commerce and its new features. Learn about the limitations of commerce solutions on the market possess and how a unified solution can be ideal for complex B2B projects. Who should attend: CMO, CTO/CIO, Marketer/Editors.

You can register here.

Support Open Source and eZ Platform, join Hacktoberfest 2018

Hacktoberfest is open to anyone in the open source ecosystem. You can sign up any time between October 1st and October 31st. What do you have to do? Sign up, and make five pull requests (PRs) between October 1st - 31st in any timezone, on any public repository.

Of course we welcome you to search for issues on our issue tracker, work on a solution, and make a pull request on one of our repo's on GitHub.

eZ Platform 2.3.1 released

eZ Platform 2.3.1 has been released, fixing several bugs. Check out the release notes to find out which bugs. As always, update your current installation using Composer, or download the release from our developer hub.

In Other News:

Resources

Discover eZ Platform v2.3

Last week we presented eZ Platform 2.3, the latest Fast Track release. The recording of this webinar is available on our YouTube channel.

Looking for a bundle compatible with eZ Platform? Check out: https://ezplatform.com/Bundles.

Social Media

Follow us on Twitter, Facebook, LinkedIn, Google+, or YouTube, and join our Community for any help with eZ Platform or community-related questions.

Find eZ at These Events

For more events, make sure to check out this list.

Each week we publish a roundup of highlights from the eZ ecosystem. If you have any news or events to share, please contact me.

(Lead image credit: Kmeron, CC)

10/19/2018 10:13 am   eZ Systems News   Mirror   Link  

Contributed by
Maxime Veber
in #27742.

The Symfony Process component executes commands taking care of the differences between operating system and escaping arguments to prevent security issues. One of the features it provides is the wait() method, which blocks the app execution until the given process has finished.

However, for some kinds of commands (such as long running processes) you can't use this method because the process never ends. That's why it's common to find code like this, which waits a few seconds for the process to start:

1
2
3
4
5
6
7
use Symfony\Component\Process\Process;

$process = new Process(['/usr/bin/php', 'slow-starting-server.php']);
$process->start();

// wait a few seconds for the process to be ready
sleep(3);

However, this code is fragile because the process may take longer to be ready than the given time. In Symfony 4.2 we've added a new waitUntil() method which receives a callback as argument and keeps waiting until the callback returns true.

The callback is called repeatedly whilst the process is still running, passing in the process output and its type (Process::ERR or Process::OUT) as its arguments.

In the above example, instead of waiting a fixed number of seconds, you could wait until some text is printed in the console showing that the process is ready:

1
2
3
$process->waitUntil(function ($type, $output) {
    return $output === 'Ready. Waiting for commands...';
});

Be trained by Symfony experts - 2018-10-24 Clichy - 2018-11-5 Paris - 2018-11-5 Paris
10/19/2018 05:45 am   Symfony Blog   Mirror   Link  

Symfony meetup in Vietnam

We’re super excited to announce that for the first time ever a Symfony meetup will be organized in Vietnam next month. For this great occasion, Fabien Potencier will be speaking there about “What’s new in Symfony 4”. For one night only, join him on November 8th for an exclusive event to get to know the latest version of Symfony in Hồ Chí Minh. We'd like to give a warm thank you to Pierre Joye who helped putting this meetup together, thank you for your help and Symfony support from there!

The free meetup is organized by NFQ Asia at Dreamplex 195 Dien Bien Phu St., Quận Bình Thạnh, Thành Phố Hồ Chí Minh from 6:30 pm to 9 pm. The talk will be followed by a networking time to share pizzas, beers and soft drinks in a relaxed way. A great opportunity for all Symfony and PHP lovers to gather, learn some new knowledge, and network with like-minded techies.

Don’t forget to register here to the meetup if you plan to go there! We are very pleased to meet the Vietnamese Symfony community there!


Be trained by Symfony experts - 2018-10-24 Clichy - 2018-11-5 Paris - 2018-11-5 Paris
10/18/2018 02:47 am   Symfony Blog   Mirror   Link  

Symfony's security system has always been flexible. But over the past few years, it's also become increasingly easy to tap into that power: by creating Guard authenticators and voters for complex authorization rules.

But, we can do more. For example, Symfony security users are so flexible, they can be confusing to set up. And creating a Guard authenticator, while clear and powerful, requires some work. Can we have both flexibility and rapid development? I think so - thanks to two new commands added to MakerBundle.

make:user

Contributed by
Ryan Weaver
in #250.

Ready to start your security system? First you need a user. But, does your entity need to be saved to the database? And is your app responsible for checking passwords? MakerBundle 1.7 will guide you through these decisions and generate exactly what you need:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
$ php bin/console make:user

The name of the security user class (e.g. User) [User]:
> User

Do you want to store user data in the database (via Doctrine)? (yes/no) [yes]:
> yes

Enter a property name that will be the unique "display" name for the user
(e.g. email, username, uuid) [email]:
> email

Will this app need to hash/check user passwords? Choose No if passwords
are not needed or will be checked/hashed by some other system (e.g. a single sign-on server).
Does this app need to hash/check user passwords? (yes/no) [yes]:
> yes

created: src/Entity/User.php
created: src/Repository/UserRepository.php
updated: src/Entity/User.php
updated: config/packages/security.yaml

That's it! Depending on your answers, the command will create a User class/entity and update your security.yaml file to configure a secure password encoder (if needed) and a user provider. The generated code has clear comments so you can continue updating everything for your needs.

make:auth

Contributed by
Nicolas Philippe
in #266.

Now that you have a User class, it's time to let your users log in. Want a complete form login system in one command? In MakerBundle 1.8, it's no problem. The new make:auth command can create an entire form authentication system, or an empty authenticator, based on your answers:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
$ php bin/console make:auth

What style of authentication do you want? [Empty authenticator]:
[0] Empty authenticator
[1] Login form authenticator
> 1

The class name of the authenticator to create (e.g. AppCustomAuthenticator):
> LoginFormAuthenticator

Choose a name for the controller class (e.g. SecurityController) [SecurityController]:

created: src/Security/LoginFormAuthenticator.php
updated: config/packages/security.yaml
created: src/Controller/SecurityController.php
created: templates/security/login.html.twig

This creates the login route, controller and template as well as a Guard authenticator that handles the login submit, includes CSRF protection and redirects intelligently on success and error. Your authenticator class will have a few minor TODOs inside (usually just 1) that you'll need to finish. But, you won't need to modify any config files.

The result? A fully functional login system in minutes that you have full control over. Customize the template to match your look and update the code in your authenticator to add anything special you need during the login process.

You can also generate a "empty" authenticator to use for whatever other authentication you need. Want support to generate other kinds of authenticators? Just open a pull request!

Happy security!


Be trained by Symfony experts - 2018-10-17 Paris - 2018-10-22 Clichy - 2018-10-22 Clichy
10/17/2018 08:24 am   Symfony Blog   Mirror   Link  

The international Symfony conference is coming in less than 2 months, on December 6th and 7th in the fantastic Lisbon, Portugal. Pre-conference workshops at SymfonyCon Lisbon are organized on December 4th and 5th and all of them are almost sold out! If you want to get trained before the conference, you might secure your workshop ticket before there are all gone!

We’re very pleased to announce that we have added a new workshop to the list:

Discover the Sylius plugin development with Symfony 4.1, one-day workshop. You will be trained by Sylius Core Team Members Mateusz Zalewski & Łukasz Chruściel. Learn all about how to implement a reusable plugin for your Sylius-based e-commerce application that will be crafted to your needs. We will use the most recent Symfony version, fulfilling its conventions and recommended practices. Using BDD methodology, we will not forget about tests that will describe your custom business logic and ensure us that we write clean and shiny code. During the workshop, we will be aiming to make plugin usable with Symfony Flex to make installation and configuration more developer-friendly.

You can combo this one-day workshop with the others one-day workshops already online but there are only a few seats left for the following workshops. Registration for these workshops is not available on both pre-conference workshop days as the workshops might already be sold out on selected dates:

  • Writing Modern JavaScript with Symfony & Webpack Encore by Ryan Weaver - Symfony Core Team member & docs leader (one-day workshop). In this workshop, we'll use the Webpack Encore library from Symfony to quickly bootstrap a sophisticated asset setup, complete with minification, SASS processing, automatic versioning, Babel support and everything you need to start writing great JavaScript quickly. We'll also learn about using JavaScript modules, how to bootstrap a framework (like React) and other important modern practices. Give your assets a huge boost with Webpack Encore!

  • Symfony 4 Best practices by Nicolas Grekas - Symfony Core Team member (one-day workshop). During this workshop, you will discover the new practices recommended by the Symfony Core Team. You will learn how to install third-party packages with Symfony Flex, configure your application with environment variables or exploit the new features of the dependency injection container. And much more! We'll build a demo app together so that you'll learn all the basic (and less basic) features that modern Symfony apps allow to build efficiently.

  • Symfony Messenger by Samuel Rozé - Symfony Core Team member and creator of the component (one-day workshop). The Messenger component just landed in Symfony 4.1. In this workshop, you will learn about: 1. Creating and handling messages as a strategy to decouple your application; 2. Configure the message routing and asynchronously handle your messages; 3. Discovering the bus middleware and creating your owns to add your custom logic; 4. An overview of using Messenger in the CQRS context (command and query buses); 5. Specifics of the AMQP and Enqueue adapters for your asynchronous processing; 6. How to customise and write your own adapters.

  • Building API-driven apps with API Platform by Kévin Dunglas - Symfony Core Team member (one-day workshop). After an overview of modern API patterns and formats (REST, Swagger, hypermedia, HATEOAS, JSON-LD, Hydra, Schema.org, GraphQL...), we'll learn how to use and extend the most popular features of the API Platform API component: Swagger documentation, pagination, validation, sorting, filtering, authentication, authorization, content negotiation, data model generation using the Schema.org vocabulary. Finally, we'll discover how easy it is to use the client-side (JavaScript) toolkit.

  • Mastering OOP & Design Patterns by Hugo Hamon - lead dev at Dayuse.com, ex head of training at SensioLabs (two-day workshop). Object Oriented Design aka OOD is hard and not limited to designing just classes and interfaces. This workshop will help you better understand all the concepts and techniques to write cleaner, more robust and more testable object oriented code. You'll learn how to make your code respect the SOLID principles. You'll also discover the techniques to reduce the complexity of your code as well as making your classes thinner and more focused. You'll also learn how to recognize and leverage the power of design patterns (factory, adapter, composite, decorator, mediator, strategy, etc.) in order to make your code flexible, extensible, unit testable and less fragile.

    Check out the entire workshop schedule and get your combo workshop and conference ticket now! See you soon at the conference in Lisbon!


Be trained by Symfony experts - 2018-10-17 Paris - 2018-10-22 Clichy - 2018-10-22 Clichy
10/16/2018 03:10 am   Symfony Blog   Mirror   Link  

This week development activity increased in preparation for the upcoming release of Symfony 4.2. We simplified form extensions to no longer require any configuration, improved the Finder component to allow reversing the previous sorting and added new features to the profiler to display logs context and allow to filter logs by level.

Symfony development highlights

This week, 80 pull requests were merged (57 in code and 23 in docs) and 89 issues were closed (68 in code and 21 in docs). Excluding merges, 45 authors made 5,430 additions and 4,171 deletions. See details for code and docs.

2.8 changelog:

  • 270f496: [Form] fixed multi-digit seconds fraction handling
  • 9fdc64b: [Process] fixed locking of pipe files on Windows
  • bad4867: [Console] fixed multiselect choice question defaults in non-interactive mode

3.4 changelog:

  • 2f0e5d7: [Security] do not deauthenticate user when the first refreshed user has changed
  • f9aac64: [FrameworkBundle] added missing cache prefix seed attribute to XSD
  • 60f6e91: [SecurityBundle] do not override custom access decision configs
  • f89ef42: [FrameworkBundle] setting missing default paths under BC layer

Master changelog:

  • d482f0a: [WebProfilerBundle] extracted server parameters into their own tab
  • c10d2c0: [WebServerBundle] added ability to display the current hostname address when binding to 0.0.0.0
  • 52b7239: [Form] simplified the form type extension registration
  • 51f39b9: [Cache] added CacheInterface::delete() + improve CacheTrait
  • 003499d: [OptionsResolver] passed Options argument to deprecation closure
  • dce8f08: [Asset] added different protocols to be allowed as asset base_url
  • 331a24e: [Security] added port in access_control
  • bc816da, d13141f: [Finder] added a way to inverse a previous sorting
  • ea0b807: [VarDumper] allowed to use a light theme out of the box
  • d3fac86: [OptionsResolver] added support for nesting options definition
  • 631d718: [Form] allowed additional http methods in form configuration
  • 722c816: [Validator] provided file basename for FileValidator constraint messages
  • 61d336b: [WebProfilerBundle] displayed the log context in the debug pages
  • 6de1577: [WebProfilerBundle] filter logs by level
  • 620094a: [Cache] added support for connecting to Redis clusters via DSN
  • 4a4fda5: [Process] addde "wait until callback" to process class
  • 9bec1fc: [Validator] deprecated checkMX and checkHost on Email validator

Newest issues and pull requests

They talked about us

Upcoming Symfony Events

Call to Action


Be trained by Symfony experts - 2018-10-17 Paris - 2018-10-22 Clichy - 2018-10-22 Clichy
10/14/2018 03:09 am   Symfony Blog   Mirror   Link  

Contributed by
Nicolas Grekas
in #28447 and #28446.

In PHP, setting the secure parameter to true in the setcookie() or session_set_cookie_params() functions make cookies to be sent only when the connection is secure and uses HTTPS.

In Symfony applications you can control this behavior with the framework.session.cookie_secure option, which is a boolean that defaults to false. In order to improve the application security, in Symfony 4.2 we made cookies secure automatically.

The new default value of the cookie_secure option is null, which makes cookies secure when the request is using HTTPS and doesn't modify them when the request uses HTTP. The new behavior is a good balance between making your app "safe by default" and not breaking any existing app.

Related to this, the cookie used in the Remember Me feature now inherits the default config used in the framework.session.cookie_* options, so the new auto-secure behavior also applies to it.

In Symfony 5.0, to be released in November 2019, the default value of the $secure argument of the Cookie class constructor will change from false to null. In addition, the default value of the $samesite argument will change from null to lax to use the new SameSite cookie configuration.


Be trained by Symfony experts - 2018-10-15 Paris - 2018-10-15 Paris - 2018-10-17 Paris
10/12/2018 05:13 am   Symfony Blog   Mirror   Link  

It’s with a great pleasure that we’ll meet the North American Symfony community in San Francisco during 2 great days of conference on October 11th and 12th. We have the pleasure to welcome 13 fabulous speakers at the Symfony Loves PHP conference, formerly called SymfonyLive USA! We changed our conference name and focus to enable both communities to meet and make sure our attendees will get the most out of Symfony and PHP latest news at the same place. We have the great pleasure to count among our great speakers several Symfony Core Team members and very well-known PHP community members, so this will be the right place to be if you want to learn all the latest with Symfony and PHP! We hope you’ll enjoy this new conference format and can’t wait to meet you there!

We’d like to address a particular thank you to all our amazing conference speakers for sharing their experience, best practices and real use cases with Symfony and PHP at the conference! We’d like to thank Fabien Potencier, Jeremy Mikola, Tugdual Saunier, Jonathan Johnson, Michael Cullum, Kristen Costagliola, Ryan Weaver, Cal Evans, Nicolas Grekas, Jonathan Wage, David Stokes, Samuel Roze and Jordi Boggiano, thank you very much for speaking at the conference!

We also would like to thank all our sponsors for their support and involvement with the conference:

Thanks again for teaming with us and pulling together an awesome conference experience for everyone!

Stay tuned as we have a great announce for the North American community coming next week! And of course enjoy the conference!


Be trained by Symfony experts - 2018-10-15 Paris - 2018-10-15 Paris - 2018-10-17 Paris
10/11/2018 10:04 am   Symfony Blog   Mirror   Link  
@ezpublishlegacy
ezpublishlegacy pushed to master in ezpublishlegacy/ezpublish-legacy Oct 10, 2018
1 commit to master
10/10/2018 12:11 pm   eZPublishLegacy @ GitHub   Mirror   Link  
@ezpublishlegacy
ezpublishlegacy pushed to master in ezpublishlegacy/ezplatform Oct 10, 2018
2 commits to master
  • @brookinsconsulting fd5cf30
    Merge remote-tracking branch 'upstream/master'
  • @andrerom db0c094
    [YMl] Add inline doc link for Memcached/Redis setups
10/10/2018 12:09 pm   eZPublishLegacy @ GitHub   Mirror   Link  
@ezecosystem
ezecosystem pushed to master in ezecosystem/ezplatform Oct 10, 2018
2 commits to master
  • @brookinsconsulting 668d364
    Merge remote-tracking branch 'upstream/master'
  • @andrerom db0c094
    [YMl] Add inline doc link for Memcached/Redis setups
10/10/2018 11:59 am   eZecosystem @ GitHub   Mirror   Link  

Contributed by
Christian Flothmann
in #24530.

Form type extensions allow you to modify any existing form field types. They are used to add a specific feature to a single form type (e.g. adding a "download" feature to the FileType field type) and to add a generic feature to several field types at once.

In Symfony 4.2 we've improved form type extensions to simplify their config and to allow them to extend multiple types.

Simpler configuration

In previous Symfony versions, Form type extensions define the getExtendedType() method to tell which form type they are extending:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
namespace App\Form\Extension;

use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\Extension\Core\Type\FileType;

class ImageTypeExtension extends AbstractTypeExtension
{
    // ...

    public function getExtendedType()
    {
        return FileType::class;
    }
}

Before using them, you had to register those classes as services and apply the form.type_extension service tag to them. Unfortunately, you also needed to repeat the extended form type in the service declaration:

1
2
3
4
5
6
7
8
# config/services.yaml
services:
    # ...

    App\Form\Extension\ImageTypeExtension:
        tags:
            - { name: form.type_extension,
                extended_type: Symfony\Component\Form\Extension\Core\Type\FileType }

This repetition is cumbersome, so we improved it and in Symfony 4.2, form type extensions no longer require any service configuration. First, replace the getExtendedType() method by a new static method called getExtendedTypes():

1
2
3
4
5
6
7
8
9
class ImageTypeExtension extends AbstractTypeExtension
{
    // ...

    public static function getExtendedTypes(): iterable
    {
        return [FileType::class];
    }
}

Second, if the app has enabled the service autoconfiguration feature, Symfony will apply the form.type_extension tag automatically to any service whose class implements FormTypeExtensionInterface::class.

Thanks to the new static method and the automatic tag, you no longer need to configure anything for your form type extensions. Creating the form type extension class is all you need to do.

Extending multiple form types

A side improvement provided by the new getExtendedTypes() method is that you can now extend multiple types with a single extension class, instead of having to create one extension class per form type.

The value returned by this method is of type iterable, so you can return a traditional array or be more creative if needed:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
class DateTimeExtension extends AbstractTypeExtension
{
    // ...

    public static function getExtendedTypes(): iterable
    {
        yield DateTimeType::class;
        yield DateType::class;
        yield TimeType::class;
    }
}

Not implementing the static getExtendedTypes() method when implementing FormTypeExtensionInterface is deprecated since Symfony 4.2. The method will be added to the interface in 5.0.


Be trained by Symfony experts - 2018-10-15 Paris - 2018-10-15 Paris - 2018-10-17 Paris
10/10/2018 06:01 am   Symfony Blog   Mirror   Link  
@ezpublishlegacy
ezpublishlegacy pushed to master in ezpublishlegacy/phpunit Oct 10, 2018
2 commits to master
  • @localheinz 2e5304d
    Fix: Run php-cs-fixer
  • @localheinz ece7b37
    Enhancement: Configure visibility_required fixer
10/10/2018 12:24 am   eZPublishLegacy @ GitHub   Mirror   Link  
@ezecosystem
ezecosystem pushed to master in ezecosystem/Sylius Oct 10, 2018
2 commits to master
10/10/2018 12:05 am   eZecosystem @ GitHub   Mirror   Link  
@ezpublishlegacy
ezpublishlegacy pushed to master in ezpublishlegacy/data_import Oct 10, 2018
1 commit to master
  • @peterkeung 682ef7d
    Give Administration Interface sidebar remote ID search box a unique ID
10/10/2018 12:01 am   eZPublishLegacy @ GitHub   Mirror   Link  
@ezpublishlegacy
ezpublishlegacy pushed to master in ezpublishlegacy/ezpublish-kernel Oct 9, 2018
2 commits to master
10/09/2018 12:11 pm   eZPublishLegacy @ GitHub   Mirror   Link  
@ezpublishlegacy
ezpublishlegacy pushed to master in ezpublishlegacy/ezpublish-api Oct 9, 2018
2 commits to master
10/09/2018 12:10 pm   eZPublishLegacy @ GitHub   Mirror   Link  
@ezpublishlegacy
ezpublishlegacy pushed to master in ezpublishlegacy/ezplatform Oct 9, 2018
2 commits to master
  • @brookinsconsulting e06976e
    Merge remote-tracking branch 'upstream/master'
  • @sunpietro f971658
    EZP-29675: Correct JMS translations config to exclude node_modules fo…
10/09/2018 12:09 pm   eZPublishLegacy @ GitHub   Mirror   Link