====== PHP ====== Sources d'information : * [[/informatique/php/tips|/informatique/php/Tips & Tricks]] * [[http://julien-pauli.developpez.com/|Les cours de Julien Pauli]] sur developpez.com sont très pertinents (sécurité, ZendFramework, ...). * [[http://g-rossolini.developpez.com/tutoriels/php/5.3/|Les nouveautés de PHP 5.3]] PHP8 Attributes * https://stitcher.io/blog/attributes-in-php-8 * https://github.com/TWithers/laravel-php-attributes [[/informatique/php/Build Win32|Compiler PHP et PECL pour Windows]] Installer différentes versions de Php grâce au [[https://launchpad.net/~ondrej/+archive/ubuntu/php|dépôt de Ondřej Surý]] (un développeur Debian) : sudo apt install software-properties-common sudo add-apt-repository ppa:ondrej/php sudo apt update ===== Application Frameworks ===== [[http://www.javaworld.com/javaworld/jw-01-2011/110126-php-frameworks.html|InfoWorld review: Fabulous PHP frameworks]], Zend Framework, Symfony, CodeIgniter, CakePHP, and other PHP frameworks conquer Web development with extensive features, powerful tools, and superior ease Review By Rick Grehan, InfoWorld, 2011-01-26. [[http://toys.lerdorf.com/archives/38-The-no-framework-PHP-MVC-framework.html|The no-framework PHP MVC framework]]: Une petit leçon d'architecture PHP à lire absolument avant de commencer une petite application qui n'a pas les grandes ambitions d'un CMS. Un code permettant de faire des benchmarks sur quelques framework: [[https://github.com/pmjones/php-framework-benchmarks]] par [[http://paul-m-jones.com/archives/category/programming/php|Paul M. Jones]] [[http://ralphschindler.com/2011/01/18/php-component-and-library-api-design-overview|PHP Component and Library API Design Overview]] by Ralph Schindler (2011-01-08) ==== Dans les plus connus ==== * [[http://framework.zend.com|Zend Framework]] : [[/informatique/php/Zend Framework]], [[wpfr>Zend Framework]], [[http://zend-framework.developpez.com/|ZF sur Developpez.com]] * [[http://www.symfony-project.org/|Symfony]] : [[/informatique/php/Symfony|Symfony]], [[wpfr>Symfony]] * Prado * [[/informatique/php/laravel|Laravel]] The PHP Framework For Web Artisans. * [[http://mouf-php.com|Mouf]] * [[http://codeigniter.com/user_guide/toc.html|CodeIgniter]] * [[http://ezcomponents.org|eZComponents]] et maintenant en incubation par ASF [[http://incubator.apache.org/zetacomponents|Apache Zeta Components]] * [[/informatique/php/CakePHP]] : [[wpfr>CakePHP]] * [[http://www.copix.org|Copix]] : [[wpfr>Copix]] ==== Light MVC ==== Les "bons" frameworks c'est bien, mais quand on veut des performances pour un petit projet hébergé pour pas cher tout en ne ré-inventant pas la roue, il faudrait un framework léger. * [[http://slimframework.com|Slim Framework]] ([[/informatique/php/slim]]) * [[http://www.kohanaphp.com/download|Kohana]] (a lightweight fork of CI (CodeIgniter)). * [[http://www.rapyd.com/|Rapyd]] * [[https://github.com/jmathai/epiphany|epiphany]] * [[http://www.elf-php.com/|ELF PHP]] * [[http://code.google.com/p/baseappframework/|BaseApp]] * [[http://www.pluf.org/|Pluf]] * [[http://fatfree.sourceforge.net/|Fat-Free-Framework (F3)]] ==== Dependency Injector ==== Un bon article de Fabien Potencier sur l'usage de l'[[http://fabien.potencier.org/article/11/what-is-dependency-injection|injection de dépendance (en Php)]], notamment pour ceux qui ont du mal à voir l'utilité de l'IoC/DI. Sur Wikipedia il y a toutes une liste de frameworks php qui implémentent le pattern [[:informatique:design_pattern#Dependency Injection|Dependency Injection]]. Il faudrait jeter un oeil à tout ce petit monde: [[wpen>Dependency_injection]]. * [[http://www.seasar.org/en/php5/DIContainer.html|S2Container.PHP5]]: is a port of Java version Seasar2 to PHP5. C'est un DI à la Spring (def file, AOP aspect). * [[http://sourceforge.net/projects/phemto|Phemto]] is a dependency injector for PHP. Similar in concept to Pico container, but smaller. DI is for managing complex OO dependencies on a large project, e.g. for web frameworks, rather than the registry or service locator patterns. * [[https://github.com/beberlei/yadif|Yadif]]: Yet Another (PHP) Dependency Injection Framework. It is compatible with Zend Framework (ZF). Un tout simple: * [[http://github.com/fabpot/Pimple|Pimple]] par Fabien Potencier Autres qui semblent tout neuf et sans communauté: * [[http://www.lionframework.org/|Lion PHP Framework]]: objectifs impressionnants, mais tout jeune (communauté vide...). Autres qui semblent inactifs ou pas finis: * [[http://en.wikipedia.org/wiki/Xyster_Framework|Xyster_Framework]] * [[http://garden.tigris.org/|Garden]] ===== Performance ===== [[/informatique/php/Performance]] [[/informatique/php/Cache]] [[/informatique/php/Multithread]] Les generators "[[https://www.php.net/manual/en/language.generators.syntax.php|generator function]]" permettent d'**économiser de la mémoire** lors d'une itération. Au lieu d'accumuler dans un ''tableau'' le résultat d'une fonction, avec ''yield'' les valeurs sont retrournées au fil de l'itération. * [[https://scotch.io/tutorials/understanding-php-generators|Understanding PHP Generators]] ===== Outillage ===== Liste d'outils/extension affectant le comportement de Php: [[http://fr2.php.net/manual/en/refs.basic.php.php|Affecting PHP's Behaviour]]. [[http://www.baptisteautin.com/projets-personnels/php_uml/comment-utiliser-php_uml/lang/fr/|PHP_UML]] est un parser de code PHP, un générateur de XMI, et un outil de production de documentation. Concrètement, grâce à PHP_UML, vous pourrez importer dans un atelier de génie logiciel (comme Rationale Rose™ ou ArgoUml), une représentation UML d’une application PHP existante. Vous obtiendrez ainsi une vue d’ensemble du code, avec toutes les fonctions habituelles de votre AGL préféré. Eclipse plugin: [[http://phpsrc.org/|PHP Tool Integration (PTI)]] [[/informatique/php|AOP]] Aspect Oriented Programming avec Php ==== phpUnderControl ==== [[http://phpundercontrol.org/|phpUnderControl]] - Continuous Integration for PHP. * Testing and software metrics, PHPUnit output: Code Coverage, Project Mess Detection and Software Metrics. * Documentation: PhpDocumentor, to generate an up to date documentation of the software on every build cycle. Therefore the developers will always get the latest API documentation of their project. Additionally phpUnderControl extracts the documentation violations found by the PhpDocumentor and visualizes these as an additional quality report in the user interface and the project time line of documentation violations. * Coding Standards: With the package PHP_CodeSniffer ==== Phing ==== [[/informatique/php/Phing]]: Le ANT (make like) pour Php. ==== Debug with Eclipse/PDT and Zend Debugger ==== Voir [[informatique:ide:eclipse:pdt|Eclipse PDT]] config XDebug dans le php.ini : zend_extension=/usr/lib64/php/modules/xdebug.so xdebug.remote_enable=On xdebug.remote_autostart=On xdebug.remote_handler=dbgp xdebug.remote_host=192.168.1.100 xdebug.remote_port=9000 xdebug.remote_mode=req Alternative sans Eclipse: **xdebugclient** : http://code.google.com/p/xdebugclient/ ==== FirePHP ==== http://www.firephp.org FirePHP extends the aforementioned [[http://www.getfirebug.com|Firebug]]'s capabilities to the server side, allowing you to easily log messages and other data hailing from a PHP script. This can be tremendously useful when debugging Ajax-driven features, or when you simply want to inspect the contents of an object or array without having to repeatedly insert and delete echo or var_dump statements. Like Firebug, FirePHP is also a Firefox extension. However you'll also need to install a simple PHP library on the server running your PHP-driven website. This script serves as the bridge for communications between the server and Firebug/FirePHP. Learn more at the official website, and be sure to check out the Developer.com article [[http://www.developer.com/lang/jscript/article.php/10939_3879711_2/Firebug-Add-Browser-based-Debugging-to-Your-Ajax-Development.htm|Firebug: Add Browser-based Debugging to Your Ajax Development]]. ==== SimpleTest ==== http://www.simpletest.org It is a PHP unit test and web test framework. Users of JUnit will be familiar with most of the interface. The JWebUnit style functionality is more complete now. It has support for SSL, forms, frames, proxies and basic authentication. The idea is that common but fiddly PHP tasks, such as logging into a site, can be tested easily. ==== PhpUnit ==== http://www.phpunit.de Features * Complete port of JUnit 3.8.1 to PHP 5. * Integrates ideas from TestNG, such as * Annotation-based @grouping of test cases. * Suite-Level setUp() and tearDown(). * Testing for failures. * Supports Mock Objects (port of jMock). * Supports database testing (port of DbUnit). * Supports Code Coverage Analysis (utilizing the Xdebug extension for PHP) and can generate reports based on this information. * Supports the calculation of software metrics. * Can be used as a Project Mess Detector (PMD). * Supports storing test result and code coverage data in a Test Database. * Supports Incomplete Tests (port of junitour) and the skipping of tests. * Supports Agile Documentation (port of TestDox). * Supports generation of test code skeletons for existing code. * Supports logging of test execution in an XML Format, as JavaScript Object Notation (JSON) messages, using the Test Anything Protocol (TAP), in GraphViz Markup, and to PEAR::Log sinks. * Integrates with Selenium RC for web application user interface testing. * Integrates with Apache Maven, Bamboo, Bitten, CruiseControl, and Parabuild for Continuous Integration. * Integrates with Phing. * "Self-Hosted" and Robust: PHPUnit is covered by a Test Suite that ensures it works correctly. Voir: * [[http://jp-grossglauser.developpez.com/tutoriels/langages/php/phpunit/|Introduction aux tests unitaires avec PHPUnit 3.1]] * [[http://julien-pauli.developpez.com/tutoriels/php/phpunit-tdd/|Développement piloté par les tests avec PHPUnit]], Julien Pauli * [[http://julien-pauli.developpez.com/tutoriels/php/phpunit-avance/|PHPUnit avancé : patterns de tests]], Julien Pauli 16/07/2010 * [[http://blog.loftdigital.com/running-phpunit-tests-in-eclipse-pdt|Running PHPUnit tests in Eclipse PDT]] by Zdenek Machek, 22 August 2012 ====PHPDocumentor ==== http://www.phpdoc.org For API documentation generation. ==== PHP_CodeSniffer ==== http://pear.php.net/package/PHP_CodeSniffer PHP_CodeSniffer is a PHP5 script that tokenises and "sniffs" PHP, JavaScript and CSS files to detect violations of a defined coding standard. It is an essential development tool that ensures your code remains clean and consistent. It can also help prevent some common semantic errors made by developers. ===== Librairies ===== ==== Générale ==== === SPL Standard Php Library === PHP5 possède un modèle objet 'non vide' : il est agrémenté de classes et d'interfaces internes, réunies dans ce qu'on appelle la SPL, ou Standard PHP Library. Nous allons voir en quoi ils peuvent s'avérer très utiles dans des développements orientés objets en PHP, de plus en plus nécéssaires de nos jours, afin de maintenir une cohérence logique dans ses programmes. Intégrée : la SPL est en réalité une extension PHP, mais qui est très souvent (pour ne pas dire tout le temps) compilée dans PHP, quelle qu'en soit la distribution (Win, packages Linux...), ce qui donne l'impression de la nativité de ses fonctionnalités. La SPL rend beaucoup de services, et de plus en plus d'extensions PHP en sont dépendantes. Ainsi, à partir de PHP5.3, il ne sera plus possible de désactiver l'intégration de la SPL via la commande de compilation. Elle sera réellement "nativement" intégrée. Outre une approche procédurale conservée, il est désormais possible avec PHP5 de développer des pages et des processus entièrement orientés objets. La SPL, ou Standard PHP Library, est un ensemble de classes disponibles, prêtes à être utilisées ou implémentées. De nombreux patrons de conception (design pattern) sont fournis par la SPL. Voir: * [[http://fr3.php.net/spl|Standard PHP Library (SPL)]] sur php.net * http://www.php.net/~helly/php/ext/spl/main.html * POO PHP5 par Julien Pauli : [[http://julien-pauli.developpez.com/tutoriels/php/spl/|Standard Php Library (SPL)]], [[http://julien-pauli.developpez.com/tutoriels/php/observer-spl/|Design Pattern observateur aidé de la Standard PHP Library (SPL)]], [[http://julien-pauli.developpez.com/tutoriels/php/agregator/|Créer un agrégateur à base de réflexion et de SPL]] ==== Date Time ==== [[http://carbon.nesbot.com/|Carbon]] a simple PHP API extension for DateTime. ==== Cron ==== === crunz === https://github.com/lavary/crunz * Crunz is a framework-agnostic package to schedule periodic tasks (cron jobs) in PHP using a fluent API * Install a cron job once and for all, manage the rest from the code * Crunz is capable of executing any kind of executable command as well as PHP closures Ce package semble bien géré et pérenne ;-) ==== Validation ==== === Respect/Validation === For a Validation framework, look at http://respect.li/Validation/ === owasp-php-filters === ==== Office Excel/CSV ==== === Spout === http://opensource.box.com/spout/ Spout supports 3 types of spreadsheets: XLSX, ODS and CSV. Spout provides a simple and unified API to read or create these different types of spreadsheets. Switching from one type to another is ridiculously easy! === PHPOffice === PhpSpreadsheet, PHPWord, PHPPresentation, PHPVisio, PhpProject https://github.com/PHPOffice ==== Graphique ==== === PDF Parser === * http://pdfparser.org/ * Une lib très simpliste pour extrait des éléments d'un PDF. C'est une sur-couche simplifiant l'API de TCPDF * https://github.com/smalot/pdfparser * is a standalone PHP package that provides various tools to extract data from PDF files. === mPDF === https://mpdf.github.io/ Très fort pour les langues (Ko, Th, Zh ...) === TCPDF === TCPDF library is a FPDF "fork" http://www.tcpdf.org === jpgraph === http://jpgraph.net 07 Oct 2010, JpGraph 3.5.0b1 === artishow === http://www.artichow.org 15/12/2006 - Artichow 2.0.0 alpha et 1.1.0 ==== Communication ==== === WSO2 WSF/PHP === WSO2 Web Services Framework/PHP (WSO2 WSF/PHP) The Web Services Framework for PHP is a PHP extension that delivers comprehensive WS-* based Web Services support for the PHP world. With WSF/PHP, your php applications can acquire enterprise grade web services capabilities and seamlessly integrate with other Java or .Net systems using web services.WSO2 WSF/PHP is an open source framework for providing/consuming Web services in PHP and is the only extension that supports the full Web services (WS*-) stack including security and reliable messaging. In addition to the ability to provide and consume web services, WSF/PHP provides comprehensive support for REST based web services allowing you to expose your soap services as REST services. It also provides the data services capability. WSF/PHP comes with comprehensive documentation and samples in addition to tooling support in the form of a code generation tool which allows the PHP user to get started with PHP web services in no time. As WSF/PHP is based on WSF/C web services framework, it comes with proven interoperability with other major web services stacks including .Net and Java. * [[http://wso2.com/products/web-services-framework/php/|Product page]] * [[http://wso2.org/library/wsf/php|Developper page]] === nusoap === https://sourceforge.net/projects/nusoap/ === wsdl-writer === http://www.placeoweb.com/fichiers/wsdl-writer-0.3-katy.htm === xmlrpc-epi-php === ==== Html & DOM scraper ==== === Simple HTML DOM === https://packagist.org/packages/voku/simple_html_dom === php-html-parser === https://packagist.org/packages/paquettg/php-html-parser === Goutte === Goutte is web crawling library for PHP. Goutte fourni un client programmable pour lire et interagir sur des pages html/xml. http://github.com/fabpot/Goutte // Require the Goutte phar file to use Goutte in a script: require_once '/path/to/goutte.phar'; // Create a Goutte Client instance: $client = new Client(); // Make requests $crawler = $client->request('GET', 'http://www.symfony-project.org/'); // Click on links: $link = $crawler->selectLink('Plugins')->link(); $crawler = $client->click($link); // Submit forms: $form = $crawler->selectButton('sign in')->form(); $crawler = $client->submit($form, array('signin[username]' => 'fabien', 'signin[password]' => 'xxxxxx')); //Extract data: $nodes = $crawler->filter('.error_list'); if ($nodes->count()) { die(sprintf("Authentification error: %s\n", $nodes->text())); } printf("Nb tasks: %d\n", $crawler->filter('#nb_tasks')->text()); ==== Divers ==== === eZComponents Workflow=== http://ezcomponents.org/docs/tutorials/Workflow The Workflow component provides a virtual machine that executes workflows represented through object graphs. These object graphs can be created programmatically through the software component's Workflow Definition API. Alternatively, a workflow definition can be loaded from an XML file. Object graph and XML file are two different representations of a workflow definition that uses a backend language built on the workflow patterns. [[http://ezcomponents.org/docs/api/trunk/Workflow_theoretical_background.html|eZ Components - Workflow - Theoretical Background]] ===php_uploadprogress=== Une extension PECL en C qui permet de suivre la progression d'un upload (An extension to track progress of a file upload).\\ http://pecl.php.net/package/uploadprogress See http://cvs.php.net/viewvc.cgi/pecl/uploadprogress/examples/ for a little example.\\ It is only known to work on Apache with mod_php, other SAPI implementations unfortunately still have issues. At least PHP 5.2 is needed. Articles : * [[http://blog.liip.ch/archive/2009/06/20/upload-progress-meter-1-0-1-released.html|Upload Progress Meter 1.0.1 released]] by Christian Stocker @ 29.06.2009 * [[http://blog.liip.ch/archive/2006/09/28/upload-progress-meter-extension-for-php-5-2.html|Upload Progress Meter extension for PHP 5.2]] by Christian Stocker @ 31.03.2009 * [[http://blog.liip.ch/archive/2009/03/31/upload-progress-meter-common-issues-and-some-answers.html|Upload Progress Meter - Common issues and some answers]] by Christian Stocker @ 31.03.2009 * [[http://blog.liip.ch/archive/2009/03/09/upload-progress-meter-for-windows-the-next-take.html|Upload Progress Meter for Windows - The next take]] by Christian Stocker @ 13.03.2009 * [[http://blog.liip.ch/archive/2009/01/10/uploadprogress-0-9-2-released.html|Upload Progress Meter extension 0.9.2 released]] by Christian Stocker @ 22.01.2009 * [[http://blog.liip.ch/archive/2006/12/05/upload-progress-meter-for-windows.html|Upload Progress Meter for Windows]] by Christian Stocker @ 06.12.2006 * [[http://blog.liip.ch/archive/2006/12/12/upload-progress-meter-finally-in-pecl.html|Upload Progress Meter finally in PECL]] by Christian Stocker @ 05.12.2006 ===== Templates engines ===== ==== Blade ==== Used in Laravel https://laravel.com/docs/blade ==== Twig ==== http://www.twig-project.org Encore une belle réalisation de Fabien Potencier/Sensios Labs. Doc: * [[http://www.twig-project.org/documentation|Official doc]] * Google Groups: * [[http://groups.google.com/group/twig-devs|Twig Developers]] * [[http://groups.google.com/group/twig-users|Twig Users]] === tips === == Show all variables == Set the environment debug mode to true: $twig = new Twig_Environment($loader, array('debug' => true)); Add this in your template file: {% debug %} Happy debugging! **removed the debug tag (should be done in an extension)** It's now available in the Twig-Extensions repository: http://github.com/fabpot/Twig-extensions ==== Smarty ==== http://www.smarty.net/ * Gestion des variables : {$title} * Gestion des zones : {Section name=Zone} * Last release: ==== Php::TAL ==== http://phptal.org (http://phptal.sourceforge.net, http://phptal.motion-twin.com) PHPTAL is a templating engine for PHP5 that implements brilliant Zope Page Templates syntax:

* Last release: PHPTAL 1.1.16 Released 2009-02-24 PHPTAL is fast thanks to compiled templates and fine-grained caching. Makes it easy to generate well-formed XML/XHTML (protected against XSS attacks). PHPTAL's code is mature and improving. Released free under LGPL license. PHPTAL is a PHP implementation of ZPT work. To be short, PHPTAL is a XML/XHTML template library for PHP. While most web developpers continue to use ASP/JSP/PHP tags as the core language of their templates, the Zope community came with a refreshing idea named TAL. The idea was to move presentation actions inside XHTML attributes instead of using plain tags or elements. ==== ModeliXe ==== http://modelixe.phpedit.com/ * Gestion des variables : * Gestion des zones : * Last release: ===== BdD, DAL & ORM ===== Glossaire: * [[glossaire:DAL|Database Abstraction Layers (DAL)]] * [[glossaire:ORM|Object Relational Mapping (ORM]] Pages: * [[/informatique/php/orm|Object Relational Mapping (ORM) pour PHP]] * [[/informatique/php/dal|Database Abstraction Layers (DAL) pour Php]] ==== ORM ==== * [[http://www.doctrine-project.org/|Doctrine]] * The [[http://laravel.com/docs/eloquent|Eloquent ORM]] included with [[http://laravel.com|Laravel Php Framework]] provides a beautiful, simple ActiveRecord implementation for working with your database. Each database table has a corresponding "Model" which is used to interact with that table. * [[http://j4mie.github.io/idiormandparis/|Idiorm & Paris]] A minimalist database toolkit for PHP5 * [[http://www.redbeanphp.com|RedBeanPHP]] Zero Config & Fluid Schema ... * [[http://dicabrio.com/php/dica-orm-object-relational-mapping.php|dicaORM]] is a powerful and easy to use ORM library. It is based on the ActiveRecord pattern. It carries both data and behavior. ==== Database schema ==== [[http://ezcomponents.org/docs/api/1.1/introduction_DatabaseSchema.html|DatabaseSchema]] de eZ Components permet de gérer un schéma de BdD: reverse/create to xml,php array,SQL DDL. Comparing Database Schemas. Validating Schemas. ==== Desktop tools ==== [[http://dev.mysql.com/downloads/workbench|MySQL Workbench]] [[http://sourceforge.net/projects/dbdesigner-fork/|DBDesignerFork]] c'est pas du Php mais bien pratique pour designer. Last version 1.4 2007-07-31). ==== MySQL ==== MySQLnd Plugins: [[http://blog.mayflower.de/archives/578-MySQLnd-Plugins-Writing-a-MySQL-Query-Logger-in-PHP.html|Writing a MySQL Query Logger in PHP with the help of the MySQLnd Userland Handler Extension (mysqlnd_uh)]] 2010-08-16 ===== Other stuff ===== ==== Streaming ==== * When using nginx you need to disable fastcgi_buffering with header('X-Accel-Buffering: no'); * Disabling the cache is useful to avoid caching the response header("Cache-Control: no-cache, must-revalidate"); Streaming Ajax response * [[https://gist.github.com/sohelrana820/63f029d3aa12936afbc50eb785c496c0|Catch php output buffering data over jQuery AJAX]]