Loading config/laminas-developer-tools.php.dist 0 → 100644 +160 −0 Original line number Diff line number Diff line <?php return [ 'laminas-developer-tools' => [ /** * General Profiler settings */ 'profiler' => [ /** * Enables or disables the profiler. * * Expects: bool * Default: true */ 'enabled' => true, /** * Enables or disables the strict mode. If the strict mode is enabled, any error will throw an exception, * otherwise all errors will be added to the report (and shown in the toolbar). * * Expects: bool * Default: true */ 'strict' => true, /** * If enabled, the profiler tries to flush the content before the it starts collecting data. This option * will be ignored if the Toolbar is enabled. * * Note: The flush listener listens to the MvcEvent::EVENT_FINISH event with a priority of -9400. You have * to disable this function if you wish to modify the output with a lower priority. * * Expects: bool * Default: false */ 'flush_early' => false, /** * The cache directory is used in the version check and for every storage type that writes to the disk. * Note: The default value assumes that the current working directory is the application root. * * Expects: string * Default: 'data/cache' */ 'cache_dir' => 'cache', /** * If a matches is defined, the profiler will be disabled if the request does not match the pattern. * * Example: 'matcher' => array('ip' => '127.0.0.1') * OR * 'matcher' => array('url' => array('path' => '/admin') * Note: The matcher is not implemented yet! */ 'matcher' => [], /** * Contains a list with all collector the profiler should run. Laminas Developer Tools ships with * 'db' (Laminas\Db), 'time', 'event', 'memory', 'exception', 'request' and 'mail' (Laminas\Mail). If you wish to * disable a default collector, simply set the value to null or false. * * Example: 'collectors' => array('db' => null) * Expects: array */ 'collectors' => [], ], 'events' => [ /** * Set to true to enable event-level logging for collectors that will support it. This enables a wildcard * listener onto the shared event manager that will allow profiling of user-defined events as well as the * built-in ZF events. * * Expects: bool * Default: false */ 'enabled' => true, /** * Contains a list with all event-level collectors that should run. Laminas Developer Tools ships with 'time' * and 'memory'. If you wish to disable a default collector, simply set the value to null or false. * * Example: 'collectors' => array('memory' => null) * Expects: array */ 'collectors' => [], /** * Contains event identifiers used with the event listener. Laminas Developer Tools defaults to listen to all * events. If you wish to disable the default all-inclusive identifier, simply set the value to null or * false. * * Example: 'identifiers' => array('all' => null, 'dispatchable' => 'Laminas\Stdlib\DispatchableInterface') * Expects: array */ 'identifiers' => [], ], /** * General Toolbar settings */ 'toolbar' => [ /** * Enables or disables the Toolbar. * * Expects: bool * Default: false */ 'enabled' => true, /** * If enabled, every empty collector will be hidden. * * Expects: bool * Default: false */ 'auto_hide' => false, /** * The Toolbar position. * * Expects: string ('bottom' or 'top') * Default: bottom */ 'position' => 'bottom', /** * If enabled, the Toolbar will check if your current Laminas Framework version is up-to-date. * Note: The check will only occur once every hour. * * Expects: bool * Default: false */ 'version_check' => false, /** * Contains a list with all collector toolbar templates. The name of the array key must be same as the name * of the collector. * * Example: 'profiler' => array( * 'collectors' => array( * // My_Collector_Example::getName() -> mycollector * 'MyCollector' => 'My_Collector_Example', * ) * ), * 'toolbar' => array( * 'entries' => array( * 'mycollector' => 'example/toolbar/my-collector', * ) * ), * Expects: array */ 'entries' => [ 'config' => false, 'db' => false, 'doctrine.mapping_collector.orm_default' => false, //'bjy_authorize_role_collector' => false, //'request' => true, //'memory' => true, ], ], ], ]; doc/Documentation.md +21 −41 Original line number Diff line number Diff line Loading @@ -3,8 +3,8 @@ ## Description UnicaenCode est un module de la biliothèque Unicaen, dédiée au développement avec le Laminas Framework 3+. Le module est intégré à la [Laminas Developer Toolbar](/develop/laminas-debug), qu'il conviendra développement avec Laminas. Le module est intégré à la [Laminas Developer Toolbar](https://github.com/laminas/laminas-developer-tools), qu'il conviendra d'installer préalablement pour un usage optimal 8-). Son but est de fournir un ensemble de services facilitant le Loading @@ -21,25 +21,34 @@ développement d'applications. Parmis ces outils : ## Installation Sa placer à la racine du projet, puis utiliser composer pour installer le plugin : ### - 1 - Composer composer require "unicaen/code" : "master", Ajouter la dépendance à votre fichier composer.json : `composer require "unicaen/code" : "master",` \<note tip\> Le fichier `composer.json` sera mis à jour et le plugin sera téléchargé dans le dossier `vendor/`. \</note\> ### - 2 - Configuration Ajouter les deux fichiers de configuration dans votre /config/autoload en supprimant les ".dist": [laminas-developer-tools.php](../config/laminas-developer-tools.php.dist) [unicaen-code.global](../config/unicaen-code.global.php.dist) UnicaenCode est destiné au développement d'application et n'a pas vocation à être déployé sur un serveur de production. Aussi, plutôt que de simplement déclarer le module, il est préférable de faire comme suit : ### - 3 - Modules Les developer tools et UnicaenCode sont tous deux des modules qu'il faut ajouter à la liste de vos modules chargés. Dans l'idéal, il ne seront chargés qu'en mode développement. Dans le fichier de configuration de l'application (`application.config.php`), ajouter ``` php $env = getenv('APP_ENV') ?: 'production'; if ( 'development' == $env ) { $modules[] = 'Laminas\DeveloperTools'; $modules[] = 'UnicaenCode'; } ``` Loading @@ -49,40 +58,11 @@ de développement. Pour rappel, la variable APP\_ENV se configure dans le fichier *.htaccess* ou bien dans le *virtualHost* correspondant à votre application (`SetEnv "APP_ENV" "development"`). Enfin, vous devrez créer deux répertoires dans votre projet : - un au même niveau que config, vendor, module, public, etc. qui s'appellera `code` - et son sous-répertoire `template` \<WRAP center round tip 80%\> Vous pouvez très bien positionner ces répertoires ailleurs. Il faudra dans ce cas positionner un fichier `unicaen-code.global.php` dans `config/autoload` doté du contenu suivant : ``` php if (defined('APPLICATION_PATH')){ $settings = [ 'view-dirs' => [APPLICATION_PATH . '/code'], 'template-dirs' => [APPLICATION_PATH . '/code/template'], 'generator-output-dir' => '/tmp/UnicaenCode', ]; }else{ $settings = []; } return [ 'unicaen-code' => $settings, ]; ``` \</WRAP\> ### - 4 - Mise en place des répertoires spécifiques \<WRAP center round alert 80%\> Assurez-vous bien que la constante globale `APPLICATION_PATH` a bien été définie comme suit dans votre fichier `/public/index.php` : Créez ensuite à la racine de votre projet (ou ailleurs en adaptant votre configuration) un répertoire `code`, puis à l'intérieur un sous-répertoire `template`. `define('APPLICATION_PATH', realpath(__DIR__ . "/.."));` \</WRAP\> # Utilisation Loading Loading @@ -141,7 +121,7 @@ un `Doctrine\ORM\QueryBuilder` comme paramètre d'entrée\!\! \</WRAP\> ### Util::varDump est une variante de var\_dump, à ceci prêt qu'elle affiche les objets de est une variante de var_dump, à ceci prêt qu'elle affiche les objets de manière moins verbeuse. ## Introspection Loading Loading @@ -184,7 +164,7 @@ $params = [ 'generator' => 'service', // On précise le nom complet de sa classe 'class' => 'Application\Service\ExempleService', // On affiche le résultat à l'écran // On affiche le résultat à l'écran ou on l'ajoute si on est en mode console 'echo' => true, // on crée aussi une Factory 'factory' => [ Loading Loading
config/laminas-developer-tools.php.dist 0 → 100644 +160 −0 Original line number Diff line number Diff line <?php return [ 'laminas-developer-tools' => [ /** * General Profiler settings */ 'profiler' => [ /** * Enables or disables the profiler. * * Expects: bool * Default: true */ 'enabled' => true, /** * Enables or disables the strict mode. If the strict mode is enabled, any error will throw an exception, * otherwise all errors will be added to the report (and shown in the toolbar). * * Expects: bool * Default: true */ 'strict' => true, /** * If enabled, the profiler tries to flush the content before the it starts collecting data. This option * will be ignored if the Toolbar is enabled. * * Note: The flush listener listens to the MvcEvent::EVENT_FINISH event with a priority of -9400. You have * to disable this function if you wish to modify the output with a lower priority. * * Expects: bool * Default: false */ 'flush_early' => false, /** * The cache directory is used in the version check and for every storage type that writes to the disk. * Note: The default value assumes that the current working directory is the application root. * * Expects: string * Default: 'data/cache' */ 'cache_dir' => 'cache', /** * If a matches is defined, the profiler will be disabled if the request does not match the pattern. * * Example: 'matcher' => array('ip' => '127.0.0.1') * OR * 'matcher' => array('url' => array('path' => '/admin') * Note: The matcher is not implemented yet! */ 'matcher' => [], /** * Contains a list with all collector the profiler should run. Laminas Developer Tools ships with * 'db' (Laminas\Db), 'time', 'event', 'memory', 'exception', 'request' and 'mail' (Laminas\Mail). If you wish to * disable a default collector, simply set the value to null or false. * * Example: 'collectors' => array('db' => null) * Expects: array */ 'collectors' => [], ], 'events' => [ /** * Set to true to enable event-level logging for collectors that will support it. This enables a wildcard * listener onto the shared event manager that will allow profiling of user-defined events as well as the * built-in ZF events. * * Expects: bool * Default: false */ 'enabled' => true, /** * Contains a list with all event-level collectors that should run. Laminas Developer Tools ships with 'time' * and 'memory'. If you wish to disable a default collector, simply set the value to null or false. * * Example: 'collectors' => array('memory' => null) * Expects: array */ 'collectors' => [], /** * Contains event identifiers used with the event listener. Laminas Developer Tools defaults to listen to all * events. If you wish to disable the default all-inclusive identifier, simply set the value to null or * false. * * Example: 'identifiers' => array('all' => null, 'dispatchable' => 'Laminas\Stdlib\DispatchableInterface') * Expects: array */ 'identifiers' => [], ], /** * General Toolbar settings */ 'toolbar' => [ /** * Enables or disables the Toolbar. * * Expects: bool * Default: false */ 'enabled' => true, /** * If enabled, every empty collector will be hidden. * * Expects: bool * Default: false */ 'auto_hide' => false, /** * The Toolbar position. * * Expects: string ('bottom' or 'top') * Default: bottom */ 'position' => 'bottom', /** * If enabled, the Toolbar will check if your current Laminas Framework version is up-to-date. * Note: The check will only occur once every hour. * * Expects: bool * Default: false */ 'version_check' => false, /** * Contains a list with all collector toolbar templates. The name of the array key must be same as the name * of the collector. * * Example: 'profiler' => array( * 'collectors' => array( * // My_Collector_Example::getName() -> mycollector * 'MyCollector' => 'My_Collector_Example', * ) * ), * 'toolbar' => array( * 'entries' => array( * 'mycollector' => 'example/toolbar/my-collector', * ) * ), * Expects: array */ 'entries' => [ 'config' => false, 'db' => false, 'doctrine.mapping_collector.orm_default' => false, //'bjy_authorize_role_collector' => false, //'request' => true, //'memory' => true, ], ], ], ];
doc/Documentation.md +21 −41 Original line number Diff line number Diff line Loading @@ -3,8 +3,8 @@ ## Description UnicaenCode est un module de la biliothèque Unicaen, dédiée au développement avec le Laminas Framework 3+. Le module est intégré à la [Laminas Developer Toolbar](/develop/laminas-debug), qu'il conviendra développement avec Laminas. Le module est intégré à la [Laminas Developer Toolbar](https://github.com/laminas/laminas-developer-tools), qu'il conviendra d'installer préalablement pour un usage optimal 8-). Son but est de fournir un ensemble de services facilitant le Loading @@ -21,25 +21,34 @@ développement d'applications. Parmis ces outils : ## Installation Sa placer à la racine du projet, puis utiliser composer pour installer le plugin : ### - 1 - Composer composer require "unicaen/code" : "master", Ajouter la dépendance à votre fichier composer.json : `composer require "unicaen/code" : "master",` \<note tip\> Le fichier `composer.json` sera mis à jour et le plugin sera téléchargé dans le dossier `vendor/`. \</note\> ### - 2 - Configuration Ajouter les deux fichiers de configuration dans votre /config/autoload en supprimant les ".dist": [laminas-developer-tools.php](../config/laminas-developer-tools.php.dist) [unicaen-code.global](../config/unicaen-code.global.php.dist) UnicaenCode est destiné au développement d'application et n'a pas vocation à être déployé sur un serveur de production. Aussi, plutôt que de simplement déclarer le module, il est préférable de faire comme suit : ### - 3 - Modules Les developer tools et UnicaenCode sont tous deux des modules qu'il faut ajouter à la liste de vos modules chargés. Dans l'idéal, il ne seront chargés qu'en mode développement. Dans le fichier de configuration de l'application (`application.config.php`), ajouter ``` php $env = getenv('APP_ENV') ?: 'production'; if ( 'development' == $env ) { $modules[] = 'Laminas\DeveloperTools'; $modules[] = 'UnicaenCode'; } ``` Loading @@ -49,40 +58,11 @@ de développement. Pour rappel, la variable APP\_ENV se configure dans le fichier *.htaccess* ou bien dans le *virtualHost* correspondant à votre application (`SetEnv "APP_ENV" "development"`). Enfin, vous devrez créer deux répertoires dans votre projet : - un au même niveau que config, vendor, module, public, etc. qui s'appellera `code` - et son sous-répertoire `template` \<WRAP center round tip 80%\> Vous pouvez très bien positionner ces répertoires ailleurs. Il faudra dans ce cas positionner un fichier `unicaen-code.global.php` dans `config/autoload` doté du contenu suivant : ``` php if (defined('APPLICATION_PATH')){ $settings = [ 'view-dirs' => [APPLICATION_PATH . '/code'], 'template-dirs' => [APPLICATION_PATH . '/code/template'], 'generator-output-dir' => '/tmp/UnicaenCode', ]; }else{ $settings = []; } return [ 'unicaen-code' => $settings, ]; ``` \</WRAP\> ### - 4 - Mise en place des répertoires spécifiques \<WRAP center round alert 80%\> Assurez-vous bien que la constante globale `APPLICATION_PATH` a bien été définie comme suit dans votre fichier `/public/index.php` : Créez ensuite à la racine de votre projet (ou ailleurs en adaptant votre configuration) un répertoire `code`, puis à l'intérieur un sous-répertoire `template`. `define('APPLICATION_PATH', realpath(__DIR__ . "/.."));` \</WRAP\> # Utilisation Loading Loading @@ -141,7 +121,7 @@ un `Doctrine\ORM\QueryBuilder` comme paramètre d'entrée\!\! \</WRAP\> ### Util::varDump est une variante de var\_dump, à ceci prêt qu'elle affiche les objets de est une variante de var_dump, à ceci prêt qu'elle affiche les objets de manière moins verbeuse. ## Introspection Loading Loading @@ -184,7 +164,7 @@ $params = [ 'generator' => 'service', // On précise le nom complet de sa classe 'class' => 'Application\Service\ExempleService', // On affiche le résultat à l'écran // On affiche le résultat à l'écran ou on l'ajoute si on est en mode console 'echo' => true, // on crée aussi une Factory 'factory' => [ Loading