{"id":23537725,"url":"https://github.com/prod3v3loper/php-auto-autoloader","last_synced_at":"2025-05-15T00:22:00.257Z","repository":{"id":57044855,"uuid":"97158109","full_name":"prod3v3loper/php-auto-autoloader","owner":"prod3v3loper","description":"🏗 With this autoloader, you do not need any more, no matter where you have a master in your root, the autoloader will find it.","archived":false,"fork":false,"pushed_at":"2024-05-13T20:52:03.000Z","size":119,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-26T03:18:58.648Z","etag":null,"topics":["auto","autoload","autoload-cache","autoload-class","autoloader","autoloaders","autoloading","autoloading-classes","autoloadphp","php","php-auto-autoloader"],"latest_commit_sha":null,"homepage":"https://prod3v3loper.github.io/php-auto-autoloader/","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/prod3v3loper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-13T19:31:05.000Z","updated_at":"2024-05-13T20:44:54.000Z","dependencies_parsed_at":"2024-05-13T21:30:29.239Z","dependency_job_id":"38d02d52-9dc7-452f-b2f4-33c7613e4efa","html_url":"https://github.com/prod3v3loper/php-auto-autoloader","commit_stats":{"total_commits":69,"total_committers":5,"mean_commits":13.8,"dds":0.5217391304347826,"last_synced_commit":"d4d69ec7ff35d61db06b247b293f4b48acd85235"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prod3v3loper%2Fphp-auto-autoloader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prod3v3loper%2Fphp-auto-autoloader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prod3v3loper%2Fphp-auto-autoloader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prod3v3loper%2Fphp-auto-autoloader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prod3v3loper","download_url":"https://codeload.github.com/prod3v3loper/php-auto-autoloader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239250723,"owners_count":19607517,"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":["auto","autoload","autoload-cache","autoload-class","autoloader","autoloaders","autoloading","autoloading-classes","autoloadphp","php","php-auto-autoloader"],"created_at":"2024-12-26T03:19:05.634Z","updated_at":"2025-02-17T07:26:57.056Z","avatar_url":"https://github.com/prod3v3loper.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n![Melabuai Logo](https://raw.githubusercontent.com/prod3v3loper/php-auto-autoloader/master/img/icon-MB.png \"Melabuai Brand\")\n\n![Language](https://img.shields.io/github/languages/top/prod3v3loper/php-auto-autoloader.svg?style=flat \"Language\")\n![Repo Size](https://img.shields.io/github/repo-size/prod3v3loper/php-auto-autoloader.svg?style=flat \"Repo size\")\n![Code SIze](https://img.shields.io/github/languages/code-size/prod3v3loper/php-auto-autoloader.svg?style=flat \"Code size\")\n![Github Release date](https://img.shields.io/github/release/prod3v3loper/php-auto-autoloader.svg?style=flat \"Github Release date\")\n![Packgist PHP Version](https://img.shields.io/packagist/php-v/prod3v3loper/php-auto-autoloader.svg?style=flat \"Packgist PHP Version\")\n![MIT License](https://img.shields.io/github/license/prod3v3loper/php-auto-autoloader.svg?style=flat \"MIT License\")\n[![Website](https://img.shields.io/website-up-down-green-red/https/www.tnado.com/open-source-projects-by-prod3v3loper.svg?style=flat \"Website\")](https://www.tnado.com/open-source-projects-by-prod3v3loper/ \"Website\")\n\n**melabuai**\n\n# 🏗 PHP Auto Autoloader \n\nWith this autoloader, you do not need any more, no matter where you have a master in your root, the autoloader of MB tnado Ai will find it. The classes found can be indexed to retry without searching.\n\n# Usage\n\n\u003c/div\u003e\n\nInstantiate your classes, interfaces, traits or even abstract classes, no matter where.\nThe only thing you have to do is to integrate.\n\n## Packagist with Composer\n\nThis solution extends the vendor autoloader because it calls the files with certain criteria. The extension allows you to call classes wherever the Autoloader is involved.\n\nDownload [Composer](https://getcomposer.org/) local or global. Check for more [Tutorial - NetBeans with Composer and Packagist](https://www.tnado.com/blog/netbeans-with-composer-and-packagist-the-php-package-manager/) for this one.\n\nYou found the Autoloader package on [Packagist - PHP Auto Autoloader](https://packagist.org/packages/prod3v3loper/php-auto-autoloader).\n\nAdd the Autoloader dependencie to the **composer.json** and set the autoload.\n```json\n{\n    ...\n    \"autoload\": {\n        \"psr-4\": { \"Aautoloder\\\\\": \"autoload/src\" }\n    },\n    \"require\": {\n        \"prod3v3loper/php-auto-autoloader\": \"\u003e=1.0\"\n    }\n    ...\n}\n```\n\nNow run the composer install command with php\n```\nphp composer.phar install\n```\ne.g.\n```\ncomposer install\n```\n\nThis is the vendor autoloader invites our autoloader and now we do not need to specify any more class and can load all our classes.\n\n`index.php`\n```php\n\u003c?php\n// Define the document root project folder\ndefine('MBT_DOCUMENT_ROOT', __DIR__);\n\n// Load the autoloader\nrequire_once __DIR__ . '/vendor/autoload.php';\nnew \\Aautoloder\\Loader(array(MBT_DOCUMENT_ROOT));\n?\u003e\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n    \u003chead\u003e\n        \u003cmeta charset=\"UTF-8\"\u003e\n        \u003ctitle\u003eProd3v3loper - Autoload\u003c/title\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n        \u003c?php\n\n        // METHOD 1: Fastest way, the namespace is foldername structure and filename is equal to filename\n        $class_one = new testclasses\\first_class();\n        $class_one-\u003emethod_from_first_class();\n\n        // METHOD 2: The slower way, namespace is equal to folder structure but the classname is differnt to the filename\n        $class_two = new testclasses\\classes\\second_class();\n        $class_two-\u003emethod_from_second_class();\n\n        // METHOD 3: The slowest way, here ist nothing euqal\n        $three_class = new name_space\\namespace2\\third_class();\n        $three_class-\u003emethod_from_third_class();\n        \n        ?\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\n## Git clone\n\nGet per [Git](https://git-scm.com/) or [download](https://github.com/prod3v3loper/php-auto-autoloader/archive/master.zip) and use it.\n\n```\ngit clone https://github.com/prod3v3loper/php-auto-autoloader.git /projects/\n```\n\nSo we use it without a vendor and can start a direct call.\n\n`index.php`\n```php\n\u003c?php\n// Define the document root project folder\ndefine('MBT_DOCUMENT_ROOT', __DIR__);\n\n// Load the autoloader\nrequire_once './autoload/src/Loader.php';\nnew \\Aautoloder\\Loader(array(MBT_DOCUMENT_ROOT));\n?\u003e\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n    \u003chead\u003e\n        \u003cmeta charset=\"UTF-8\"\u003e\n        \u003ctitle\u003eProd3v3loper - Autoload\u003c/title\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n        \u003c?php\n\n        // METHOD 1: Fastest way, the namespace is foldername structure and filename is equal to filename\n        $class_one = new testclasses\\first_class();\n        $class_one-\u003emethod_from_first_class();\n\n        // METHOD 2: The slower way, namespace is equal to folder structure but the classname is differnt to the filename\n        $class_two = new testclasses\\classes\\second_class();\n        $class_two-\u003emethod_from_second_class();\n\n        // METHOD 3: The slowest way, here ist nothing euqal\n        $three_class = new name_space\\namespace2\\third_class();\n        $three_class-\u003emethod_from_third_class();\n        \n        ?\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\u003cdiv align=\"center\"\u003e\n\n# Core Settings \u0026 Debug\n\n\u003c/div\u003e\n\n`autoload/core.config.php`\n\nIndexing of the found classes, default is `true`.\n```php\ndefine('MBT_CORE_AUTOLOAD_INDEX', true);\n```\n\nMaximum number of lines to read in a file, default is `49`.\n```php\ndefine('MBT_CORE_AUTOLOAD_READ_MAX_LINES', 49);\n```\n\nSet this to false so that you no longer see the debugging, default is `true`.\n```php\ndefine('MBT_DEBUG_DISPLAY_AUTOLOAD', true);\n```\n\nLook at which classes where were found, default is `true`.\n```php\ndefine('MBT_DEBUG_DISPLAY_AUTOLOAD_SEARCH', true);\n```\n\n\u003cdiv align=\"center\"\u003e\n\n# Root\n\n\u003c/div\u003e\n\nThe complete path is the directory path, that the autoloader get by self.\n\nDEFAULT: `MBT_DOCUMENT_ROOT`\n\nThe autoloader define get the web root by self after set `MBT_DOCUMENT_ROOT`\n```php\ndefine('MBT_DOCUMENT_ROOT', __DIR__);\n\ndefine('MBT_SERVER_ROOT', str_replace(MBT_DOCUMENT_ROOT, '', str_replace(filter_input(INPUT_SERVER, 'DOCUMENT_ROOT'), '', str_replace(\"\\\\\", \"/\", MBT_DOCUMENT_ROOT))));\ndefine('MBT_HTTP_ROOT', get_protocol() . get_host() . MBT_SERVER_ROOT);\n```\n\n\u003cdiv align=\"center\"\u003e\n\n# Loader methods\n\n\u003c/div\u003e\n\nThe autoloader finds everything yourself you do not have to do anything except write your class and instance and use.\n\nMethod | Namespace (with class) | Path | Load Time\n------------ | ------------ | ------------- | -------------\n1 | testclasses\\first_class | php-auto-autoloader/testclasses/first_class.php | 0.0 sec.\n2 | testclasses\\classes\\second_class | php-auto-autoloader/testclasses/classes/second.php | 0.002 sec.\n3 | name_space\\namespace2\\third_class | php-auto-autoloader/testclasses/classThree.php | 0.011 sec.\n\n## METHOD 1:\n\n\u003e This is the fastest way\n\nThat means we take the website root path and namespace as a folder path and the classname we put together with these.\n\n### Example\n\n**The instance:**\n`new testclasses\\first_class();`\n\nType | Sample | Description\n---- | ------ | ------\nPATH | `/project/sites/mywebsite/` | MBT_DOCUMENT_ROOT\nNAMESPACE | `testclasses` | Like the folder name\nCLASS | `first_class` | Like the file name without extension\nThen the result example | `/project/sites/mywebsite/testclasses/first_class.php` | \n\n## METHOD 2:\n\n\u003e This method is slightly slower than the first, so 0.03 - 0.05 seconds\n\nThis function namespace as folder path and force only this path for class `second_class` (Example) file.\nHowever, this only occurs when the file does not match the specified class name.\nThis means every file found in this folder is opened and searched for the classname. \nAs soon as the used class exists in a file, this is integrated and can use it.\n\n### Example\n\n**The instance:**\n`new testclasses\\classes\\second_class();`\n\nType | Sample | Description\n---- | ------ | ------\nPATH | `/project/sites/website/` | MBT_DOCUMENT_ROOT\nNAMESPACE | `testclasses\\classes` | Like the folder name\nThen the result example | `/project/sites/mywebsite/testclasses/classes/second_class.php` | \n\n## METHOD 3:\n\n\u003e This method is the slowest, but found class anything where\n\nThis method is the slowest, because it scans all your folders. \nNo matter how much files you have, all are opened, read and searched for the classname. \nThis method intervenes only when none of the other methods was successful. So if the namespace was not just a folder name and the class name was not filename.\n\n### Example\n\n**The instance:**\n`new testclasses\\classes\\third_class();`\n\nType | Sample | Description\n---- | ------ | ------\nPATH | `/project/sites/mywebsite/` | MBT_DOCUMENT_ROOT\nThen the result example | `/project/sites/mywebsite/testclasses/classThree.php` | \n\n\u003cdiv align=\"center\"\u003e\n\n# Information\n\n[tnado SEO \u0026 AMP CMS](https://www.tnado.com/), this autoloader is one of parts from Framework.\n\n# ISSUE\n\nPlease use the issue tab to request a:\n\n* Bug\n* Feature\n\nChoose template and report a bug or feature you want [issues](https://github.com/prod3v3loper/php-auto-autoloader/issues).\n\n# CONTRIBUTE\n\nPlease read the [contributing](https://github.com/prod3v3loper/php-auto-autoloader/blob/master/.github/CONTRIBUTING.md) to contribute.\n\n# VULNERABILITY\n\nPlease use the Security section for privately reporting a [vulnerability](https://github.com/prod3v3loper/php-auto-autoloader/security).\n\n# Authors\n\n**Samet Tarim** - *All works*\n\n# License\n\n[MIT](https://github.com/prod3v3loper/php-auto-autoloader/blob/master/LICENSE) - [prod3v3loper](https://www.prod3v3loper.com/)\n\n\u003c/div\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprod3v3loper%2Fphp-auto-autoloader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprod3v3loper%2Fphp-auto-autoloader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprod3v3loper%2Fphp-auto-autoloader/lists"}