Fresh inputs from Confoo Vancouver 2016

I was invited to present at Confoo in Vancouver, Canada. I gave my talk “HTTP caching with Varnish” and a Symfony introduction. After having been invited to Confoo Montreal early this year, it was great to see how Confoo got an even broader range of technologies and languages covered. Many talks where on concepts first, rather than specific languages: HTTP, in-application caching, databases and so on. Other talks actively invited to learn new languages, like “Python for non-Python developers”.

Continue reading about Fresh inputs from Confoo Vancouver 2016

IPC: International PHP Conference 2016 in Munich

I have been invited to Munich to do two talks at the IPC. I gave my introduction to HTTP caching with Varnish and a talk on practical tools to build REST APIs. The IPC wanted some talks in German, so the slides are in german. You can find older versions of the slides in english for HTTP caching and REST APIs. I always enjoy presenting on a topic I care about, and the discussions after the talk. I am glad to help people, and more often than not, questions lead to me having to reflect why I have that opinion or outright learning something new. The organization of the conference has been flawless and the venue in the center of Munich was very convenient.

I could not stay for very long unfortunately, but managed to sit in to a few talks. Most notable was the talk on content strategy by Neos CMS core developer Robert Lemke with a lot of valuable information. I found the slides of his talk. The other talk I managed to see was by Michael Haeuslmann on dependencies in large projects. Michael is the developer of dephpend (pronounced “defend”), a tool to analyse dependencies of your PHP code and detecting architecture violations. He advocate such tools to identify the most important places to start improving a large code base.

Web Summercamp in Croatia – PHP track

David Buchmann introducing HTTPlug

HTTP client workshop in the PHP track of Web Summer Camp Rovinj

I was invited to do a workshop at Web Summer Camp in Rovinj (yes, last year it was called PHP Summer Camp – it got bigger this year). This year, I did a workshop on building HTTP clients in PHP. I did the workshop together with Márk Sági-Kazár, the lead author of HTTPlug, the HTTP client abstraction on top of PSR-7. We used PSR-7 and HTTPlug to build a client against an example API to manage TODO items. Then we showed how to do a Symfony integration for such a client, and how the HttplugBundle can be used to debug requests that are done in Symfony. The slides are online on slides.com – though note that this was a hands-on workshop, important parts of the workshop are not visible on these slides. The workshop was well received and I hope to teach it again in the future.

Web Summer Camp is unique in being a conference that only consists of 3 hour hands-on workshops and no only talks – aside from a lightning talks session. There are workshops in the morning and in the afternoon, so during the 3 days, you get to do 6 in depth-workshops. This year, there was the PHP track with 2 parallel workshops, and an eZ publish track as well as a UX / agile track. The Summer Camp is a community organized event with a great atmosphere, nice evening activities – and keeping the prices impressively low for what you get. The included boat trip on saturday is another unique and awesome thing. In short, you should strongly consider visiting the Summer Camp next year!

Symfony: A Tool to Convert NelmioApiDocBundle to Swagger PHP

We have an API built with Symfony that outputs its specification in the Swagger format. We needed to upgrade from version 1 to 2. As we switched the library to generate the specification while upgrading, we had to convert the configuration. In our case that configuration was so extensive that we decided to build a script to convert the configuration.

Swagger is a standard to document REST APIs. Using a JSON file, an application can document its API. Swagger specifies the path for each resource and allowed HTTP methods, as well as input parameters and the returned data. On top of this specification, tools like Swagger UI can automatically provide an API client in a browser. This is an excellent way to explore the documentation and also very helpful when investigating data issues.

We have been using NelmioApiDocBundle with our application for a while now. This bundle reads annotations on the controllers and combines them with the Symfony routing informations to produce an API documentation in the Swagger 1 format. Support for Swagger version 2 however was not available in NelmioApiDocBundle at the time of this blog post. We would have stayed with NelmioApiDocBundle, as it worked well for us, but we did not want to invest the time to refactor that bundle to Swagger 2.

Continue reading about Symfony: A Tool to Convert NelmioApiDocBundle to Swagger PHP

Tags: ,

Symfony: A look back and what it all means

As we were preparing the news about becoming a Sensiolabs Silver Partner, I brought back a bit to the history of Symfony here at Liip. We did do a few symfony v1 projects at Liip but things only really took off with Symfony2. Back in 2009 Fabien came to Zurich to discuss some of the Symfony2 components (still PHP 5.2 compatible at the time) he had just released as well as a few he hadn’t yet released. Jordi, who was working at Liip at the time, and I integrated all of them into our company internal framework over the following months which we later presented at the Symfony Live. This means Liip in fact build the first Symfony2 framework, even before there was the official Symfony framework.

Continue reading about Symfony: A look back and what it all means

Tags: , ,

Playing well with others

I was invited to speak at the T3DD15, the TYPO3 Developer Days 2015, on the topic of community collaboration. Indeed my presence there was also made happen because there was a big interest both from the TYPO3 CMS as well as from Neos CMS to explore adopting Symfony. Another topic was adopting of PHPCR, again both TYPO3 and Neos CMS expressed an interest in this topic, though not as urgently as adopting Symfony. In fact the Symfony adoption is already under way with TYPO3 CMS developers having already integrated the Console component and looking towards the Routing component next. Neos CMS has long ago adopted the Yaml component and are looking towards the Process component next. Indeed especially Neos CMS might be beginning to adopt quite a few more Symfony, and other components. They are even willing to explore going to Symfony full stack, though it would need to be made compatible with their unique Proxy based AOP solution that enables them to effectively overload the “new” operator.

Anyway, back to the title of this blog post. I did in fact choose the same title for my talk in which I tried to give some considerations about legal but more importantly community topics related to working with third party projects. I tried to make it clear that there valid points for choosing to not adopt third party solutions in every case. I also tried to address a bit how to get people from other communities more involved into the TYPO3 and Neos CMS communities. Overall I must say I am still not quite as fluent with soft topic talks compared to hard topic, ie. code related, talks. I still do not know how much content to put on the slides and how much I can free style. I also still have a hard time estimating how long my talk will last. I guess I will get better with practice.

It was also an interesting time to give this talk, as TYPO3 and Neos CMS only recently decided to part ways. It is not clear if this will be the last joint conference. During my talk I wanted to make things a bit more concrete, especially when discussing points about what might prevent people from collaborating with TYPO3 and Neos CMS. It felt a bit strange as I was mentioning issues with each of the projects. I was worried that I might set of a flamewar, but everything seemed to stay quite civil :)

At any rate, I spend two great days with lots of interesting discussions. The location was awesome, essentially right in the Nürnburg castle, with lots of rooms for people to gather to discuss and hack. Aside from the Symfony and PHPCR related discussions I also entered into a session on diversity as well as on CQRS. Overall it was a very productive environment and a fun exchange with lots of old and new faces!

Tags: , , ,

DPC – Dutch PHP Conference in Amsterdam

amsterdam

Last week, I was at the Dutch PHP Conference in Amsterdam. I did a workshop on content management with Symfony with the CMF and a workshop as well as a talk on HTTP caching and the Varnish reverse proxy together with David de Boer. I will give a similar tutorial at PHP Summer Camp in Rovinj, Croatia and at PHP Conference Bulgaria in Sofia later this year. Let me know if you are interested in having me give this tutorial at your company.

A nice perk of talking at a conference is of course that I also get to attend the conference and see other talks. There was a couple of interesting talks I managed to attend in Amsterdam. Most notably was Implement Single Sign On easily with Symfony by Sarah Khalil from Sensiolabs, who explained the authentication process of symfony so good that I finally feel like I really understand what is going on. The talk on HTTP/2 was mainly interesting for its detailed analysis of what was cleaned up in HTTP/1.1 since RFC 2616. Another good talk was by Arne Blankerts on the Content Security Policy (CSP). And I really enjoyed Daan van Berkels talk on Ada Lovelace and the Analytical Engine, he made maths and assembler sound like fun! There was also a code night in which David de Boer and I hosted a FOSHttpCache session with the main outcome of providing reusable varnish configuration files for the features of the library, instead of copy-paste documentation.

Besides the conference, there was of course also time to visit the beautiful city of Amsterdam. I had not visited the Netherlands since I was a small child. I even found the time for a trip to Friesland, visiting Schiermonnikoog in the Wadden Sea and taking lots of pictures of sand and birds. On the way back to Amsterdam, I stayed at Leeuwarden to do a Symfony CMF introduction at PHP Friesland Usergroup.

Symfony Live in Berlin: Lots of Symfony in Germany

Last week, I went to Berlin to present the Symfony Content Management Framework to the German PHP crowd. I did a presentation almost exclusively based on code. I showed how to develop an application with the Symfony CMF step by step. But rather than trying to live code, I prepared a series of pull requests that I switched through and showed the interesting code changes. This is a rather unusual format and I lost a few people, but I also got enthusiastic feedback from the audience. The tutorial is also online at github for those that want to have a look at it.

Fellow Liiper Lukas Kahwe Smith did two presentations. RESTing with Symfony brings together REST theory and Symfony implementation tricks for REST APIs. There is a Bundle for that explains how to find and evaluate third party bundles for Symfony, and is an appeal to not reinvent the wheel. Rather than spending time to do yet another mediocre bundle for the same purpose, invest that time makeing an existing bundle better – which is harder but more sustainable in the long term.

I also went to some other talks. One of my highlights was Dennis Benkert with his presentation on Dockerizing Symfony Applications. The talk contains many interesting recepies how to handle a symfony application including console support in docker. It was also clear about the current limits and challenges with docker (persistent filesystem for example). The other highlight was Johann-Peter Hartmann talking about Leadership in der Softwareentwicklung. This talk is about the management perspective of agile companies and held a lot of interesting and sometimes amusing background that developers who care about their work environment should think about.

Sensio Germany did a lot to ensure the conference was a nice experience. There was a social evening with free drinks in (and outside the) rainmaker loft club and colab space. I got to talk with many people about the CMF, explaining ideas and concepts and getting valuable feedback. One important bit is that I should write a blog post about the CMF routing component and how its usable stand alone even outside a full stack Symfony project. At the hackday on Saturday, a couple of people got their hands into the CMF and investigated the frontend editing, looked at the UX of the sonata admin and fixed warnings from Sensiolab insight.

Tags: , ,

Tips & tricks for capifony deployment

In this blog post we want to share some tips & tricks for deploying with capifony
which you might find useful as well.

Upload parameters files per server

Capifony already supports the upload of a parameters.yml file to servers during the deployment.
This is done globally or for each stage separately, what is already
documented as a cookbook. The parameters files
don’t need to be in the repository, they just have to be on the machine where you run the deployment.

In our project each server requires its own license key for an external service. For that reason we
need a separate parameters.yml file for each server and can’t use the stages to distinguish them.
To solve this problem we created a capifony task which can upload a different parameters file to each server.

First, we define the separate files for the servers.

The directory of the files is set as a variable.

Now comes the main part, we create a new task for uploading the file.

This task is very similar to the one of the cookbook. We use the :except option to run this
task only for servers which have the parameters_file property defined.

Then you can run the task.

  • For a shared parameters file: after ‘deploy:setup’, ‘upload_parameters’
  • For an unshared parameters file: before ‘deploy:share_childs’, ‘upload_parameters’

Generate parameters files per server

Instead of uploading the parameter files they can also be generated during the deployment. This can
be used if you don’t want to copy around files and just want to import another parameters file inside
the parameters.yml. For this a slightly different task is needed.

The rest remains the same as for uploading the parameters files.

With this solution, the parameters.yml files have to be committed to the repository. We decided to do
this because it makes the maintenance easier, e.g. we see the changes directly in our merge/pull requests.

Update schema with multiple entity managers

If you need an entity manager for updating the schema, which is not the default one, you can set a variable.
All doctrine tasks in capifony will use this variable.

But if you have multiple entity managers and want to update the schema for all of them, a little more
work is required.

The variable should be set to the default value again after running the task to avoid conflicts with other
existing tasks.

Add options when running custom Symfony commands

If you run some custom Symfony commands during deployment don’t forget to add the console_options
variable. This variable defines the –env and –no-debug parameters.

Commands without that will run in the dev environment what you probably don’t want.

Tags: ,

RESTing with Symfony2

This weekend I had the opportunity to attend and speak at Symfony Camp UA in Kiev. This event was organized already for the 5th time and draws many developers from the region. While I did spend the entire week before doing an intensive Russian course in Odessa (just for fun, no Liip has no plans to open an office in Russia), I did my talk on REST in English. Next to mine the only other talk in English was delivered by Pawel, who spoke about Sylius. It was great to finally meet Pawel in person! At any rate all other talks were in Russian. It was semi possible to follow the Russian talks if the slides contained enough code but in the end I spend most of the time talking to people sitting on the comfy chairs in front of the conference room. There were two questions that came up multiple times, so I figure I also answer them quickly here.

DELETE and 404

I started my talk on RESTing with Symfony2 with an introduction to REST itself. On slide 7 of my talk I explained the concept of “safe” and “idempotent” HTTP methods. Many people were surprised when I explained that DELETE should be idempotent, meaning that sending a DELETE request to a resource that has been removed should infact not return a 404. However, after doing some additional research now, it seems like there is acually a debate on this topic. Personally, I think a 404 should only be returned in case the URI is known to be invalid. So for example if I know my URLs should look like /notes/\d+ and I get a DELETE request to /notes/foo then a 404 would be appropriate. Otherwise I think that a 204 is the correct response. The reason is that when I DELETE, all I care about is that the resource was removed. If I wanted to know if it existed previously, I would need to do a GET request (REST does not try to keep requests to a minimum). Now obviously there could be a race condition, but lets say I have read a resource, generate a UI an provide a “delete” button. When I click that button, do I really care if I was the one that deleted the record or if someone else already deleted it before me? If I would receive a 404, I would think that I constructed my URL incorrectly and that I need to check if the server changed the URL.

UPDATE: So there has been a lengthy debate on twitter following this post. First up it seems as if most likely idempotence in REST is limited to the results on the server and not to the actual response. Quoting wikipedia on this:

“Methods PUT and DELETE are defined to be idempotent, meaning that multiple identical requests should have the same effect as a single request (Note that idempotence refers to the state of the system after the request has completed, so while the action the server takes (e.g. deleting a record) or the response code it returns may be different on subsequent requests, the system state will be the same every time).”

In this sense it would no be a violation to return a different response status code for a deleted resource than for the request that actually triggers the delete. Now to make things fun, the German wikipedia entry disagrees. All things said, I still maintain that the points I raised above mean that most likely you want to return a 2xx code and not a 4xx. I would find a 404 highly confusing but in case I know for sure that the resource used to exist a 410 might be appropriate.

HHVM

Several people asked me about my opinion about HHVM. If I look back to the original announcement by Facebook for HipHop, then I have to say I was totally underwelhmed by their gains. Given all the effort and complexity getting twice the performance seemed like such a little gain, given that every single PHP 5 minor release has given speedup in the range of 20%. I felt that their time would have been better spend helping on those improvements and maybe writing a PHP to C-extension convert. Now HHVM is much more interesting because it at least gets rid of a lot of the pains of HipHop as it can be used in development more easily. In terms of performance the speed ups are mostly for longer running computation heavy requests otherwise they are quite small compared to PHP 5.5 with OpCache. The memory footprint reductions are however quite significant even for requests that do not do a lot of number chrunching. What makes HHVM really interesting is that they are just at the very beginning of adding optimizations to their JIT. So there seems to be the potential for significant further speed ups in the near future. So given that HHVM now runs with many popular frameworks and libraries we are certainly keeping an eye on HHVM. We will hopefully soon publish a blog post with some more details on our performance analysis of HHVM.

Tags: , ,