Mes slides du Symfony Live 2015 : à la découverte de API Platform

Voici les slides concernant le développement d’API hypermerdia diffusés tout à l’heure lors du Symfony Live de Paris.

Les liens vers les différents outils présentés tout à l’heure :

Les slides en plein écran.

Symfony Live 2015 : Construire des applications API-centric avec Symfony

Symfony Live 2015

Je donnerai une conférence de 40 minutes au Symfony Live 2015 qui se déroulera le 9 avril à la Cité Internationale Universitaire de Paris.

J’y parlerai de la conception et du développement d’applications construites autour d’une API REST :

Au cours de ce talk, je présenterai une architecture moderne qui permet de construire des applications performantes, évolutives et interopérables :

Le talk sera didactique et accessible aux développeurs Symfony de tous niveaux. La construction d’une micro-application suivant cette architecture sera présentée pas à pas.

 17 autres conférences atuour de Symfony auront lieu lors du même évènement. Les billets sont en vente sur le site du Symfony Live.


Introducing PropertyInfo: a PHP component to find types and doc of properties

PHP Beer Mug

PHP doesn’t support explicit type definition. This is annoying, especially when doing meta programming. Various libraries including but not limited to Doctrine ORM and the Symfony Validator provide their own type managing system. Another common way to describe type(s) of a property is integrated documentation aka PHPDoc.

The PHP Property Info library extracts various information including the type and documentation from PHP class properties from metadata of popular sources including:

  • Setter method with type hint
  • PHPDoc’s DocBlock
  • Doctrine ORM mapping (annotation, XML, YML or custom format)

Thanks to the visitor pattern, adding support for other metadata source is easy, and Pull Requests are welcome!

As usual, this library is freely available (MIT license) on my GitHub page.

As you maybe know, I’m working on a new way to build hypermedia REST API with Symfony (an experimental release is already available: DunglasJsonLdApiBundle). This bundle will leverage PHP Property Info and the Symfony Serializer Component that will be shipped in Symfony 2.7 to allow powerful deserialization.

Slides à propos des Linked Data et des API REST Hypermedia avec Symfony

Hier j’ai présenté certains de mes travaux autour des Linked Data et de Symfony au sfPot de Lille. Voici la présentation que j’ai projetée :

Voir les slides en plein écran.

sfPot à Lille sur Docker et le web sémantique avec Symfony

Alexandre Salomé (SensioLabs) et moi ( animeront un nouvel apéro Symfony à Lille le 15 janvier.

Au programmes deux talks :

  • L’un sur le web de données avec Symfony ou seront évoqués les APIs REST, l’hypermedia,, PHP Schema et HydraBundle.
  • L’autre sur Docker ou l’on parlera… de Docker !

Tout cela arrosé de bières belges.

Rendez-vous le 15 janvier à 19h au Bar Braz rue Doudain à Lille.

Sfpot 15 janvier

Generate a Symfony password hash from the command line

There is an easy way to generate a Symfony compliant password hash from the command line. Assuming you’re using the bcrypt algorithm (the preferred choice according to Symfony’s security best practices), the default cost (13) and you have PHP >= 5.5 installed, just run the following command:

 It will output something like:  $2y$13$7mBTrD0lgdgBxt1.YbdvOOeSOrPUYOBfeC1Ra2osPs9lpCHdplw1m

You can directly use this value in your app/config/security.yml  file:

Thanks to Sarah Khalil, a built-in Symfony command will be available in a next release (and that command will support all installed algorithms).

CoopTilleulsOVHBundle: OVH SDK integration in Symfony

I’ve just released a new tiny open source bundle under the umbrella: CoopTilleulsOvhBundle.

That bundle integrates the official PHP SDK provided by OVH and exposes it as a Symfony service. It also provides a convenient way to store API credentials in parameters.yml.

The OVH API provides a lot of features including dynamic server management (elasticity) and monitoring, SMS sending, telephony configuration, billing… Almost all services provided by the first european internet hosting company (from Roubaix, France – our neighbors!) are exposed through their API, and can now be used from any Symfony application.

As usual, the source code and tests are freely available on our GitHub account. The bundle can be installed using Composer.

“Persistence in PHP with Doctrine ORM” eBook for $5 until January 6th 2015

Persistence in PHP with the Doctrine ORM


Thanks to Packt’s eBook Bonanza, my book “Persistence in PHP with Doctrine ORM” is available for only $5 until January 6th. Enjoy it!

What you will learn from this book

  • Install Doctrine through the Composer dependency manager
  • Configure Doctrine Command Line Tools
  • Learn to manage relations between entities with different association types
  • Create data fixtures, a custom entity repository, and native SQL queries
  • Master the query builder to generate DQL queries
  • Get started with inheritance and lifecycle events

In Detail

Doctrine 2 has become the most popular modern persistence system for PHP. It can either be used as a standalone system or can be distributed with Symfony 2, and it also integrates very well with popular frameworks. It allows you to easily retrieve PHP object graphs, provides a powerful object-oriented query language called DQL, a database schema generator tool, and supports database migration. It is efficient, abstracts popular DBMS, and supports PHP 5.3 features.

Doctrine is a must-have for modern PHP applications.

Persistence in PHP with the Doctrine ORM is a practical, hands-on guide that describes the full creation process of a web application powered by Doctrine. Core features of the ORM are explained in depth and illustrated by useful, explicit, and reusable code samples.

Persistence in PHP with the Doctrine ORM explains everything you need to know to get started with Doctrine in a clear and detailed manner.

From installing the ORM through Composer to mastering advanced features such as native queries, this book is a full overview of the power of Doctrine. You will also learn a bunch of mapping annotations, create associations, and generate database schemas from PHP classes. You will also see how to write data fixtures, create custom entity repositories, and issue advanced DQL queries. Finally it will teach you to play with inheritance, write native queries, and use built-in lifecycle events. If you want to use a powerful persistence system for your PHP application, Persistence in PHP with the Doctrine ORM is the book you.


Persistence in PHP with the Doctrine ORM is a concise, fast, and focused guide to build a blog engine with advanced features such as native queries and lifecycle callbacks.

Who this book is for

This book is primarily intended for PHP developers and architects who want to increase their skills in the field of Persistence and ORM to map the data they are working on to objects they are using in programming. Basic knowledge of databases and PDO and working knowledge of PHP namespaces is a prerequisite.


Two free chapters are available on the Pack website.

PHP Schema: generate a fully functional PHP / Doctrine / Symfony data model from vocabulary in minutes

PHP Schema is a code generator that instantly generates a PHP data model from the vocabulary : browse, choose the types and properties you need, run our code generator and you’re done! You get a fully featured PHP data model including:

  • A set of PHP entities with properties, constants (enum values), getters, setters, adders and removers. The class hierarchy provided by will be translated to a PHP class hierarchy with parents as abstract classes. The generated code complies with PSR coding standards.
  • Full high-quality PHPDoc for classes, properties, constants and methods extracted from
  • Doctrine ORM annotation mapping including database columns with type guessing, relations with cardinality guessing, class inheritance (through the @AbstractSuperclass annotation).
  • Data validation through Symfony Validator annotations including data type validation, enum support (choices) and check for required properties.
  • Interfaces and Doctrine ResolveTargetEntityListener support.
    Custom PHP namespace support.
  • List of values provided by with PHP Enum classes.


  • The code generator is fully configurable and extensible: all features can be deactivated (e.g.: the Doctrine mapping generator) and custom generator can be added (e.g.: a Doctrine ODM mapping generator).
  • The generated code can be used as is in a Symfony app (but it will work too in a raw PHP project or any other framework including Laravel and Zend Framework).

Why use data to generate a PHP model?

Don’t Reinvent The Wheel

Data models provided by are popular and have been proved efficient. They cover a broad spectrum of topics including creative work, e-commerce, event, medicine, social networking, people, postal address, organization, place or review. has its root in a ton of preexisting well designed vocabularies and is successfully used by more and more website and applications.

Pick up schemas applicable to your application, generate your PHP model, then customize and specialize it to fit your needs.

Improve SEO and user experience

Adding markup to websites and apps increase their ranking in search engines results and enable awesome features such as Google Rich Snippets and Gmail markup.

Mapping your app data model to structures can be a tedious task. Using the generator, your data model will be a derived from Adding microdata markup to your templates or serializing your data as JSON-LD will not require specific mapping nor adaptation. It’s a matter of minutes.

Be ready for the future improves the interoperability of your applications. Used with hypermedia technologies such as Hydra it’s a big step towards the semantic and machine readable web. It opens the way to generic web API clients able to extract and process data from any website or app using such technologies.

PHP 7: Introducing a domain name validator and making the URL validator stricter

PHP Origami

DNS comes with a set of rules defining valid domain names. A domain name cannot exceed 255 octets (RFC 1034) and each label cannot exceed 63 octets (RFC 1035). It can contain any character (RFC 2181) but extra rules apply for hostnames (A and MX records, data of SOA and NS records): only alphanumeric ASCII characters and hyphens are allowed in labels (we’ll talk about IDNs at the end of this post), and they cannot start nor end with a hyphen.

Until now, there was no PHP’s filter validating that a given a string is a valid domain name (or hostname). Worst,  FILTER_VALIDATE_URL was not fully enforcing domain name validity (this is mandatory for schemes such as http and https) and was allowing invalid URLs. FILTER_VALIDATE_URL was also lacking IPv6 host support.

These limitations will be fixed in PHP 7. I’ve introduced a new FILTER_VALIDATE_DOMAIN filter checking domain name and hostname validity. This new filter is now used internally by the URL validator. I also added IPv6 host support in URL validation:

There is still a big lack in PHP’s domain names and URLs handling: internationalized domain names are not supported at all in the core. I’ve already blogged about an userland workaround, but as IDNs becomes more and more popularsa core support by PHP in streams and validation is necessary. For instance, almost all french registrars support them, and even TLDs – such as the Chinese one – are available in the wild in a non-ASCII form). I’ve started a patch enabling IDN support in PHP’s streams. It works on Unix but still lacks a Windows build system. As it requires making ICU a dependency of PHP, I’ll publish a PHP RFC on this topic soon!