<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Php on Outweb</title><link>https://outweb.eu/tags/php/</link><description>Recent content in Php on Outweb</description><image><title>Outweb</title><url>https://outweb.eu/images/seo/outweb-default-og.svg</url><link>https://outweb.eu/images/seo/outweb-default-og.svg</link></image><generator>Hugo</generator><language>fr-FR</language><lastBuildDate>Mon, 03 Dec 2018 09:00:25 +0000</lastBuildDate><atom:link href="https://outweb.eu/tags/php/feed.xml" rel="self" type="application/rss+xml"/><item><title>Analyse de code statique avec phpstan</title><link>https://outweb.eu/2018/12/03/analyse-de-code-static-avec-phpstan/</link><pubDate>Mon, 03 Dec 2018 09:00:25 +0000</pubDate><guid isPermaLink="false">https://outweb.eu/2018/12/03/analyse-de-code-static-avec-phpstan/</guid><description>&lt;p>&lt;a href="https://github.com/phpstan/phpstan">Phpstan&lt;/a> est un outil en ligne de commande qui va vous permettre de détecter automatiquement les erreurs les plus simples en scannant l&amp;rsquo;intégralité de votre projet.&lt;/p>
&lt;figure>
&lt;img loading="lazy" src="https://github.com/phpstan/phpstan/raw/master/build/phpstan.gif"/>
&lt;/figure>
&lt;p>De base, l&amp;rsquo;outil va analyser une application PHP sans tenir compte des spécificités des différents frameworks et librairies. C&amp;rsquo;est pourquoi il existe des extensions comme &lt;a href="https://github.com/phpstan/phpstan-symfony">PHPstan Symfony&lt;/a> pour affiner l&amp;rsquo;analyse.&lt;/p>
&lt;p>Si comme moi vous voulez l&amp;rsquo;utiliser sur un projet qui a beaucoup de legacy (plus de 10 ans) vous allez avoir un rapport gigantesque. Il faut trouver des solutions pour réduire le rapport à la pull request (merge request) que l&amp;rsquo;on doit relire.&lt;/p></description></item><item><title>Du machine learning dans mes cocktails</title><link>https://outweb.eu/2018/11/08/du-machine-learning-dans-mes-cocktails/</link><pubDate>Thu, 08 Nov 2018 07:37:00 +0000</pubDate><guid isPermaLink="false">https://outweb.eu/2018/11/08/du-machine-learning-dans-mes-cocktails/</guid><description>&lt;p>Dans cet article, nous allons parler Mojitos, machine learning et PHP, trois sujets que l&amp;rsquo;on mélange assez rarement, mais qui dans le cas du site &lt;a href="https://cocktailand.fr">Cocktailand&lt;/a> sont rassemblés.&lt;/p>
&lt;h2 id="use-case">Use case&lt;/h2>
&lt;p>Je souhaite afficher la recette de cocktail qui ressemble le plus à celle que le visiteur est en train de lire. Comme je suis finalement quelqu&amp;rsquo;un d&amp;rsquo;assez fainéant, je n&amp;rsquo;ai pas envie de maintenir des listes de cocktails associés manuellement. Il faut donc trouver un moyen de calculer automatiquement cette liste pour les quelques 600 recettes et que cette liste soit mise à jour automatiquement pour intégrer les nouvelles recettes.&lt;/p></description></item><item><title>Afficher des graphiques avec JQPlot</title><link>https://outweb.eu/2011/08/16/afficher-des-graphiques-avec-jqplot/</link><pubDate>Tue, 16 Aug 2011 06:28:46 +0000</pubDate><guid isPermaLink="false">https://outweb.eu/2011/08/16/afficher-des-graphiques-avec-jqplot/</guid><description>&lt;p>JQPlot est un plugin JQuery qui permet de dessiner des graphiques dans vos pages HTML. Si vous faites des pages de statistiques sur vos pages Internet vous comprendrez rapidement quelles sont les applications et surtout en quoi il vous simplifie les choses. En effet, il vous suffit de lui donner les données et de décider quel type de graphique vous voulez obtenir en sortie et le tour est joué ! On peut facilement imager une fonction PHP (ou autre) qui va générer les données qu&amp;rsquo;il faut mettre en entrée de JQPlot à partir de votre base de données.&lt;/p></description></item><item><title>Sécurité PHP</title><link>https://outweb.eu/2011/08/02/securite-php/</link><pubDate>Tue, 02 Aug 2011 18:21:33 +0000</pubDate><guid isPermaLink="false">https://outweb.eu/2011/08/02/securite-php/</guid><description>&lt;blockquote>
&lt;p>Les informations de cet article datent&lt;/p>&lt;/blockquote>
&lt;p>L&amp;rsquo;actualité étant chargée niveau hack, il est temps de sortir un petit article présentant différentes méthodes de sécurisation d&amp;rsquo;une application PHP.&lt;br>
Je vais donc brièvement vous présenter différentes librairies ou classes PHP orientées sécurité.&lt;/p>
&lt;ul>
&lt;li>&lt;a href="https://phpids.org/">PHPIDS&lt;/a>&lt;br>
Un monitoring complet des actions de l&amp;rsquo;utilisateur avec évaluation de la dangerosité de chaque requête, et de la session. L&amp;rsquo;outil indispensable pour détecter les recherches de failles.&lt;/li>
&lt;li>&lt;a href="http://www.phpclasses.org/package/2189-PHP-Filter-out-unwanted-PHP-Javascript-HTML-tags-.html">Input filter&lt;/a>&lt;br>
Cette librairie permet de filtrer les tableaux $_GET, $_POST, $_REQUEST pour y detecter le PHP, JavaScript et HTML.&lt;/li>
&lt;li>&lt;a href="http://code.google.com/p/anticsurf/">Anti csrf&lt;/a>&lt;br>
Permet d&amp;rsquo;ajouter un token dans ses formulaires afin de ne pas se les faire détourner. Le but étant que chaque formulaire ne soit soumis qu&amp;rsquo;une seule fois.&lt;/li>
&lt;/ul>
&lt;p>L&amp;rsquo;utilisation des librairies précédentes est un complément mais elles ne constituent pas une sécurité optimale à elles seules.&lt;/p></description></item><item><title>Commencer un petit site Internet avec Instant Blueprint</title><link>https://outweb.eu/2011/07/12/commencer-un-petit-site-internet-avec-instant-blueprint/</link><pubDate>Tue, 12 Jul 2011 08:00:48 +0000</pubDate><guid isPermaLink="false">https://outweb.eu/2011/07/12/commencer-un-petit-site-internet-avec-instant-blueprint/</guid><description>&lt;p>Instant Blueprint est un service en ligne qui vous permet en quelques clics de mettre en place une architecture de base pour votre nouveau projet de site Internet. En effet, après avoir renseigné quelques informations, il va vous générer automatiquement le squelette de votre site Internet.&lt;/p>
&lt;p>Pour utiliser cet outil, il vous faut renseigner :&lt;/p>
&lt;ul>
&lt;li>Titre du projet&lt;/li>
&lt;li>Le doctype désiré&lt;/li>
&lt;li>Le framework javascript à inclure&lt;/li>
&lt;li>Comment inclure le framework (local ou distant, compressé ou normal)&lt;/li>
&lt;li>L&amp;rsquo;extension du fichier index (html, htm, php, asp)&lt;/li>
&lt;li>Que mettre dans le dossier include (config.php et/ou fonction.php)&lt;/li>
&lt;li>Centrer ou non le contenu du site&lt;/li>
&lt;li>Les principales div de la page&lt;/li>
&lt;/ul>
&lt;p>Voici le squelette généré :&lt;/p></description></item><item><title>Système de pagination sous CodeIgniter</title><link>https://outweb.eu/2011/06/08/systeme-de-pagination-sous-codeigniter/</link><pubDate>Wed, 08 Jun 2011 09:45:58 +0000</pubDate><guid isPermaLink="false">https://outweb.eu/2011/06/08/systeme-de-pagination-sous-codeigniter/</guid><description>&lt;p>Avec Codigniter vous pouvez mettre en place simplement un système de pagination pour afficher vos informations par paquets. Tout cela sans se prendre la tête et se noyer dans des dizaines de lignes de code.&lt;/p>
&lt;p>Nous allons créer la base de donnée de l&amp;rsquo;article : &lt;a href="https://outweb.eu/2011/06/04/installation-et-configuration-de-codeigniter/">Installation et Configuration de CodeIgniter&lt;/a> .&lt;/p>
&lt;p>Dans un premier temps il créer le model. Pour cela nous allons utiliser la classe active record de CodeIgniter.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-gdscript3" data-lang="gdscript3">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">class&lt;/span> model &lt;span style="color:#66d9ef">extends&lt;/span> CI_Model {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> function __construct()
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">//&lt;/span> Call the Model constructor
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> parent::__construct();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> public function getAll(&lt;span style="color:#f92672">$&lt;/span>debut&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#ae81ff">0&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">return&lt;/span> &lt;span style="color:#f92672">$&lt;/span>this&lt;span style="color:#f92672">-&amp;gt;&lt;/span>db&lt;span style="color:#f92672">-&amp;gt;&lt;/span>select(&lt;span style="color:#e6db74">&amp;#39;*&amp;#39;&lt;/span>)&lt;span style="color:#f92672">-&amp;gt;&lt;/span>from(&lt;span style="color:#e6db74">&amp;#39;message&amp;#39;&lt;/span>)&lt;span style="color:#f92672">-&amp;gt;&lt;/span>order_by(&lt;span style="color:#e6db74">&amp;#34;id&amp;#34;&lt;/span>, &lt;span style="color:#e6db74">&amp;#34;desc&amp;#34;&lt;/span>)&lt;span style="color:#f92672">-&amp;gt;&lt;/span>limit(&lt;span style="color:#ae81ff">30&lt;/span>, &lt;span style="color:#f92672">$&lt;/span>debut)&lt;span style="color:#f92672">-&amp;gt;&lt;/span>get()&lt;span style="color:#f92672">-&amp;gt;&lt;/span>result();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> public function count(&lt;span style="color:#f92672">$&lt;/span>where &lt;span style="color:#f92672">=&lt;/span> array()) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">return&lt;/span> (&lt;span style="color:#a6e22e">int&lt;/span>) &lt;span style="color:#f92672">$&lt;/span>this&lt;span style="color:#f92672">-&amp;gt;&lt;/span>db&lt;span style="color:#f92672">-&amp;gt;&lt;/span>where(&lt;span style="color:#f92672">$&lt;/span>where)&lt;span style="color:#f92672">-&amp;gt;&lt;/span>count_all_results(&lt;span style="color:#e6db74">&amp;#39;message&amp;#39;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Puis nous allons créer notre contrôleur.&lt;/p></description></item><item><title>Installation et Configuration de CodeIgniter</title><link>https://outweb.eu/2011/06/04/installation-et-configuration-de-codeigniter/</link><pubDate>Sat, 04 Jun 2011 12:32:39 +0000</pubDate><guid isPermaLink="false">https://outweb.eu/2011/06/04/installation-et-configuration-de-codeigniter/</guid><description>&lt;h2 id="pré-requis">Pré requis&lt;/h2>
&lt;ul>
&lt;li>Un serveur Apache ( lamp, wamp, easy php, mamp, &amp;hellip; )&lt;/li>
&lt;li>Un SGBD mysql&lt;/li>
&lt;/ul>
&lt;h2 id="la-base-de-données">La Base de données&lt;/h2>
&lt;p>Dans un premier temps voici un exemple de petite base de données. Par exemple la base de données suivante&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-mysql" data-lang="mysql">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">CREATE&lt;/span> &lt;span style="color:#66d9ef">DATABASE&lt;/span> &lt;span style="color:#f92672">`&lt;/span>tuto&lt;span style="color:#f92672">`&lt;/span> &lt;span style="color:#66d9ef">DEFAULT&lt;/span> &lt;span style="color:#66d9ef">CHARACTER&lt;/span> &lt;span style="color:#66d9ef">SET&lt;/span> latin1 &lt;span style="color:#66d9ef">COLLATE&lt;/span> latin1_swedish_ci;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">USE&lt;/span> &lt;span style="color:#f92672">`&lt;/span>tuto&lt;span style="color:#f92672">`&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">CREATE&lt;/span> &lt;span style="color:#66d9ef">TABLE&lt;/span> &lt;span style="color:#66d9ef">IF&lt;/span> &lt;span style="color:#66d9ef">NOT&lt;/span> &lt;span style="color:#66d9ef">EXISTS&lt;/span> &lt;span style="color:#f92672">`&lt;/span>message&lt;span style="color:#f92672">`&lt;/span> (
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">`&lt;/span>id&lt;span style="color:#f92672">`&lt;/span> &lt;span style="color:#66d9ef">int&lt;/span>(&lt;span style="color:#ae81ff">8&lt;/span>) &lt;span style="color:#66d9ef">NOT&lt;/span> &lt;span style="color:#66d9ef">NULL&lt;/span> &lt;span style="color:#66d9ef">AUTO_INCREMENT&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">`&lt;/span>sujet&lt;span style="color:#f92672">`&lt;/span> &lt;span style="color:#66d9ef">varchar&lt;/span>(&lt;span style="color:#ae81ff">255&lt;/span>) &lt;span style="color:#66d9ef">NOT&lt;/span> &lt;span style="color:#66d9ef">NULL&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">`&lt;/span>message&lt;span style="color:#f92672">`&lt;/span> &lt;span style="color:#66d9ef">text&lt;/span> &lt;span style="color:#66d9ef">NOT&lt;/span> &lt;span style="color:#66d9ef">NULL&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">PRIMARY&lt;/span> &lt;span style="color:#66d9ef">KEY&lt;/span> (&lt;span style="color:#f92672">`&lt;/span>id&lt;span style="color:#f92672">`&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>) &lt;span style="color:#66d9ef">ENGINE&lt;/span>&lt;span style="color:#f92672">=&lt;/span>MyISAM &lt;span style="color:#66d9ef">DEFAULT&lt;/span> &lt;span style="color:#66d9ef">CHARSET&lt;/span>&lt;span style="color:#f92672">=&lt;/span>latin1 &lt;span style="color:#66d9ef">AUTO_INCREMENT&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#ae81ff">1&lt;/span> ;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Maintenant que la base est prête nous alors configurer CodeIgniter pour qu&amp;rsquo;il puisse s&amp;rsquo;y connecter.&lt;/p>
&lt;p>Rendez-vous dans le fichier : application/config/database.php&lt;/p></description></item></channel></rss>