{"id":18772437,"url":"https://github.com/eftec/autoloadone","last_synced_at":"2025-04-05T23:09:47.816Z","repository":{"id":56975545,"uuid":"138487942","full_name":"EFTEC/AutoLoadOne","owner":"EFTEC","description":"It is a library","archived":false,"fork":false,"pushed_at":"2025-02-22T00:57:34.000Z","size":860,"stargazers_count":39,"open_issues_count":2,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-29T22:07:38.080Z","etag":null,"topics":["autoincluder","code-generator","php","php7"],"latest_commit_sha":null,"homepage":"https://www.eftec.cl","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EFTEC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2018-06-24T14:19:09.000Z","updated_at":"2025-02-22T00:57:21.000Z","dependencies_parsed_at":"2025-02-04T23:32:28.934Z","dependency_job_id":"0cd4e37a-7468-45cc-b500-14c2df6f342c","html_url":"https://github.com/EFTEC/AutoLoadOne","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EFTEC%2FAutoLoadOne","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EFTEC%2FAutoLoadOne/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EFTEC%2FAutoLoadOne/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EFTEC%2FAutoLoadOne/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EFTEC","download_url":"https://codeload.github.com/EFTEC/AutoLoadOne/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247411235,"owners_count":20934653,"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":["autoincluder","code-generator","php","php7"],"created_at":"2024-11-07T19:28:59.261Z","updated_at":"2025-04-05T23:09:47.790Z","avatar_url":"https://github.com/EFTEC.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Auto Include AutoLoadOne Generator\r\n\r\nAutoloadOne is a program that generates an autoload class (Auto Include) for PHP that is project specific. This class is useful to use classes on code without calling each \"include\" manually.   It is a direct alternative to Composer's autoload, but it works differently.   \r\nComposer's autoload, scans the folders during runtime, while this library only scans the folder once, and it stores the result.\r\n\r\n[![Packagist](https://img.shields.io/packagist/v/eftec/autoloadone.svg)](https://packagist.org/packages/eftec/autoloadone)\r\n[![Total Downloads](https://poser.pugx.org/eftec/autoloadone/downloads)](https://packagist.org/packages/eftec/autoloadone)\r\n[![Maintenance](https://img.shields.io/maintenance/yes/2025.svg)]()\r\n[![composer](https://img.shields.io/badge/composer-%3E2.0-blue.svg)]()\r\n[![php](https://img.shields.io/badge/php-7.4-green.svg)]()\r\n[![php](https://img.shields.io/badge/php-8.4-green.svg)]()\r\n[![CocoaPods](https://img.shields.io/badge/docs-60%25-yellow.svg)]()\r\n\r\n\r\n\r\nContrary to other alternatives, it supports the easiest way to autoload classes using PHP without sacrifice performance.\r\n How it works?. AutoLoadOne pre-calculates every class of a project and generates a single autoload.php (or the name \r\nindicated) file that it's ready to use.  You don't need a specific folder, structure or rule to use it. Just generate \r\nthe autoload file **class**, **include,** and you are ready to load any class (even classes without a namespace, classes in the \r\nnamespace in different folders, multiple classes defined in a single file...).  \r\n\r\nAutoLoadOne is a replacement to Composer's Autoload, rendering obsolete the use of psr-0 or psr-4.\r\n\r\n\r\n\u003e \u003cb\u003eNOTE:\u003c/b\u003e If you run the dev-distro, then you must exclude the example/ folder because it contains @autorun tags.  \r\n\r\n**Last Update 26 Jan, 2023**\r\n\r\n\u003e \"Universal Autoloading classes in PHP, any class, any time!\"\r\n\r\n## Table of Contents\r\n\r\n\u003c!-- TOC --\u003e\r\n* [PHP Auto Include AutoLoadOne Generator](#php-auto-include-autoloadone-generator)\r\n  * [Table of Contents](#table-of-contents)\r\n  * [How it Works?](#how-it-works)\r\n  * [When I should re-run AutoLoadOne?](#when-i-should-re-run-autoloadone)\r\n  * [Composer Autoload features:](#composer-autoload-features-)\r\n  * [AutoLoadOne extended features:](#autoloadone-extended-features-)\r\n  * [Getting started](#getting-started)\r\n  * [Usage using the CLI](#usage-using-the-cli)\r\n  * [Usage via code](#usage-via-code)\r\n  * [Usage (generate code via Web)](#usage--generate-code-via-web-)\r\n  * [Usage (via cli)](#usage--via-cli-)\r\n  * [Usage of the generated file (autoload.php)](#usage-of-the-generated-file--autoloadphp-)\r\n  * [Note](#note)\r\n  * [Autorun](#autorun)\r\n  * [Extension](#extension)\r\n  * [Statistic and optimization](#statistic-and-optimization)\r\n    * [How can I reduce the map?](#how-can-i-reduce-the-map)\r\n  * [Test](#test)\r\n    * [AutoLoadOne](#autoloadone)\r\n    * [Optimized AutoLoadOne](#optimized-autoloadone)\r\n    * [Composer's autoload (using optimize)](#composers-autoload--using-optimize-)\r\n    * [Why the size matter?.](#why-the-size-matter)\r\n    * [Lookup usage?](#lookup-usage)\r\n      * [How many lookup are called?.](#how-many-lookup-are-called)\r\n  * [TEST II (Magento 2.2.3)](#test-ii--magento-223-)\r\n    * [Let's say we have 1000 concurrent users](#lets-say-we-have-1000-concurrent-users)\r\n    * [Compression and Magento.](#compression-and-magento)\r\n    * [Code execution.](#code-execution)\r\n  * [Benchmark](#benchmark)\r\n  * [Security](#security)\r\n  * [Composer.json](#composerjson)\r\n  * [Version](#version)\r\n  * [Todo](#todo)\r\n\u003c!-- TOC --\u003e\r\n\r\n## How it Works?\r\n\r\n:one:  \r\n Run AutoLoadOne.php as CLI or as Web.  \r\n:two:  \r\n AutoLoadOne will generate a single file called autoload.php (or the name indicated) based in your project. \r\nFor the record, it takes mere 1.5 seconds to scan WordPress and yes, it is compatible with WordPress.  \r\n:three:  \r\n Include the generated file (ex: autoload.php) in your project code and start using it.  \r\n\r\n## When I should re-run AutoLoadOne?\r\n\r\nYou don't need to run it again if you are adding a new class with the same namespace in the same folder.\r\n\r\nAlso, you could edit autoload.php manually by adding more classes and namespaces.\r\n\r\nOr you could run AutoLoadOne.php again and replace the old generated file.\r\n\r\n## Composer Autoload features:\r\n:black_square_button: One class per file  \r\n:black_square_button: One Namespace per file.  \r\n:black_square_button: The file must have a namespace.  \r\n:black_square_button: It requires composer.  \r\n:black_square_button: It validates the file each file the class is loaded per user.  \r\n:black_square_button: The structure of the folders should be pre-defined.  \r\n:white_check_mark: Support CLI  \r\n\r\n## AutoLoadOne extended features:\r\n:white_check_mark: One or Many classes per file.  \r\n:white_check_mark: One or many namespaces per file.  \r\n:white_check_mark: The file could contain optionally a namespace.  \r\n:white_check_mark: It only requires PHP  \r\n:white_check_mark: The folder structure and classes are validated once.  \r\n:white_check_mark: If you add a class that shares a previous folder and uses the previous namespace, then you don't need to run the generator.  \r\n:white_check_mark: You could use any structure of folder. It's recommended to use the same folder for the same namespace,\r\nbut it's not a requisite.  \r\n:white_check_mark: Support CLI and Web-UI.  \r\n:white_check_mark: It doesn't require APCU, lock files or cache.  \r\n:white_check_mark: It´s compatible with practically any project, including a project that uses Composer's autoload.  \r\n:white_check_mark: It's compatible with PSR-0, PSR-4, and practically  any specification, since you don't need to use\r\nany special configuration or standard.  \r\n:white_check_mark: It allows libraries outside the project folder.  \r\nFor example /someuser/myproject/ allows to include libraries from the folder /otheruser/library/    \r\n:white_check_mark: It doesn't require APCU, lock files or cache.   \r\n:white_check_mark: It has a minimum impact on runtime.         \r\n:white_check_mark: It allows compression without impacting the runtime.   \r\n\r\n## Getting started\r\n\r\nYou could run directly AutoLoadOne.php (via web of via CLI), or you could create a file that calls it.\r\n\r\n## Usage using the CLI\r\n\r\nYou must execute it in the root folder, and it will generate a file called autoload.php.\r\n\r\n```shell\r\nphp AutoLoadOne.php -generate\r\n```\r\n\u003e If AutoLoadOne.php is not in the same folder then you can copy it, or set the path to use it \r\n\u003e php /somefolder/AutoLoadOne.php -generate\r\n\u003e There are more commands that you can use but -generate is the basic and out-the-box experience.\r\n\r\n\r\n## Usage via code\r\n\r\n* Copy AutoLoadOne.php in the root folder (recommended) of your project\r\n* Execute it directly or\r\n* Create the next PHP file (in the root folder) and execute it.\r\n\r\n```php\r\n\u003c?php\r\n// This code will generate the file autoload.php\r\n\r\nuse eftec\\AutoLoadOne\\AutoLoadOne;\r\n\r\ndefine(\"_AUTOLOAD_SELFRUN\",false); // we want to call it manually.\r\ninclude \"AutoLoadOne.php\"; // or change the path of the file.\r\n$auto=new AutoLoadOne();\r\n$auto-\u003einit();\r\n$auto-\u003eprocess();\r\n$auto-\u003erender();\r\n```\r\n\r\n\r\n\r\n## Usage (generate code via Web)\r\n\r\n:one:  \r\n Copy the file **autoloadone.php** somewhere.\r\n\r\n:two:  \r\n For security, you could edit the first lines of the class **autoloadone.php**. Change the user, password and autoloadenter if it's required.\r\n\r\n```php\r\n\u003c?php\r\ndefine(\"_AUTOLOAD_USER\",\"autoloadone\");\r\ndefine(\"_AUTOLOAD_PASSWORD\",\"autoloadone\");\r\ndefine(\"_AUTOLOAD_ENTER\",true); // if you want to autoload (no user or password) then set to true\r\n?\u003e\r\n```\r\n:three:  \r\n   Start the browser\r\n\r\nEnter your user and password.  If _AUTOLOAD_ENTER is true then you are logged automatically.\r\n\r\n![autoloadone login](https://github.com/EFTEC/AutoLoadOne/blob/master/doc/login.jpg \"Autoloadone logon\")\r\n\r\n\r\n:four:  \r\n Select the folder to scan, then select the file to generate and finally press the button GENERATE.\r\n\r\n![autoloadone screen](https://github.com/EFTEC/AutoLoadOne/blob/master/doc/screen.jpg \"Autoloadone screen\")\r\n\r\n* Root Folder : The folder to scan.\r\n* Generated File: The full path (local) of the autoload.php.  Even if you are not using the generation of file, you must specify it, because the program uses for determine the relative path.\r\n* Save File: If you check it, then generate file will be generated.  If PHP doesn't have access to save the file, then you could copy the code manually (screen Result)\r\n* Excluded Namespace : Namespace excluded of mapping.\r\n* Excluded Map : Paths excluded to scan (they are not recursives)\r\n\r\n\r\n\r\n:five:  \r\n The result should look this:\r\n\r\n![autoloadone screen2](https://raw.githubusercontent.com/EFTEC/AutoLoadOne/master/doc/screen2.jpg \"Autoloadone screen2\")\r\n\r\n## Usage (via cli)\r\n\r\n![autoloadone cli](https://raw.githubusercontent.com/EFTEC/AutoLoadOne/master/doc/cli1.jpg)\r\n\r\nIn the shell, browser to the folder where you want to generate the code and run the next command\r\n\r\nCommands available :  \r\n\r\n* current (scan and generates files from the current folder)  \r\n* folder (folder to scan)  \r\n* filegen (folder where autoload.php will be generate)\r\n* filename (name of the filename to generate by default its autoload.php)  \r\n* save yes/no (save the file to generate).This option is required.\r\n* excludens (namespace excluded)  \r\n* excludepath (path excluded)  \r\n* externalpath (include an external path). An external path is a library that lives outside the project folder\r\n\r\n\r\n\u003e Example: php autoloadone.php -folder folder\\scan -filegen folder\\whereautoload\\ -save yes\r\n\r\n\r\n```\r\nphp folder/located/autoloadone.php -current\r\n```\r\n\r\n\r\n\r\n## Usage of the generated file (autoload.php)\r\n\r\n:one:  \r\ninclude the generated file by the previous step. ex: autoload.php\r\n\r\n```php\r\n\u003c?php\r\ndefine(\"_AUTOLOAD_ONEDEBUG\",true); // this line is optional. By default, the DEBUG is off. The debug mode is used for find errors.\r\ninclude \"autoload.php\"; // it could be an absolute or relative path.\r\n?\u003e\r\n```\r\nand that's it!.\r\n\r\nIn the /test folder you could find some example to try.\r\n\r\n\u003e Note:Finally, you could delete the file autoloadone.php if you wish for.\r\n\r\n## Note\r\n\r\n\u003e If you want to exclude a class, you could add the namespace to the exclude list, or you could skip a folder.  \r\n\u003e Also, if a class has the next comment, it's excluded automatically:\r\n\r\n```php\r\n\u003c?php\r\n// @noautoload\r\n?\u003e\r\n```\r\n\r\n\r\n## Autorun\r\n\r\n\u003e If you want to execute (run) a php file, then you could add the next comment.\r\n\r\n```php\r\n\u003c?php\r\n// @autorun\r\n?\u003e\r\n```\r\n\r\n\u003e You could also set priority to the execution by adding a comment with @autorun first\r\n\r\n```php\r\n\u003c?php\r\n// @autorun first\r\n?\u003e\r\n```\r\n\r\n\r\n\u003e If you find the error: Parse error: syntax error, \u003cmessage\u003e in on line 000. Then some php files scanned have some syntax error. The solution is to fix the problem or to exclude the whole folder.  \r\n\u003e How to find the file with error? You could run the page with the debug flag: autoloadone.php?debug=1  \r\n\r\n## Extension\r\n\r\nYou could change the extension (by default it is .php) by running the next command\r\n\r\n```php\r\n$auto=new AutoLoadOne();\r\n$auto-\u003eextension='.php'; // it's not required. By default it's .php\r\n```\r\n\r\n## Statistic and optimization\r\n\r\nThis library generates the next statistics.  **The objective is simple, you must reduce (in the possible), the size of the map. The smaller the map, then the better.**\r\n\r\n```\r\nNumber of Classes: 42\r\nNumber of Namespaces: 12\r\nNumber of Maps: 16\r\nNumber of PHP Files: 50\r\nNumber of PHP Autorun: 3\r\nNumber of conflicts: 0\r\nRatio map per file: 32% Acceptable (less is better. 100% means one map/one file)\u003c\r\nRatio map per classes: 38.1% Acceptable (less is better. 100% means one map/one class)\r\nMap size: 3.1 kbytes (less is better, it's an estimate of the memory used by the map)\r\n```\r\nExample of the screen:\r\n\r\n![autoloadone screen](doc/screen3.jpg \"Autoloadone screen\")\r\n\r\nIn the log file:\r\n* White means a normal operation\r\n* Yellow means a warning. For example, some file was excluded.\r\n* Green means an optimization.\r\n* Blue means an important operation was done succesfully.\r\n* Red is an error that must be attended.\r\n\r\n\r\n### How can I reduce the map?\r\n\r\n* You could use one class / one file, also, the class must have the same name as the filename.  **The name of the namespace is irrelevant**\r\n  \u003e Example Customer.php and class Customer { }\r\n* Grouping classes of the same namespace in the same folder. So, the library could map the whole namespace as a single folder instead of map per file/class. \r\n* * :file_folder: repository (_repositoryns\\\\_)\r\n* * * :page_with_curl: MyClass.php _repositoryns\\\\MyClass_\r\n* * * :page_with_curl: MyClass2.php _repositoryns\\\\MyClass2_\r\n* * :file_folder: model (_namespace_model\\\\_)\r\n* * * :page_with_curl: MyClass.php _namespace_model\\\\MyClass_\r\n* * * :page_with_curl: MyClass2.php _namespace_model\\\\MyClass2_\r\n* You could remove (:scissors:) namespaces and folders that you don't need it. Some namespaces and folders are used by the system however, they don't require to be autoloaded because they are loaded manually (for example, most libraries load \r\nits own include manually)\r\n* * :file_folder: somelibrary \r\n* * * :page_with_curl: MainLibraryClass.php \r\n* * * :page_with_curl: IncludesLibrary.php :scissors:\r\n* * * :file_folder: somelibrary :scissors:\r\n* * * * :page_with_curl: MoreIncludesLibrary.php :scissors:\r\n* * * * :page_with_curl: MoreIncludesLibrary.php :scissors:\r\n* You could also exclude a file/class/include/strut by adding the tag **@noautoload**\r\n```php\r\n/* @noautoload */\r\nclass Someclass {\r\n\r\n}\r\n```\r\n* * :file_folder: somelibrary \r\n* * * :page_with_curl: MainLibraryClass.php \r\n* * * :page_with_curl: IncludesLibrary.php **@noautoload** :scissors:\r\n* Only files with the extension **.php** (or the defined extension) are loaded. So, Files **.inc**, **.phpinclude** or similar, are automatically excluded (:scissors:).\r\n* * :file_folder: somelibrary \r\n* * * :page_with_curl: file.inc.php (inc.php is included but .inc)\r\n* * * :page_with_curl: IncludesLibrary.inc :scissors:\r\n* * * :page_with_curl: MoreIncludesLibrary.inc :scissors:\r\n* Another optimization is to write **many classes in the same file**. This library even allows to use multi classes / multi namespaces in the same file. So, it's possible to create a bulk version of a project.\r\n* * :page_with_curl: AllClassesOneFile.php \r\n* * * namespace _repositoryns\\\\_\r\n* * * * class _repositoryns\\\\MyClass_\r\n* * * * class _repositoryns\\\\MyClass3_\r\n* * * namespace _anotherns\\\\MyClass2_\r\n* * * * class _anotherns\\\\MyClass2_\r\n\r\n## Test \r\n\r\nI created an empty blog on Laravel. The project is empty but the default libraries and components.\r\n\r\n\r\nFiles:\r\n\r\n    7545 files in total. (including files that aren't PHP files)\r\n    \r\n### AutoLoadOne\r\n\r\n    Number of Classes: 5565\r\n    Number of Namespaces: 765\r\n    Number of Maps: 2305 (you want to reduce it)\r\n    Number of PHP Files: 6302\r\n    Number of PHP Autorun: 0\r\n    Number of conflicts: 31\r\n\r\nFile generated:   \r\n\r\n    autoload.php 231kb.\r\n    \r\n### Optimized AutoLoadOne \r\n\r\nI separated PHPUnit and Mockery from the project. Why? Both libraries are for unit test.\r\n\r\nexcluded namespace = /vendor/phpunit/*,/vendor/mockery/*\r\n\r\n\r\n    Number of Classes: 5565\r\n    Number of Namespaces: 765\r\n    Number of Maps: 1535 (you want to reduce it)\r\n    Number of PHP Files: 6302\r\n    Number of PHP Autorun: 0\r\n    Number of conflicts: 13     \r\n\r\nFile generated: \r\n\r\n    autoload.php 159kb.    \r\n\r\n### Composer's autoload (using optimize)\r\n\r\ncomposer dump-autoload -o\r\n\r\n    Generated optimized autoload files containing 3519 classes\r\n    Number of Maps: 3519 (static and not-static)\r\n\r\nAutoload uses one of the next methods:\r\n\r\n* Static:  (fast method, it uses more memory, and it requires to be calculated manually)\r\n\r\n  \r\n    autoload.php 1kb  \r\n    autoload_real.php 3kb  \r\n    autoload_static.php 468kb  \r\n    ClassLoader.php 14kb  \r\n\r\n\r\n* Not static: (default method)\r\n\r\n\r\n    autoload.php 1kb\r\n    autoload_real.php 3kb\r\n    autoload_namespaces.php 1kb\r\n    autoload_psr4.php 4kb\r\n    autoload_classmap.php 426kb    \r\n\r\n\r\n### Why the size matter?.\r\n\r\nLet's say we are calling a single webpage that uses autoload.\r\n\r\nIf we use **Composer's autoload (static)**, we are also calling a file that uses **468kb** (plus other files), and this memory is loaded into the memory. It could use (an average of) **609kb of ram** per call (it's around PHP file x 1.3 x 1kb)\r\n \r\nFor example, what if we have **1000 concurrent users**. It will use 609kb x 1000 = **609mb of ram** thanks to Autoload alone at the same time and with **10k concurrent users** we will use **6gb of ram** only because autoload.   \r\n\r\n\r\nWith **AutoLoadOne**, it is optimized to **302mb** (1000 users) or 3gb (10k users), it is for the version not optimized.\r\n\r\nAutoLoadOne tags all classes from the project, including classes that aren't defined in composer.json (unless they are excluded from the project). **Composer's autoload found only 3519 classes, while AutoLoadOne found all classes of the project (5565).**\r\n\r\nHowever, some classes are not required to be loaded by the project (for example unit test classes), so we could exclude those classes of the project.\r\n\r\nFor example, excluding PHPUnit and Mockery reduces the use to 206mb (1000 users) or 2gb (10k users) but **we could optimize it even further.**\r\n \r\n| Concurrent Users | Composer's autoload (Optimized) | AutoLoadOne | AutoLoadOne Optimized | AutoLoadOne Optimized and compressed |\r\n|------------------|---------------------------------|-------------|-----------------------|--------------------------------------|\r\n| 1000             | 609mb                           | 301mb       | 206mb                 | 130mb                                |\r\n| 10000            | 6gb                             | 3gb         | 2gb                   | 1gb                                  |\r\n\r\n\r\n### Lookup usage?\r\n\r\nLet's say we have a \"map\" with different elements. How much time does it take to find the element of the map?.\r\n\r\n| Map size  | Time (1 million of lookup sequentially) |\r\n|-----------|-----------------------------------------|\r\n| 100       | 0.271 seconds +/-                       |\r\n| 10.000    | 0.299 seconds  +/-                      |\r\n| 1.000.000 | 0.376 seconds  +/-                      |\r\n\r\nSo, the size of the map/lookup time is not important. The difference between a small map (100 elements) versus a huge map (1 million of elements) is 0.1 second in total (per 1 millon of queries). \r\nHowever, the memory usage matters, and it could impact the performance considerably.\r\n\r\n#### How many lookup are called?.\r\n\r\nLet's say we have 10k concurrent users and each one calls 100 different classes. It means we are doing 10k x 100 = 1 million of lookup at the same time.\r\n\r\n## TEST II (Magento 2.2.3)\r\n\r\nMagento is a huge project, it has 22k PHP files and from it, 20k are classes. \r\n\r\nAutoLoadOne:\r\n\r\n    Number of Classes: 21063\r\n    Number of Namespaces: 7018\r\n    Number of Maps: 9473 (you want to reduce it)\r\n    Number of PHP Files: 22862\r\n    Number of PHP Autorun: 0\r\n    Number of conflicts: 6\r\n    Ratio map per file: 41.44% Bad. (less is better. 100% means one map/one file)\r\n    Ratio map per classes: 44.97% Bad. (less is better. 100% means one map/one class)\r\n    Map size: 1398.7 kbytes (less is better, it's an estimate of the memory used by the map)\r\n    Map size Compressed: 1195.1 kbytes (less is better, it's an estimate of the memory used by the map)\r\n\r\nIt takes +/- 200 seconds to generate the autoload.php \r\n\r\nIn comparison, Composer's autoload (optimized) uses\r\n\r\n    Generated optimized autoload files containing 11582 classes\r\n    Number of Maps: 11582 classes (2.6mb of memory will be use per request per user)\r\n    \r\n| Composer's autoload (optimized) | AutoLoadOne (not optimized) | AutoLoadOne (not optimized, compressed) |     \r\n|---------------------------------|-----------------------------|-----------------------------------------|\r\n| 2.6mb                           | 1.36mb                      | 1.16mb                                  |\r\n\r\nHowever, it is without a manual optimization.    \r\n    \r\n### Let's say we have 1000 concurrent users    \r\n\r\n| Concurrent Users(*) | Composer's autoload (Optimized) | AutoLoadOne (not optimized) | AutoLoadOne (compressed) |\r\n|---------------------|---------------------------------|-----------------------------|--------------------------|\r\n| 1000                | 2.6gb                           | 1.36gb                      | 1.16gb                   |\r\n| 10000               | 26gb                            | 13.6gb                      | 11.6gb                   |      \r\n\r\n\u003e (*) However, Magento wasn't create for concurrency. But, however what we are measuring is not the number of\r\n\u003e concurrent users but the number of concurrent calls (for example rest-json, opening a page and such).\r\n\r\n### Compression and Magento.\r\n\r\nWhile AutoLoadOne is able to compress the map, but it only compresses the path of it, not the namespace. It is\r\nbecause the compression is aimed to generate the minimum impact on the system.   Magento relies on heavily in huge \r\nnamespaces so the compression is unable to compress them. But still, the system is able to compress values in 15%.\r\n\r\nIn general, the compression allows to shrink the values in 40-50%.\r\n\r\n\r\n### Code execution.\r\n\r\nBoth AutoLoadOne and Composer's autoload execute a code when it is initialized/executed.\r\n\r\nWhen AutoLoadOne generates the map, it consists of two relational arrays as follows:\r\n\r\n```php\r\n    private $_arrautoloadCustom = array(\r\n\t\t'Magento\\AdminNotification' =\u003e '/app/code/',\r\n\t\t'Magento\\Notice' =\u003e '/app/code/Developer/',...\r\n\r\n```\r\n\r\nWhile Composer's autoload generates an array that requires concatenation.\r\n\r\n```php\r\narray(\r\n    'Magento\\\\AdminNotification' =\u003e $baseDir . '/app/code/MagentoActions.php',\r\n    'Magento\\\\Notice' =\u003e $baseDir . '/app/code/Developer/Notice.php',\r\n```\r\n\r\nSo it requires to concatenate each map (with a variable called $baseDir).  So Composer's autoload affects slighly the performance.\r\n\r\n\r\n## Benchmark\r\n\r\nPHP 7.1.18 + Windows 10 + SSD.\r\n\r\n![AutoloadOne Benchmark](https://raw.githubusercontent.com/EFTEC/AutoLoadOne/master/doc/speed.jpg)  \r\n\r\n_More is better._\r\n\r\n\r\n\u003e I did a synthetic benchmark by loading different classes and reading the performance of it. Since my machine has a SSD disk then, the impact of the disk is minimum in comparison with a mechanical hard disk.\r\n\u003e This chart compares the performance against INCLUDE.\r\n\r\n## Security\r\n\r\nYou could block the access to the file\r\n\r\nRedirectMatch 403 ^/folder/^/folder/.*$\r\n\r\n\u003e :heavy_exclamation_mark: While the program has a build-in-security measure, however I suggest to protect adding new layers of security such as locating the AutoLoadOne.php file\r\noutside the public/web folder.\r\n\r\n\u003e AutoLoadOne.php is not safe (because it writes a generate file), it doesn't have access to the database, neither it allows to write any content to the file but, it could overwrite an exist code and put down a system.\r\n\r\n\u003e However, the generate file is safe (autoload.php) and you could expose to the net.\r\n\r\n* Change the user and password and set _AUTOLOAD_ENTER to false.\r\n* Or, Don't put this file in your public website.\r\n* Or, change the filename.\r\n* Or, you could block the access to the file using .htaccess or similar.  \r\n\r\n```\r\nRewriteEngine On\r\nRewriteBase /\r\n\r\n\u003cFiles \"AutoLoadOne.php\"\u003e\r\nOrder Allow,Deny\r\nDeny from all\r\n\u003c/Files\u003e\r\n```\r\n\r\n* Or you could restrict the access to PHP, and it's the behaviour by default on Linux (it runs under Apache's account\r\n, most of the time as user NOBODY)\r\n\r\n\r\n## Composer.json\r\n\r\nCommonly, this library does not need **composer.json**, and it actively ignores its configuration (because it reads the PHP\r\n source code directly). However, since 1.19, AutoLoadOne reads (optionally) part of the information of composer.json (for compatibility \r\npurpose).  For example, the library **guzzlehttp** uses this feature.   \r\n\r\n\u003e Note: it requires to set the constant _AUTOLOAD_COMPOSERJSON to **true**. By default, this variable is **false**.\r\n  \r\nLet's say the next file:  \r\n\r\ncomposer.json  \r\n  \r\n```json  \r\n{\r\n  \"autoload\": {\r\n    \"psr-4\": {\r\n      \"blahblahblah\": \"some folder blahblahblah/\"\r\n    },\r\n    \"files\": [\"src/functions_include.php\"]\r\n  }\r\n}\r\n```\r\n\r\nIf AUTOLOAD_COMPOSERJSON is true the AutoLoadOne includes the file (or files) declared in composer.json and declared \r\nin 'files'.  This file or files is added to our autoload.php as follows:\r\n \r\nOur code to generate autorun.php  \r\n```php\r\ndefine(\"_AUTOLOAD_COMPOSERJSON\",true);\r\ninclude 'vendor/eftec/autoloadone/AutoLoadOne.php';\r\n``` \r\n \r\nAnd our autorun.php generated.  \r\n```php   \r\n@include __DIR__.'/folder/jsontest/src/functions_include.php'; \r\n```\r\nSince it is done once (when autoload.php is generated), then this feature does not affect the performance because it \r\nreads the composer.json files once.  \r\n  \r\n\r\n## Version\r\n* 1.30.1 2025-02-21\r\n  * Fixed a problem with the command line. \r\n* 1.30 2025-02-21\r\n  * Fixed external path.\r\n  * Fixed a warning with a float value.\r\n* 1.29 2024-12-30\r\n  * update dependencies. \r\n  * cleaned the code\r\n* 1.28 2023-01-26\r\n  * Small cleanups \r\n* 1.27 2022-08-27\r\n  *  [fix] fixed a problem with double mapped.\r\n* 1.26 2022-02-21\r\n    * [fix] compatibility with PHP 8.1. \r\n    * Raising the compatibility with php 7.1.5 and higher. If you want to use an old version, then you can use 1.25.1\r\n    * Adding AutoLoadOne as a composer's binary file.\r\n* 1.25.1 2021-06-09\r\n    * [fix] in autoloadone_exception_handler when the arguments of the error is not an array but a string.\r\n* 1.25 2021-04-17\r\n    * A better error management. Now, it shows the line of the error in a custom trace.\r\n* 1.24 2021-04-17\r\n    * [cli] Re-colored the CLI.   \r\n    * [code] Some cleanups in the code.\r\n    * [fix] Now the generated file shows the correct hour.\r\n* 1.23 2021-02-26\r\n    * Updatted the file generated. \r\n* 1.22.2 2021-02-26\r\n    * fixed composer.json\r\n* 1.22.1 2021-02-26\r\n    * fixed an error in the code\r\n* 1.22 2021-02-26\r\n    * Another fix (it failed to save the configuration file. It failed to use the same path for multiple classes)\r\n    * Configuration now it is stored in the same file autoload.php.  The old file is still could be used but only if \r\n      the new configuration is not set or used.\r\n    * Removed part of the configuration, functions related with json and constants related with json.   \r\n* 1.21.2 2021-02-15\r\n    * Removed wrong \"']\" characters.\r\n* 1.21.1 2021-02-15\r\n    * fixed composer.json (wrong number)\r\n* 1.21 2021-02-15\r\n    * Fixed a big problem with linux. It used basename(), but it works diffently in Linux and Windows. Now, it works in\r\n      Linux.\r\n* 1.20 2020-09-02\r\n    * some cleanups.  \r\n    * The GUI has some examples.  \r\n    * _AUTOLOAD_COMPOSERJSON is indicated where it is executed or not.   \r\n* 1.19.2 2020-06-05\r\n    * composer.json feature is now optional (and disable by default)   \r\n* 1.19.1 2020-06-05\r\n    * composer.json autoload-files now it could be excluded via \"exclude-path\"  \r\n* 1.19 2020-06-05  \r\n    * Added composer.json {'autoload':{'files':[]}}   \r\n* 1.18 2020-04-23 \r\n    * Some cleaning.\r\n    * The generated file is alsoc cleaned and optimized.   \r\n* 1.17 2020-01-26 (optional but by default), the map is compressed.\r\n    *  The compression has a minimum impact on runtime, it only uses a regular expression to replace a string. \r\n* 1.16 2019-08-04 Removed git reference. It's not used.  Changed the style format to PSR\r\n* 1.15 2019-06-08 Removed external css again. Now it generates the css inside the file.\r\n* 1.14 2019-06-08 Fixed some bug.  Reverted to global (const arrays are not compatible with php\u003c7.0)  \r\n* 1.12 2019-05-10 Added some changes pushed. Removed css.\r\n* 1.11 2019-03-04 It allows to specify the result php file. And some cleanups.  Now, /namespace/nameclass:class is not considered a class\r\n* 1.10 2018-10-18 It solves a small bug when we load autoload.php from a different url,\r\nand it calls an external and remote folder.\r\n* 1.9 2018-10-14 A small fix and some colors.\r\n* 1.8 2018-10-14 Added external path and some fixes. Now you could add a path without comma (it's added automatically) [WebUI] \r\n* 1.7 2018-10-12 Some small fixes. Now by default, the system uses the caller's path instead of the AutoLoadOne.php path.\r\n* 1.6 2018-09-28 Added wildcard (*) to exclusion list (folders).\r\n* 1.5 2018-09-05 Now the interface open automatically by default. This file must be deleted or restricted if it's used publicity.\r\n* 1.4 2018-08-25 Some example. Now the interface doesn't open automatically by default. It's for security.\r\n* 1.3 2018-07-05 Now it works with interface, and it fixes a problem with some specific file.  It also fixes a problem\r\nwith linux vs Windows folder.\r\n* 1.2 2018-07-01 Lots of changes. Modified exclusion.  Title and icons for the web ui.  It also allows to disable the web.\r\n* 1.1 2018-06-26 Some fixes. \r\n* 1.0 2018-06-24 First version  \r\n\r\n## Todo\r\n* ~~Save configuration~~\r\n* ~~CLI (more commands)~~\r\n* Clean the code.\r\n* ~~Convert to a single class.~~\r\n* ~~External folder/library (relative or absolute path)~~\r\n* The generation fails if a php file has an error.\r\n* ~~Specify the extensions. By default, it scans only .php files.~~\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feftec%2Fautoloadone","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feftec%2Fautoloadone","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feftec%2Fautoloadone/lists"}