======Développement d'un framework PHP====== ==== Fonctionnalités ==== * **Générales :** * Autoloader (PSR-4) * Conteneur / dépendance d'injection (PSR-11, Container-Interop/Service-Provider) * Abstraction de BDD : PDO * Cache (PSR-16) * Config : chargement et registre * Debug * Http : abstraction de la couche HTTP (PSR-7, PSR-15, PSR-17) * Log (PSR-3) * Utilitaires : classes outils. * Routage : routage de requête http. * Session : gestionnaire de session (abstraction de $_SESSION) * **Ligne de commande :** * Cli + Script * **Web services :** * Serveur REST * Service REST * Client REST * **Web socket / Long polling :** * Event loop * Serveur de websocket / Long polling (?) * **Application web :** * HMVC : Controleur + Modele + Vue + Dispatcher * Templating : Php * URI : via PSR7 HTTP/URI * I18N * ** Autres :** * Auth : via Json Web Token. * Acls : gestion des droits. ==== Dépendances ==== * PSR-3 : Psr/Log v1.0 * PSR-4 Autoloader : * PSR-7 : Psr/Http/Message v1.0 * PSR-11 : Psr/Container v1.0 * PSR-15 : HTTP Middlewares * PSR-16 : Simple Cache * PSR-17 : HTTP Factories * Container-Interop/Service-Provider : https://github.com/container-interop/service-provider ==== Sources ==== * Core : [[https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader-examples.md|PSR-4]] (Autoloader) * Cache : [[http://www.php-fig.org/psr/psr-16/|PSR-16]], [[https://github.com/khoaofgod/phpfastcache|PhpFastCache]] * Config : * DependencyInjection : [[https://github.com/mnapoli/simplex|Simplex]] * HTTP : [[https://github.com/slimphp/Slim|Slim 3]] & [[https://github.com/guzzle/psr7|Guzzle PSR7]] * I18N : [[https://github.com/symfony/translation|Symfony Translation Component]] * Rest : [[https://github.com/slimphp/Slim|Slim3]] (serveur) & [[https://github.com/guzzle/psr7|Guzzle PSR7]] (client) * Session : [[https://github.com/symfony/http-foundation|Symfony Http Foundation Component]] ==== Ressources ==== === Software As a Service === * https://12factor.net/ === ACLs === Docs : * [[http://www.sitepoint.com/easier-authentication-with-guard-in-symfony-3/|Symfony 3 Guard]] === Dependency Injection/Service Location === Codes sources de Conteneurs : * [[https://github.com/silexphp/Pimple|Pimple]] * [[https://github.com/mindplay-dk/unbox|Unbox]] * [[https://github.com/container-interop/container-interop|Container Interop]] : standard d’interopérabilité entre Conteneur (DI) Docs : * [[http://fabien.potencier.org/do-you-need-a-dependency-injection-container.html|Do you need a Dependency Injection Container ?]] * [[http://auraphp.com/packages/Aura.Di/|Aura DI]] * [[http://php-di.org/|PHP-DI]] * [[http://laravel.com/docs/5.1/container|Laravel Container doc]] * [[https://docs.phalconphp.com/en/latest/reference/di.html|Phalcon DI doc]] Notes : * Voir le pattern Service Locator et la différence avec un DI Container. * Exemple de DIC performants : Dice, Aura and Orno * Problème éventuel et solution : Using abstract factories with Slim 3 * Aura gère les paramètres dans les appels aux classes du conteneur. C'est la solution retenu pour le Framework. === Config === * **INI** : * [[https://github.com/austinhyde/IniParser|IniParser]] : Parser de fichier ini ajoutant des améliorations * [[https://github.com/caseyamcl/Configula|Configula]] : Parser multi formats : PHP ($config), JSON (json_decode()), INI (parse_ini_file()), YAML (symfony/yaml package) * ** YAML ** : * [[https://github.com/symfony/yaml|Symfony YAML]] : Yaml 1.2 * [[https://github.com/mustangostang/spyc|Spyc]] : Yaml 1.1 === Cache === * [[https://github.com/khoaofgod/phpfastcache|phpfastcache]] * [[https://github.com/cosenary/Simple-PHP-Cache|Simple-PHP-Cache]] === Console (CLI) === Codes sources : * [[https://github.com/symfony/console|Symfony Console code source]] * [[https://github.com/laravel/framework/tree/5.1/src/Illuminate/Console|Laravel Console code source]] Docs : * [[http://www.sitepoint.com/console-wars-php-cli-libraries/|Console Wars – PHP CLI Libraries]] * [[http://symfony.com/doc/current/components/console/index.html|Symfony Console doc]] * [[http://laravel.com/docs/5.1/artisan|Laravel Artisan doc]] === Database === Principes intéressants : * https://github.com/auraphp/Aura.Sql * https://github.com/dg/dibi * https://docs.phalconphp.com/en/latest/api/Phalcon_Db_Adapter_Pdo.html Autres possibilités : * http://culttt.com/2012/10/01/roll-your-own-pdo-php-class/ * https://github.com/blag001/class_easy_pdo/blob/master/toolSql/Bdd.class.php * https://github.com/ttsuruoka/php-simple-dbi/blob/master/src/SimpleDBI.php === I18N === * [[http://symfony.com/fr/doc/current/book/translation.html|Symfony translation doc]] * [[https://github.com/symfony/Translation|Symfony translation code source]] * [[http://stackoverflow.com/questions/12731105/is-gettext-the-best-way-to-localise-a-website-in-php-only-mild-localisation-ne|PHP gettext]] === Logger === * [[https://github.com/ccampbell/chromephp|Chrome Logger]] : permet d'afficher les messages de log côté Console du navigateur. === MVC === * Voir : https://docs.phalconphp.com/en/latest/reference/mvc.html === MVC : dispatcher === * Dispatching is the process of taking the request object, extracting the module name, controller name, action name, and optional parameters contained in it, and then instantiating a controller and calling an action of that controller. * Voir : https://docs.phalconphp.com/en/latest/api/Phalcon_Mvc_Dispatcher.html === MVC : hiérarchique (HMVC) === * [[http://techportal.inviqa.com/2010/02/22/scaling-web-applications-with-hmvc/|Introduction au HMVC]] * [[https://docs.phalconphp.com/en/latest/reference/views.html|Phalcon : vues hiérarchiques]] * [[http://kohanaframework.org/3.3/guide/kohana/mvc/views|Kohana : vues hiérarchiques]] === REST : Client === * [[https://github.com/guzzle/psr7|Guzzle]] : PSR-7 === REST : Serveur === * [[https://github.com/slimphp/Slim|Slim 3]] : PSR-7 === Router === * Routing is the process of taking a URI endpoint (that part of the URI which comes after the base URL) and decomposing it into parameters to determine which module, controller, and action of that controller should receive the request * Source : * FastRoute : plusieurs solutions de routage, très performant... trop de fichiers... * AltoRouter : très simple 1 fichier ! Modifier le Router actuel selon ce principe mais avec l'analyse des Regexp de Fastroute * Voir : * https://docs.phalconphp.com/en/latest/api/Phalcon_Mvc_Router.html * http://laravel.com/docs/5.1/routing === Websocket === Code source : * [[https://github.com/reactphp/event-loop|React PHP - Event loop]] : fourni une boucle d'évènement (//event loop//), "Event-driven, non-blocking I/O with PHP". Docs : * [[http://socketo.me/docs|Ratchet]]