{"id":441,"date":"2014-07-12T20:06:54","date_gmt":"2014-07-12T19:06:54","guid":{"rendered":"http:\/\/louis.hatier.me\/blog\/?p=441"},"modified":"2018-08-18T14:10:33","modified_gmt":"2018-08-18T13:10:33","slug":"convention-code-php","status":"publish","type":"post","link":"https:\/\/louis.hatier.me\/blog\/convention-code-php\/","title":{"rendered":"Convention de code PHP"},"content":{"rendered":"<p dir=\"ltr\"><a title=\"\" href=\"http:\/\/louis.hatier.me\/blog\/wp-content\/uploads\/2013\/10\/php.jpg\" data-rel=\"lightbox-gallery-yNtGXQ2N\" data-rl_title=\"\" data-rl_caption=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-78 alignleft\" title=\"Logo PHP\" src=\"http:\/\/louis.hatier.me\/blog\/wp-content\/uploads\/2013\/10\/php.jpg\" alt=\"Logo PHP\" width=\"220\" height=\"156\" \/><\/a>Pouvoir relire le code \u00e9crit par une autre personne est tr\u00e8s important, de m\u00eame que tout le monde doit pouvoir lire votre code <strong>facilement<\/strong>. Bien sur si personne n\u2019est amen\u00e9 \u00e0 parcourir votre code vous pouvez faire comme bon vous semble.<\/p>\n<p dir=\"ltr\">Mais l\u2019id\u00e9e g\u00e9n\u00e9rale est qu\u2019en lisant le code source d\u2019un projet, on doit avoir l\u2019impression que c\u2019est la m\u00eame et <strong>unique personne<\/strong> qui a tout \u00e9crit. Et de la m\u00eame fa\u00e7on entre les diff\u00e9rents projets. Cela aide \u00e0 lire et \u00e0 comprendre plus rapidement le contenu qui est \u00e9crit.<\/p>\n<p dir=\"ltr\">C\u2019est surtout important dans le travail collaboratif et le maintient des sites\/applications.<\/p>\n<p dir=\"ltr\">Cette id\u00e9e est pr\u00e9sente dans de nombreux langages, nous allons voir ici comment \u00e7a se passe pour le <strong>PHP<\/strong>.<\/p>\n<p dir=\"ltr\"><!--more--><\/p>\n<p dir=\"ltr\">Si vous avez d\u00e9j\u00e0 mis le nez dans le code d\u2019un framework type <a href=\"http:\/\/louis.hatier.me\/blog\/zf2-introduction\/\"><strong>Zend Framework 2<\/strong><\/a> ou <a href=\"http:\/\/louis.hatier.me\/blog\/symfony2-gerer-lidentification-utilisateur-ldap\/\"><strong>Symfony2<\/strong><\/a>, vous avez du vous apercevoir que le code est toujours \u00e9crit de la m\u00eame mani\u00e8re, en suivant la m\u00eame convention.<\/p>\n<p dir=\"ltr\">Le <a title=\"PHP Framework Interop Group\" href=\"http:\/\/www.php-fig.org\/\" target=\"_blank\" rel=\"noopener\">PHP Framework Interop Group<\/a> regroupe diff\u00e9rents projets qui participent et suivent les m\u00eames conventions de code. Pour en citer quelques-uns : CakePHP, Doctrine, Drupal, Laravel, PEAR, PrestaShop, Symfony2, Zend Framework 2 etc.<\/p>\n<p dir=\"ltr\">Tous suivent les <strong>standards<\/strong> PSR-0, PSR-1, PSR-2, PSR-3, PSR-4 disponible sur <a title=\"PSR\" href=\"https:\/\/github.com\/php-fig\/fig-standards\/tree\/master\/accepted\" target=\"_blank\" rel=\"noopener\">GitHub<\/a>.<\/p>\n<p dir=\"ltr\">Voici une autre lecture int\u00e9ressante \u00e0 ce sujet, qui va plus loin que les simples conventions de code : <a title=\"PHP The Right Way\" href=\"http:\/\/www.phptherightway.com\/\" target=\"_blank\" rel=\"noopener\">PHP The Right Way<\/a>.<\/p>\n<div style=\"padding-bottom:20px; padding-top:10px;\" class=\"hupso-share-buttons\"><!-- Hupso Share Buttons - https:\/\/www.hupso.com\/share\/ --><a class=\"hupso_counters\" href=\"https:\/\/www.hupso.com\/share\/\"><img decoding=\"async\" src=\"https:\/\/static.hupso.com\/share\/buttons\/dot.png\" style=\"border:0px; padding-top:2px; float:left;\" alt=\"Share Button\"\/><\/a><script type=\"text\/javascript\">var hupso_services_c=new Array(\"twitter\",\"facebook_like\",\"pinterest\",\"email\",\"linkedin\");var hupso_counters_lang = \"en_US\";var hupso_image_folder_url = \"\";var hupso_url_c=\"\";var hupso_title_c=\"Convention%20de%20code%20PHP\";<\/script><script type=\"text\/javascript\" src=\"https:\/\/static.hupso.com\/share\/js\/counters.js\"><\/script><!-- Hupso Share Buttons --><\/div>","protected":false},"excerpt":{"rendered":"<p>Pouvoir relire le code \u00e9crit par une autre personne est tr\u00e8s important, de m\u00eame que tout le monde doit pouvoir lire votre code facilement. Bien sur si personne n\u2019est amen\u00e9 \u00e0 parcourir votre code vous pouvez faire comme bon vous semble. Mais l\u2019id\u00e9e g\u00e9n\u00e9rale est qu\u2019en lisant le code source d\u2019un projet, on doit avoir [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[57,18,52],"class_list":["post-441","post","type-post","status-publish","format-standard","hentry","category-php","tag-php","tag-symfony","tag-zf2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Convention de code PHP - Melting Poutre<\/title>\n<meta name=\"description\" content=\"Quelles sont les conventions de code PHP ? Qui les utilise ?\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/louis.hatier.me\/blog\/convention-code-php\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Convention de code PHP - Melting Poutre\" \/>\n<meta property=\"og:description\" content=\"Quelles sont les conventions de code PHP ? Qui les utilise ?\" \/>\n<meta property=\"og:url\" content=\"https:\/\/louis.hatier.me\/blog\/convention-code-php\/\" \/>\n<meta property=\"og:site_name\" content=\"Melting Poutre\" \/>\n<meta property=\"article:published_time\" content=\"2014-07-12T19:06:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-08-18T13:10:33+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/louis.hatier.me\/blog\/wp-content\/uploads\/2013\/10\/php.jpg\" \/>\n<meta name=\"author\" content=\"Louis Hatier\" \/>\n<meta name=\"twitter:label1\" content=\"\u00c9crit par\" \/>\n\t<meta name=\"twitter:data1\" content=\"Louis Hatier\" \/>\n\t<meta name=\"twitter:label2\" content=\"Dur\u00e9e de lecture estim\u00e9e\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/louis.hatier.me\/blog\/convention-code-php\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/louis.hatier.me\/blog\/convention-code-php\/\"},\"author\":{\"name\":\"Louis Hatier\",\"@id\":\"https:\/\/louis.hatier.me\/blog\/#\/schema\/person\/2f200d0368def135b452e65491c4dd11\"},\"headline\":\"Convention de code PHP\",\"datePublished\":\"2014-07-12T19:06:54+00:00\",\"dateModified\":\"2018-08-18T13:10:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/louis.hatier.me\/blog\/convention-code-php\/\"},\"wordCount\":250,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/louis.hatier.me\/blog\/#\/schema\/person\/2f200d0368def135b452e65491c4dd11\"},\"image\":{\"@id\":\"https:\/\/louis.hatier.me\/blog\/convention-code-php\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/louis.hatier.me\/blog\/wp-content\/uploads\/2013\/10\/php.jpg\",\"keywords\":[\"PHP\",\"Symfony\",\"ZF2\"],\"articleSection\":[\"PHP\"],\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/louis.hatier.me\/blog\/convention-code-php\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/louis.hatier.me\/blog\/convention-code-php\/\",\"url\":\"https:\/\/louis.hatier.me\/blog\/convention-code-php\/\",\"name\":\"Convention de code PHP - Melting Poutre\",\"isPartOf\":{\"@id\":\"https:\/\/louis.hatier.me\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/louis.hatier.me\/blog\/convention-code-php\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/louis.hatier.me\/blog\/convention-code-php\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/louis.hatier.me\/blog\/wp-content\/uploads\/2013\/10\/php.jpg\",\"datePublished\":\"2014-07-12T19:06:54+00:00\",\"dateModified\":\"2018-08-18T13:10:33+00:00\",\"description\":\"Quelles sont les conventions de code PHP ? Qui les utilise ?\",\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/louis.hatier.me\/blog\/convention-code-php\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/louis.hatier.me\/blog\/convention-code-php\/#primaryimage\",\"url\":\"http:\/\/louis.hatier.me\/blog\/wp-content\/uploads\/2013\/10\/php.jpg\",\"contentUrl\":\"http:\/\/louis.hatier.me\/blog\/wp-content\/uploads\/2013\/10\/php.jpg\"},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/louis.hatier.me\/blog\/#website\",\"url\":\"https:\/\/louis.hatier.me\/blog\/\",\"name\":\"Melting Poutre\",\"description\":\"Du web et d&#039;autres choses\",\"publisher\":{\"@id\":\"https:\/\/louis.hatier.me\/blog\/#\/schema\/person\/2f200d0368def135b452e65491c4dd11\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/louis.hatier.me\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/louis.hatier.me\/blog\/#\/schema\/person\/2f200d0368def135b452e65491c4dd11\",\"name\":\"Louis Hatier\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/louis.hatier.me\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cd8d107ede5a4ec340326655e74a00ca62b02e41a02442f961c36f085aa89942?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cd8d107ede5a4ec340326655e74a00ca62b02e41a02442f961c36f085aa89942?s=96&d=mm&r=g\",\"caption\":\"Louis Hatier\"},\"logo\":{\"@id\":\"https:\/\/louis.hatier.me\/blog\/#\/schema\/person\/image\/\"},\"sameAs\":[\"https:\/\/louis.hatier.me\",\"https:\/\/www.linkedin.com\/in\/louishatier\/\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Convention de code PHP - Melting Poutre","description":"Quelles sont les conventions de code PHP ? Qui les utilise ?","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/louis.hatier.me\/blog\/convention-code-php\/","og_locale":"fr_FR","og_type":"article","og_title":"Convention de code PHP - Melting Poutre","og_description":"Quelles sont les conventions de code PHP ? Qui les utilise ?","og_url":"https:\/\/louis.hatier.me\/blog\/convention-code-php\/","og_site_name":"Melting Poutre","article_published_time":"2014-07-12T19:06:54+00:00","article_modified_time":"2018-08-18T13:10:33+00:00","og_image":[{"url":"http:\/\/louis.hatier.me\/blog\/wp-content\/uploads\/2013\/10\/php.jpg","type":"","width":"","height":""}],"author":"Louis Hatier","twitter_misc":{"\u00c9crit par":"Louis Hatier","Dur\u00e9e de lecture estim\u00e9e":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/louis.hatier.me\/blog\/convention-code-php\/#article","isPartOf":{"@id":"https:\/\/louis.hatier.me\/blog\/convention-code-php\/"},"author":{"name":"Louis Hatier","@id":"https:\/\/louis.hatier.me\/blog\/#\/schema\/person\/2f200d0368def135b452e65491c4dd11"},"headline":"Convention de code PHP","datePublished":"2014-07-12T19:06:54+00:00","dateModified":"2018-08-18T13:10:33+00:00","mainEntityOfPage":{"@id":"https:\/\/louis.hatier.me\/blog\/convention-code-php\/"},"wordCount":250,"commentCount":0,"publisher":{"@id":"https:\/\/louis.hatier.me\/blog\/#\/schema\/person\/2f200d0368def135b452e65491c4dd11"},"image":{"@id":"https:\/\/louis.hatier.me\/blog\/convention-code-php\/#primaryimage"},"thumbnailUrl":"http:\/\/louis.hatier.me\/blog\/wp-content\/uploads\/2013\/10\/php.jpg","keywords":["PHP","Symfony","ZF2"],"articleSection":["PHP"],"inLanguage":"fr-FR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/louis.hatier.me\/blog\/convention-code-php\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/louis.hatier.me\/blog\/convention-code-php\/","url":"https:\/\/louis.hatier.me\/blog\/convention-code-php\/","name":"Convention de code PHP - Melting Poutre","isPartOf":{"@id":"https:\/\/louis.hatier.me\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/louis.hatier.me\/blog\/convention-code-php\/#primaryimage"},"image":{"@id":"https:\/\/louis.hatier.me\/blog\/convention-code-php\/#primaryimage"},"thumbnailUrl":"http:\/\/louis.hatier.me\/blog\/wp-content\/uploads\/2013\/10\/php.jpg","datePublished":"2014-07-12T19:06:54+00:00","dateModified":"2018-08-18T13:10:33+00:00","description":"Quelles sont les conventions de code PHP ? Qui les utilise ?","inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/louis.hatier.me\/blog\/convention-code-php\/"]}]},{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/louis.hatier.me\/blog\/convention-code-php\/#primaryimage","url":"http:\/\/louis.hatier.me\/blog\/wp-content\/uploads\/2013\/10\/php.jpg","contentUrl":"http:\/\/louis.hatier.me\/blog\/wp-content\/uploads\/2013\/10\/php.jpg"},{"@type":"WebSite","@id":"https:\/\/louis.hatier.me\/blog\/#website","url":"https:\/\/louis.hatier.me\/blog\/","name":"Melting Poutre","description":"Du web et d&#039;autres choses","publisher":{"@id":"https:\/\/louis.hatier.me\/blog\/#\/schema\/person\/2f200d0368def135b452e65491c4dd11"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/louis.hatier.me\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":["Person","Organization"],"@id":"https:\/\/louis.hatier.me\/blog\/#\/schema\/person\/2f200d0368def135b452e65491c4dd11","name":"Louis Hatier","image":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/louis.hatier.me\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cd8d107ede5a4ec340326655e74a00ca62b02e41a02442f961c36f085aa89942?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cd8d107ede5a4ec340326655e74a00ca62b02e41a02442f961c36f085aa89942?s=96&d=mm&r=g","caption":"Louis Hatier"},"logo":{"@id":"https:\/\/louis.hatier.me\/blog\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/louis.hatier.me","https:\/\/www.linkedin.com\/in\/louishatier\/"]}]}},"_links":{"self":[{"href":"https:\/\/louis.hatier.me\/blog\/wp-json\/wp\/v2\/posts\/441","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/louis.hatier.me\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/louis.hatier.me\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/louis.hatier.me\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/louis.hatier.me\/blog\/wp-json\/wp\/v2\/comments?post=441"}],"version-history":[{"count":6,"href":"https:\/\/louis.hatier.me\/blog\/wp-json\/wp\/v2\/posts\/441\/revisions"}],"predecessor-version":[{"id":654,"href":"https:\/\/louis.hatier.me\/blog\/wp-json\/wp\/v2\/posts\/441\/revisions\/654"}],"wp:attachment":[{"href":"https:\/\/louis.hatier.me\/blog\/wp-json\/wp\/v2\/media?parent=441"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/louis.hatier.me\/blog\/wp-json\/wp\/v2\/categories?post=441"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/louis.hatier.me\/blog\/wp-json\/wp\/v2\/tags?post=441"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}