Pierre-Charles Bertineau



Situation professionnelle

En poste
En simple veille


Diplômé en 2007 après un de stage chez Renault Sport, je m'engage dans une jeune entreprise du libre à Nantes. Je fais mes armes entre Assistance Technique et R&D, intervenant en conception et développement dans des contextes variés : industrie, service/transport, banque, édition logicielle, organismes publics. Je me suis ensuite orienté spécifiquement vers le web en travaillant pour Sellermania, fournisseur d'un service en ligne de gestion de catalogue pour les e-commerçants des marketplaces.
Depuis 2013, je crée des sites et applications web à l'agence web nantaise Le Phare, qui regroupe en son sein toutes les compétences pour mener le développement internet de ses clients.
Je suis tout particulièrement investi le développement de la plateforme technique de Kiplin, une startup incubée au Phare.

Mon bagage technique repose pour l'essentiel sur la connaissance des architectures et frameworks PHP (actuellement sur Symfony2), bases de données, langages web et architectures techniques.

AlterPHP's blog

I'm a backend web developer, mainly developing upon Symfony framework. This is the place where I share my development tools and tricks.

Symfony 3.2 brings support of PHP constants in YAML
23 août 2017
A nice improvement of Symfony 3.2 is support of PHP constants in YAML files. This allows to define a service from a class and some constructor parameters defined as PHP constants, all in a services.yml file (no PHP code involved, just inject it !). Let's try it with a PSR-7 HTTP client : services: # Concrete implementation of HTTP client app.api_client.http_client:
Voir l'article
Access static methods/properties from Twig
11 févr. 2016
Classic stuff we need while using Twig : access static properties or call static methods of any class. Reflection Extension Downloadable from my Github repository namespace SiteBundle\Twig\Extension; class Reflection extends \Twig_Extension { /** * {@inheritdoc} */ public function getFunctions() { return array( new \Twig_SimpleFunction('call_static
Voir l'article
30 janv. 2015
A short post to promote a new tool developed by my friend Alain Tiemblo : TwigFiddle. You can now test your templates, macros, and share your Twig code examples with this tool. This is really useful when you post or answer a question about a Twig issue on Stackoverflow (or any other dev forum). So test it and make feedback if you discover an issue or just have any suggestion... twigfiddle.com
Voir l'article
Redirection after registration
10 oct. 2014
Symfony Security bundle provides everything to deal with redirections after login. The most used is based on referer as many pages may require an authentication, and this way you just redirect to the pages that asked for identification. But what happens when user has no account, he needs to register and create its account. Here is a proper way to achieve redirection after registration, dealing
Voir l'article
Doctrine2 optimization with APC cache and Symfony2
13 mai 2014
Some parts of a website are common to every pages and needs to request data from database. To put this data in a cache system is often a first step for optimization. Here is my return on experience about caching data with Doctrine2 in a Symfony2 project. Before caching data, deal with metadata Doctrine metadata store informations about entities structure, relations and so on. It's really safe
Voir l'article
Trace IP with Gedmo IpTraceable behavior
22 avr. 2014
As a strong user of Doctrine2 since I'm working with Symfony2, I also use Gedmo DoctrineExtensions. This library provides a great set of useful features we commonly need when developping web project : Timestampable entities (created_at and updated_at columns on tables), Sluggable entities, Trace creators and modificators on contents (Blameable behavior) ... Since I more often work for sensitive
Voir l'article
The need to state EntityManager name in a UniqueEntity validation constraint [Symfony2, Doctrine2]
27 août 2013
I need to code a backoffice that manages many entities of my sites. Each of my sites has its own bundle with its own database, and a dependency to a common bundle with its own "common" database (for users, logging, billing). For the same reasons, avoid to access default EntityManager from Container, without naming it... It could lead to an error if you embed your bundle in another application
Voir l'article
Symfony on non-standard ports
29 nov. 2012
As Symfony (2.0) doc is not very clear on this subject, I spent some time to help a colleague on the following question : How to make HTTPS port different from 443 ? Of course it's possible, and this is a simple configuration option in app/config.yml : framework: ... # router configuration router: ... http_port: 81 https_port: 1443
Voir l'article
How to inhibit Soap Security headers "mustUnderstand" attribute in a Symfony2 controller
16 oct. 2012
I never managed to make native PHP SoapServer class to handle "understand" soap:Security header as expected with mustUnderstand attribute. But some WS tools like SoapUI automatically set it to "true" or "1" and I needed to make a work around to avoid Soap Fault : "SOAP-ENV:MustUnderstand / Header not understood" Here is a controller action that inhib mustUnderstand attribute : public
Voir l'article
How to read Soap WSSE headers
16 oct. 2012
While following Symfony2 WSSE implementation tutorial, I was annoyed by the suggested WSSE headers interpretation. It only presents HTTP headers, not Soap WSSE headers... Here is an extract of Symfony2 tutorial, handling HTTP headers : $wsseRegex = '/UsernameToken Username="([^"]+)", PasswordDigest="([^"]+)", Nonce="([^"]+)", Created="([^"]+)"/'; if (!$request->headers->has('
Voir l'article
How to deal with asynchronous request with Symfony2 and other PHP frameworks
06 août 2012
As well as most of PHP frameworks, Symfony2 manages user session by locking it during request treatment. It avoids concurrent access to session file but makes requests to be queued until session lock is freed... This behaviour is really well explained in this post from Gareth McCumskey. As Gareth describes his solution, we need to manually free session lock after all session modifications
Voir l'article
I need help on groups validation !
26 juin 2012
I handle a multi-tab form that is validated by one group per form-tab. When I get errors while binding request, I'd like to know the first tab (ie validation group) that is not valid. Is it possible with Symfony 2.0, and how ? Please feel free to post your answer on StackOverflow, I will then publish it here. Thanks in advance !
Voir l'article
How to set a related entity with Doctrine2
15 avr. 2012
When you want to set a related entity to another one, no need request the related object ! Doctrine ORM provides EntityManager::getReference($entityName, $id) method that only returns a reference to a record, not the entity itself... Let's see it in action : <php // ... //This line gets the reference to the Comment record with primary key is #5 $comment = $em->getReference('
Voir l'article
Set up a specific log file for connections with Symfony2
11 avr. 2012
Symfony2 basically embeds a full-featured logger, Monolog. A default implementation is available as 'logger' service. But you may need to log to a specifi file instead of traditional dev/prod/test.log... This article shows how to define a specific logger for connections. I don't need to re-code a logger, the default one perfectly works. I just need to define a new file to log in, so a Monolog
Voir l'article
Custom form validation constraint with Callback in Symfony2
11 avr. 2012
Symfony2 forms provides many embedded validators to constrain data passed in form fields. Here is the way to define a constraint in a callback function, useful to determine a data validity relative to another field... Given a form asking the user to chose its favorite payment ways, in a shopping application : <?php namespace Acme\DemoBundle\Form; use Symfony\Component\Form\AbstractType; use
Voir l'article
No underscores in subdomains !
20 févr. 2012
After a few hours spent on pulling out my hair (typical french-speaking), I discovered that underscores in web subdomains are not RFC compliant, and that, for once, Internet Explorer strictly follows RFC recommendations ! No session persistance in IE with an underscore in your subdomain !
Voir l'article
How to create a Service to embed business logic functions in Symfony2
05 déc. 2011
Services are classes where you will write the Business Logic code or any other treatment that you want to make accessible to a controller or another service. The Logger delivered with Symfony2 is a service, like the Registry of Doctrine, which gives access to the EntityManager. The example below shows how to create a service, to pass two services it can use as parameters. 1- We begin by
Voir l'article
Set up an AuthenticationSuccessHandler in Symfony2
31 oct. 2011
Symfony2 allows you to simply make treatments after a login attempt success. As simple as you just have to define a service, called "security.authentication.success_handler" and make it to implement AuthenticationSuccessHandlerInterface... In this example, I want logged new user to be redirected to a "Terms and conditions" accept form. I have to check the boolean property termsAndConditionsOk of
Voir l'article
Deal with a nullable relation field in an Entity with Doctrine2
04 oct. 2011
Entity generation from an existing database is a long way to go... Last issue : set a relation field to NULL => the generated setter expects an Entity Object as a parameter MyEntity is an entity including a field myRelatedEntity referencing an entity MyRelatedEntity. Basic generation produces this setter : class MyEntity { ... /** * Set myRelatedEntity * * @param Xxx\
Voir l'article
Configuration trick for multiple entity managers in Symfony2
04 oct. 2011
First time I tried to define multiple entity managers in config.yml, i got some errors... I didn't strictly followed symfony cookbook but based my configuration on the reference about Doctrine configuration. So I let "auto_mapping" parameter with false value, and I got following error : InvalidConfigurationException: Unrecognized options "auto_mapping" under "doctrine.orm" So if you want
Voir l'article
Deal with SET field in your entities with Doctrine2 / Symfony2
26 sept. 2011
Given MyEntity is an entity (mapping table my_entity), given mySetField is a MySQL SET field from this entity (mapping column my_set_field). Its admissible values are 'Value1', 'Value2' and 'Value3' : <?php namespace MyCompany\MyBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * MyCompany\MyBundle\Entity\MyEntity */ class MyEntity { //SET de la colonne my_set_field const
Voir l'article
Deal with ENUM fields in your entities with Doctrine2 / Symfony2
18 sept. 2011
MyEntity is an entity (mapping table my_entity), myEnumField is a MySQL ENUM field from this entity (mapping column my_enum_field). Its admissible values are 'Value1', 'Value2' and 'Value3' : <?php namespace MyCompany\MyBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * MyCompany\MyBundle\Entity\MyEntity */ class MyEntity { //ENUM de la colonne my_enum_field const
Voir l'article
Deal with MySQL types natively unsupported by Doctrine2
18 sept. 2011
Some types of data, specific to MySQL are not supported by Doctrine2 when generating the mapping and entities from an existing database (reverse engineering). Nevertheless, there remains the possibility to easily convert them into basic types. Example with ENUM, VARBINARY and TINYBLOB types. Everything goes in app/config.yml, in the "doctrine" section (only conf, very convenient), see the "
Voir l'article
Use ApcCache to cache any PHP data in Symfony2
08 août 2011
APC is the most well-known caching system for PHP, and maybe one of the simpliest. Symfony2 strongly suggests to enable it, as well on development than production environment. Sf2 natively uses APC to cache PHP files as OPCODE. But you can cache what you want in your code, any kind of PHP data. APC makes the distinction between PHP OPCODE cache and custom cache : File cache gets PHP OPCODE,
Voir l'article
Redirection with Cookie sending in Symfony2
04 août 2011
As i apply a redirection after switching language, i'd like to send a cookie to store the last selected language for the user. But Symfony2 RedirectResponse default constructor doesn't allow to do this.... Here is a class extanding RedirectResponse that takes an array of Cookie objects as third parameters : This component is downloadable and forkable on my Git repository : http://github.com/
Voir l'article