{"id":13518538,"url":"https://github.com/dannydamsky/Dev-Tools-Magento-2-Module","last_synced_at":"2025-03-31T10:31:57.487Z","repository":{"id":217981409,"uuid":"254454384","full_name":"dannydamsky/Dev-Tools-Magento-2-Module","owner":"dannydamsky","description":"A collection of utilities meant to improve the experience of developing modules for Magento without breaking existing functionality.","archived":false,"fork":false,"pushed_at":"2020-04-09T19:23:16.000Z","size":66,"stargazers_count":20,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-29T12:46:41.599Z","etag":null,"topics":["decoding-jsons","developer-tools","framework","framework-php","imagemagick","json","log-rotations","magento","magento2","magento2-extension","magento2-extension-free","magento2-module","magento2-module-free","php","php-extension","php7","phtml-template","twig-templates","utilities-meant"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dannydamsky.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-09T18:56:50.000Z","updated_at":"2023-12-18T16:03:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"4adb67c9-8d44-4d59-9229-29b96c5708d2","html_url":"https://github.com/dannydamsky/Dev-Tools-Magento-2-Module","commit_stats":null,"previous_names":["dannydamsky/dev-tools-magento-2-module"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dannydamsky%2FDev-Tools-Magento-2-Module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dannydamsky%2FDev-Tools-Magento-2-Module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dannydamsky%2FDev-Tools-Magento-2-Module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dannydamsky%2FDev-Tools-Magento-2-Module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dannydamsky","download_url":"https://codeload.github.com/dannydamsky/Dev-Tools-Magento-2-Module/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246453668,"owners_count":20779991,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["decoding-jsons","developer-tools","framework","framework-php","imagemagick","json","log-rotations","magento","magento2","magento2-extension","magento2-extension-free","magento2-module","magento2-module-free","php","php-extension","php7","phtml-template","twig-templates","utilities-meant"],"created_at":"2024-08-01T05:01:45.974Z","updated_at":"2025-03-31T10:31:57.471Z","avatar_url":"https://github.com/dannydamsky.png","language":"PHP","readme":"DannyDamsky DevTools Extension\n=====================\nA collection of utilities meant to improve the experience of developing modules for Magento\nwithout breaking existing functionality.\n\n-----\n- version: 1.0.0\n- extension key: DannyDamsky_DevTools\n\nRequirements\n------------\n- PHP \u003e= 7.3.0\n- Magento_Config\n- Magento_Eav\n- Magento_Cron\n- PHP Extension - JSON\n- PHP Extension - Imagick\n- PHP Extension - SimpleXML\n- PHP Extension - ZLib\n\nSuggestions\n------------\n- Twig: Version 2.0 and above, enables the use of twig templates in Magento.\n\nCompatibility\n-------------\n- Magento \u003e= 2.3.3\n\nHow To Install\n-------------\nThe recommended way to install this module\nis with composer.\n\nMake sure you have this data in your composer.json file.\n\n        \"repositories\": [\n                {\n                    \"type\": \"vcs\",\n                    \"url\": \"https://github.com/dannydamsky/Dev-Tools-Magento-2-Module\"\n                }\n        ],\n        \"require\": {\n                \"dannydamsky/module-devtools\": \"1.0.0\"\n        }\n\nFeatures\n-----------------\n\nThis module adds useful functionality to Magento 2\nwithout the breaking backwards compatibility or reducing\nperformance in any way that is significant.\n\nThis module's features include:\n\n1. Twig Template Support - Include the \"twig/twig\" package in your composer.json\nand you can start writing all of your templates using Twig, with support for\nmost (if not all) of the functions you normally use in Magento 2 PHTML templates,\nand including access to template variables such as \"block\".\n\n2. An extension to the Magento frontend and backend template (block) classes.\nThis extension enables the use of callable variables in your PHTML template,\nso for example instead of typing:\n\n        \u003c?php echo $block-\u003eescapeHtml(\"YOUR_STRING_HERE\") ?\u003e\n    \n    You can now use the following in your code:\n    \n        \u003c?php echo $escapeHtml(\"YOUR_STRING_HERE\") ?\u003e\n        \n    Usable variables include: $escapeHtml, $escapeHtmlAttr, $escapeJs, $escapeCss, $escapeUrl, and $trans (For translations).\n    \n    For a full list please take a look at:\n        \n        DannyDamsky\\DevTools\\Traits\\BlockTrait::_beforeToHtml()\n        \n    To enable this functionality your block class must extend either of the two classes:\n    \n    Backend:\n    \n        DannyDamsky\\DevTools\\App\\Backend\\Block\\Template\n        \n    Frontend:\n    \n        DannyDamsky\\DevTools\\View\\Element\\Template\n        \n    \u003cb\u003eThese blocks also include helper methods for generating the x-magento-init scripts.\u003c/b\u003e\n        \n3. A slight (but important) improvement to the Magento 2 ImageMagick adapter.\nThe default Magento 2 implementation does not configure ImageMagick to generate\n[progressive JPEGs](https://www.liquidweb.com/kb/what-is-a-progressive-jpeg/), \nthis module enables this behaviour.\n\n4. Improvements to Magento 2's JSON serializer. PHP's json_decode function isn't\ngood at decoding JSONs with lots of unicode and special characters.\nThis module adds an override to the following function:\n\n        Magento\\Framework\\Serialize\\Serializer\\Json::unserialize\n\n    The override attempts to run the above function, but in case of failure\n    relies on an that algorithm has proven to decode more complicated JSON strings.\n    \n5. You no longer have to include \u003cb\u003eregistration.php\u003c/b\u003e in your modules.\nThis module is configured to automatically load any module that does\nnot include this file.\nModules found in the vendor and app/code folders are supported.\n\n6. Helper LESS mixins included in the _module.less file of this module\nfor adding CSS properties with prefixes for browsers.\nPrefixes include: \n\n    - lib-dannydamsky-devtools-prefix-align-items, \n\n    - lib-dannydamsky-devtools-prefix-align-content,\n    \n    - lib-dannydamsky-devtools-prefix-align-self,\n    \n    - lib-dannydamsky-devtools-prefix-justify-content,\n    \n    - lib-dannydamsky-devtools-prefix-justify-self\n    \n    - lib-dannydamsky-devtools-prefix-user-select\n    \n    For a full list please take a look at:\n    \n        view/base/web/css/source/_module.less\n        \n7. Facade classes support\n\n    To create a facade, you must extend the following class:\n    \n        DannyDamsky\\DevTools\\Model\\Facade\n\n    By default, this class expects you to put your facade class in:\n    \n        VendorName\\ModuleName\\Facade\\NAMESPACE_RELATIVE_TO_HELPER\\YourFacade\n\n    Where \u003cb\u003eNAMESPACE_RELATIVE_TO_HELPER\u003c/b\u003e is the relative namespace\n    of the helper class that you want to bind the Facade to.\n    \n    For example, if you want to create a facade for:\n    \n        DannyDamsky\\PlayGround\\Helper\\Person\n        \n    Your facade class needs to have the namespace:\n    \n        DannyDamsky\\PlayGround\\Facade\\Person\n        \n    And then, any public methods that are accessible from your helper method,\n    will be automatically accessible in your Facade class as static methods.\n    \n    In order to override the namespacing behaviour of a Facade class,\n    you may add a constant that equals that class name of the helper that you wish to bind\n    the Facade to.\n    \n    For Example:\n    \n        \u003c?php\n        \n        namespace DannyDamsky\\PlayGround\\Facade;\n        \n        class Logger extends \\DannyDamsky\\DevTools\\Model\\Facade\n        {\n            public const FACADE_HELPER = \\DannyDamsky\\PlayGround\\Logger\\Logger::class;\n        }\n        \n    This code sample binds the Logger Facade to a Logger implementation.\n    \n8. An addition of numerous global functions including:\n\n    - booltostr - Convert a boolean to its strict equivalent.\n    \n    - prettify - Convert a string such as \"someText_here\" to \"Some Text Here\"\n    \n    - time_millis - Returns the current time in milliseconds\n    \n    - escape_double_quotes_in_json_string - Escapes double quotes in a JSON string.\n    \n    - convert_to_utf8 - Converts a unicode encoded string to UTF-8\n    \n    - compress_image_for_web - Uses ImageMagick to compress an image very efficiently with a minimal impact on image quality.\n    \n    - optimize_image_basic - A performance-light variant of compress_image_for_web, best used with small images.\n    \n    - get_trace_as_string - Get the exception trace as string, works the same as the \"Throwable::getTraceAsString()\" method\n    but does not truncate any of the data.\n    \n    - str_shorten - Allows shortening of strings to a specified limit.\n    \n    - is_associative - Returns whether an array is an associative array.\n    \n    - str_contains - Returns whether a string (the haystack) contains another string (the needle),\n    variations of this function include: str_icontains (case-insensitive variant),\n    mb_str_contains (multi-byte variant) and mb_str_icontains (multi-byte case-insensitive variant).\n    \n    - get_module_name - Accepts a classname and returns the name of the module of the given class.\n    \n    - rglob - Same as the \"glob\" function, but searches for files recursively in all child folders.\n    \n    - gzcompress_file - Accepts a source file and compresses it into a GZIP-compressed file.\n    \n    - rm_rf - Recursive force-delete function.\n    \n    - run_in_transaction - Helper function for handling a single transaction run using Magento's\n    ResourceModel/Database adapter classes.\n\n9. Improved database migration classes.\nThis module includes the following abstract classes which\ncan be extended by your module's setup folder classes:\n\n        DannyDamsky\\DevTools\\Model\\Setup\\InstallData\n        \n        DannyDamsky\\DevTools\\Model\\Setup\\InstallSchema\n        \n        DannyDamsky\\DevTools\\Model\\Setup\\UpgradeData\n        \n        DannyDamsky\\DevTools\\Model\\Setup\\UpgradeSchema\n        \n        DannyDamsky\\DevTools\\Model\\Setup\\Uninstall\n        \n    All of these classes have one method for you to implement: \u003ci\u003eexecute()\u003c/i\u003e\n    \n    This method takes no arguments, the \u003cb\u003e$setup\u003c/b\u003e and \u003cb\u003e$context\u003c/b\u003e arguments you are used to\n    still exist as protected class properties \u003cb\u003e$_setup\u003c/b\u003e and \u003cb\u003e$_context\u003c/b\u003e.\n    The \u003cb\u003e$_connection\u003c/b\u003e class property also exists, and is equal to the return value\n    from \u003ci\u003e$setup-\u003egetConnection()\u003c/i\u003e.\n    \n    If you are used to running:\n    \n        $setup-\u003estartSetup()\n        \n    And:\n    \n        $setup-\u003eendSetup()\n        \n    There is no longer a need to do that, these methods are run before and after\n    the \u003ci\u003eexecute()\u003c/i\u003e method respectively.\n    \n    Class Specific Features:\n    \n    Install/Upgrade Schema Classes:\n     - Access to the $_schema class property,\n     which is used for writing Laravel-Like database migration operations.\n     - Built-in version-control support.\n\n    Install/Upgrade Data Classes:\n    - Built-in version-control support.\n    \n    Uninstall Class:\n    - Accessible \u003ci\u003edropTable()\u003c/i\u003e class method.\n    \n    \u003ch4\u003eThe Schema Class Property:\u003c/h4\u003e\n    \n    This property is used for writing Laravel-Like database migration operations.\n    It is worth mentioning that while the code syntax is similar to Laravel,\n    the definitions used are completely Magento-specific and if you've\n    worked with Magento 2 Install/Upgrade Schema classes\n    you should be able to recognize the methods available\n    here quite easily.\n    \n    To create a table you can run \u003ci\u003e$this-\u003e_schema-\u003enewTable(...)\u003c/i\u003e\n    \n    To alter a table you can run \u003ci\u003e$this-\u003e_schema-\u003ealterTable(...)\u003c/i\u003e\n    \n    Or you can just run \u003ci\u003e$this-\u003e_schema-\u003etable(...)\u003c/i\u003e and let the schema\n    property decide if the table should be altered or created \n    (by checking if the table exists in the first place).\n    \n    Either of the 3 functions mentioned above accept the same arguments,\n    the first one is the table name, and the second one is a callable\n    that accepts a $blueprint as an argument.\n    \n    Below is a code sample showing how to use this property:\n    \n        $this-\u003e_schema-\u003etable('dannydamsky_playground_random_table', \n            function (\\DannyDamsky\\DevTools\\Api\\BlueprintInterface $blueprint) {\n                $blueprint-\u003ebigint('entity_id', true)\n                    -\u003esetIdentity(true)\n                    -\u003esetNullable(false)\n                    -\u003esetPrimary(true)\n                    -\u003esetComment('Entity ID');\n                $blueprint-\u003etext('some_text', 255)\n                    -\u003esetNullable(true);\n            }\n        );\n        $this-\u003e_schema-\u003eaddIndex('dannydamsky_playground_random_table', 'some_text'); \n\n    This code creates a table called \"dannydamsky_playground_random_table\",\n    with an \"entity_id\" column and a \"some_text\" column. It also sets an index\n    on the \"some_text\" column after the table has been created.\n    \n    For further information please take a look at these interfaces:\n    \n    The $_schema property:\n    \n        DannyDamsky\\DevTools\\Api\\SchemaInterface\n        \n    The $blueprint argument:    \n        \n        DannyDamsky\\DevTools\\Api\\BlueprintInterface\n        \n    The return value from column function calls of the $blueprint argument:    \n        \n        DannyDamsky\\DevTools\\Api\\ColumnDefinitionInterface\n\n    \u003ch4\u003eThe Built-In Version-Control Support:\u003c/h4\u003e\n    \n    The Install/Upgrade Data/Schema classes provide version control support.\n    \n    Which means that you are not required to use the abstract \u003ci\u003eexecute()\u003c/i\u003e\n    method, instead you can leave it empty and create methods for every version of the\n    module (or you can use them both), by creating methods with the following naming scheme:\n    \n        public function __vMODULE_VERSION_WITH_UNDERSCORES_INSTEAD_OF_DOTS() \n        {\n            // Your Migration Here\n        }\n        \n    The code in the abstract Install/Upgrade Data/Schema class' \u003ci\u003einstall()\u003c/i\u003e and \u003c/i\u003eupgrade()\u003c/i\u003e\n    will know to run these methods, and will know to compare their versions to your current module version.\n    \n    Here's an example of such a method:\n    \n        public function __v1_0_4()\n        {\n            $this-\u003e_schema-\u003etable('dannydamsky_playground_random_table', \n                function (\\DannyDamsky\\PlayGround\\Api\\BlueprintInterface $blueprint) {\n                    $blueprint-\u003etext('some_text')\n                        -\u003esetNullable(false)\n                        -\u003esetDefault('')\n                        -\u003esetComment('Some Text');\n                }\n            );\n        }\n        \n    \u003ch4\u003e Here is sample UpgradeData class from the DannyDamsky\\PlayGround sample module:\u003c/h4\u003e\n    \n        \u003c?php\n        \n        namespace DannyDamsky\\PlayGround\\Setup;\n        \n        use DannyDamsky\\DevTools\\Api\\BlueprintInterface;\n        use DannyDamsky\\DevTools\\Model\\Setup\\UpgradeSchema as ExtendedUpgradeSchema;\n        use Throwable;\n        \n        final class UpgradeSchema extends ExtendedUpgradeSchema\n        {\n            /**\n             * @inheritDoc\n             */\n            public function execute(): void\n            {\n                //\n            }\n        \n            /**\n             * @throws Throwable\n             */\n            public function __v1_0_3(): void\n            {\n                $this-\u003e_schema-\u003etable('dannydamsky_playground_random_table', static function (BlueprintInterface $blueprint): void {\n                    $blueprint-\u003ebigint('entity_id', true)\n                        -\u003esetIdentity(true)\n                        -\u003esetNullable(false)\n                        -\u003esetPrimary(true)\n                        -\u003esetComment('Entity ID');\n        \n                    $blueprint-\u003etext('some_text', 255)\n                        -\u003esetNullable(true);\n                });\n            }\n        \n            /**\n             * @throws Throwable\n             */\n            public function __v1_0_4(): void\n            {\n                $this-\u003e_schema-\u003etable('dannydamsky_playground_random_table', static function (BlueprintInterface $blueprint): void {\n                    $blueprint-\u003etext('some_text')\n                        -\u003esetNullable(false)\n                        -\u003esetDefault('')\n                        -\u003esetComment('Some Text');\n                });\n            }\n        }\n\n10. Log rotation support (Configurable in admin)\n\n    Enables [log rotation](https://en.wikipedia.org/wiki/Log_rotation) functionality from inside Magento 2,\n    with support for features such as moving log each day to a separate\n    directory with a timestamp as its name, compressing log files with GZIP, and\n    deleting the log files after a configured number of days.\n    \n    This feature must be enabled in the admin configuration. (See the configuration section for more details)\n\n11. JS polyfills support (Configurable in admin)\n\n    Enables loading a JS polyfills script to your website,\n    which enables the use of the most-used ES5, ES6 and ES7\n    functions for all browsers.\n    \n    In order to do that, it uses the [Polyfill.IO](https://polyfill.io) API, which\n    can be changed to something else in the admin configurations.\n    \n    Polyfill.IO is particularly good because it gives different results to different browsers, so\n    newer browser versions will not have a noticeable performance impact from loading the polyfills.\n    \n    This feature must be enabled in the admin configuration. (See the configuration section for more details)\n\nConfigurations\n---------------\n\nAll of this module's configurations are located in the Magento 2 admin page \nin the route: \n\nStores -\u003e Configurations -\u003e Advanced -\u003e Developer \n(These configurations only show up when you're in developer mode)\n\nThe configurations in this route that belong to this module include:\n\n1. \u003cb\u003eDebug\u003c/b\u003e - Enable Printing of Twig Generated Templates\n2. \u003cb\u003eTemplate Settings\u003c/b\u003e - Auto-Recompile Twig Templates\n3. \u003cb\u003eTemplate Settings\u003c/b\u003e - Twig Strict Variables\n4. \u003cb\u003eTemplate Settings\u003c/b\u003e - Twig Template Charset\n5. \u003cb\u003eJavaScript Settings\u003c/b\u003e - Enable JS Polyfills\n6. \u003cb\u003eJavaScript Settings\u003c/b\u003e - Polyfill API URL (Depends on JS polyfills being enabled)\n7. \u003cb\u003eCaching Settings\u003c/b\u003e - Cache Twig Templates\n8. \u003cb\u003eLog Rotation Settings\u003c/b\u003e - Enabled\n9. \u003cb\u003eLog Rotation Settings\u003c/b\u003e - Compress (Depends on log rotations being enabled)\n10. \u003cb\u003eLog Rotation Settings\u003c/b\u003e - Days (Depends on log rotations being enabled)\n\nSample Module\n-------------\n\n[Click Here To Download](https://github.com/dannydamsky/Dev-Tools-Magento-2-Module/releases/download/1.0.0/DannyDamsky_PlayGround.tar.gz)\n\nDeveloper\n---------\nDanny Damsky \u003cdannydamsky99@gmail.com\u003e\n\nLicence\n-------\nCopyright (c) 2020 Danny Damsky\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n1. Redistributions of source code must retain the above copyright\n   notice, this list of conditions and the following disclaimer.\n2. Redistributions in binary form must reproduce the above copyright\n   notice, this list of conditions and the following disclaimer in the\n   documentation and/or other materials provided with the distribution.\n3. Neither the name of the author nor the names of its contributors may\n   be used to endorse or promote products derived from this software\n\nTHIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\nARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\nFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\nOR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\nHOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\nLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\nOUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGE.\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdannydamsky%2FDev-Tools-Magento-2-Module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdannydamsky%2FDev-Tools-Magento-2-Module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdannydamsky%2FDev-Tools-Magento-2-Module/lists"}