{"id":13448082,"url":"https://github.com/tommcfarlin/simple-autoloader-for-wordpress","last_synced_at":"2025-09-29T20:30:50.003Z","repository":{"id":139745417,"uuid":"94999596","full_name":"tommcfarlin/simple-autoloader-for-wordpress","owner":"tommcfarlin","description":"An autoloader that aims to be as simple as dropping it into your WordPress project. All you need is a well-organized project.","archived":true,"fork":false,"pushed_at":"2017-11-07T21:11:31.000Z","size":16,"stargazers_count":89,"open_issues_count":2,"forks_count":14,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-09-27T14:40:53.895Z","etag":null,"topics":["autoloading","php","wordpress","wordpress-development"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tommcfarlin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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":"2017-06-21T12:05:03.000Z","updated_at":"2024-05-24T22:45:28.000Z","dependencies_parsed_at":"2023-04-21T17:30:26.046Z","dependency_job_id":null,"html_url":"https://github.com/tommcfarlin/simple-autoloader-for-wordpress","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tommcfarlin%2Fsimple-autoloader-for-wordpress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tommcfarlin%2Fsimple-autoloader-for-wordpress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tommcfarlin%2Fsimple-autoloader-for-wordpress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tommcfarlin%2Fsimple-autoloader-for-wordpress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tommcfarlin","download_url":"https://codeload.github.com/tommcfarlin/simple-autoloader-for-wordpress/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234659851,"owners_count":18867628,"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":["autoloading","php","wordpress","wordpress-development"],"created_at":"2024-07-31T05:01:35.088Z","updated_at":"2025-09-29T20:30:49.555Z","avatar_url":"https://github.com/tommcfarlin.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# Simple Autoloader for WordPress\n\nAn [autoloader](http://php.net/manual/en/language.oop5.autoload.php) that aims to be as simple as dropping it into your WordPress project. All you need is a well-organized project.\n\n## More Information\n\n**TL;DR:** An autoloader you can drop into a WordPress plugin and begin using it automagically.\n\nIn 2017, I gave a talk at WordCamp Atlanta about the importance of using \n[Namespaces and Autoloading](https://tommcfarlin.com/namespaces-and-autoloading-2017/) in WordPress.\n\nThough for many projects, we can't adopt many of the new features of PHP7+, that doesn't mean can't use \nbest practices when working on plugins and other projects.\n\nI have a _very_ simple autoloader that I'm sharing in this repository that I hope the greater (and smarter!) WordPress \ndevelopers at large will contribute to improving.\n\n## Getting Started\n\nThis particular section is for those who want to _use_ the autoloader. If you're looking to contribute to the codebase,\nplease see the section below.\n\n1. Clone or download this repository.\n2. Copy the `lib` directory into the root of your project.\n3. Add `include_once 'lib/autoload.php'` to your main plugin file.\n\n### An Example\n\nThis autoloader expects several things: \n\n1. You're following the [WordPress Coding Standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#naming-conventions) as it relates to naming your classes.\n2. The structure of your namespaces follows the structure of your directory structure\n\nI've provided an example below for how both your code and your directory should be organized to take advantage of the \nautoloader.\n \n### The Code\n\nLet's say you have a plugin and one of the files contains the following namespace:\n\n```php\nnamespace Pressware\\API;\n```\n\nAnd it's using a class in another namespace:\n\n```php\nuse Pressware\\Utility\\Files\\Reader;\n```\n\nThe autoloader expects that the root namespace defined in your main plugin file to be:\n\n```php\nnamespace Pressware\n```\n\n### The Directory Structure\n\nAnd that all of the rest of the files are located in a directory structure like this:\n```\n+ plugin-name\n|\n|   API\n|       ...\n|       ...\n|\n|   Utility\n|       ...\n|\n|   Files\n|       class-reader.php\n|       ...\n|\n|   plugin-bootstrap.php\n```\n\n### Adding The Autoloader\n\nThen, at the top of your plugin file add the following:\n\n`require_once 'lib/autoload.php';`\n\nThis can work alongside another other autoloaders (such as those that come with Composer) and will prevent you from \nneeding to add `require_once` or `include_once` all over the state of your application.\n\n## Other Information\n\nIf you're interested in contributing, reading more, and or following changes (all of which is welcome), please read \nbelow.\n\n* The project is licensed [GPL](LICENSE).\n* If you're interested in contributing, please read [this document](CONTRIBUTING.md).\n* See the [CHANGELOG](CHANGELOG.md) for a complete list of changes.\n\n\u003e [Oh yeah? Watch this!](https://www.youtube.com/watch?v=X-rkFaIPyL4) ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftommcfarlin%2Fsimple-autoloader-for-wordpress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftommcfarlin%2Fsimple-autoloader-for-wordpress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftommcfarlin%2Fsimple-autoloader-for-wordpress/lists"}