{"action":"created","issue":{"url":"https://api.github.com/repos/johnbillion/extended-cpts/issues/35","repository_url":"https://api.github.com/repos/johnbillion/extended-cpts","labels_url":"https://api.github.com/repos/johnbillion/extended-cpts/issues/35/labels{/name}","comments_url":"https://api.github.com/repos/johnbillion/extended-cpts/issues/35/comments","events_url":"https://api.github.com/repos/johnbillion/extended-cpts/issues/35/events","html_url":"https://github.com/johnbillion/extended-cpts/issues/35","id":123156646,"number":35,"title":"Autoload?","user":{"login":"ekandreas","id":1794603,"avatar_url":"https://avatars.githubusercontent.com/u/1794603?v=3","gravatar_id":"","url":"https://api.github.com/users/ekandreas","html_url":"https://github.com/ekandreas","followers_url":"https://api.github.com/users/ekandreas/followers","following_url":"https://api.github.com/users/ekandreas/following{/other_user}","gists_url":"https://api.github.com/users/ekandreas/gists{/gist_id}","starred_url":"https://api.github.com/users/ekandreas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ekandreas/subscriptions","organizations_url":"https://api.github.com/users/ekandreas/orgs","repos_url":"https://api.github.com/users/ekandreas/repos","events_url":"https://api.github.com/users/ekandreas/events{/privacy}","received_events_url":"https://api.github.com/users/ekandreas/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/johnbillion/extended-cpts/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/johnbillion/extended-cpts/milestones/10","html_url":"https://github.com/johnbillion/extended-cpts/milestones/3.0.3","labels_url":"https://api.github.com/repos/johnbillion/extended-cpts/milestones/10/labels","id":1596024,"number":10,"title":"3.0.3","description":"","creator":{"login":"johnbillion","id":208434,"avatar_url":"https://avatars.githubusercontent.com/u/208434?v=3","gravatar_id":"","url":"https://api.github.com/users/johnbillion","html_url":"https://github.com/johnbillion","followers_url":"https://api.github.com/users/johnbillion/followers","following_url":"https://api.github.com/users/johnbillion/following{/other_user}","gists_url":"https://api.github.com/users/johnbillion/gists{/gist_id}","starred_url":"https://api.github.com/users/johnbillion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnbillion/subscriptions","organizations_url":"https://api.github.com/users/johnbillion/orgs","repos_url":"https://api.github.com/users/johnbillion/repos","events_url":"https://api.github.com/users/johnbillion/events{/privacy}","received_events_url":"https://api.github.com/users/johnbillion/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":0,"state":"open","created_at":"2016-02-22T00:32:01Z","updated_at":"2016-02-22T00:32:22Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2015-12-20T12:04:37Z","updated_at":"2016-04-05T18:27:33Z","closed_at":null,"body":"Hi!\r\nThanks for a more cleaner version of extended-cpts!\r\nI miss an autoload to the library as I use the package via Packagist in a WP Roots Bedrock installation.\r\nOr do you have any example to load the lib when going via Composer?"},"comment":{"url":"https://api.github.com/repos/johnbillion/extended-cpts/issues/comments/205932633","html_url":"https://github.com/johnbillion/extended-cpts/issues/35#issuecomment-205932633","issue_url":"https://api.github.com/repos/johnbillion/extended-cpts/issues/35","id":205932633,"user":{"login":"aaemnnosttv","id":1621608,"avatar_url":"https://avatars.githubusercontent.com/u/1621608?v=3","gravatar_id":"","url":"https://api.github.com/users/aaemnnosttv","html_url":"https://github.com/aaemnnosttv","followers_url":"https://api.github.com/users/aaemnnosttv/followers","following_url":"https://api.github.com/users/aaemnnosttv/following{/other_user}","gists_url":"https://api.github.com/users/aaemnnosttv/gists{/gist_id}","starred_url":"https://api.github.com/users/aaemnnosttv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaemnnosttv/subscriptions","organizations_url":"https://api.github.com/users/aaemnnosttv/orgs","repos_url":"https://api.github.com/users/aaemnnosttv/repos","events_url":"https://api.github.com/users/aaemnnosttv/events{/privacy}","received_events_url":"https://api.github.com/users/aaemnnosttv/received_events","type":"User","site_admin":false},"created_at":"2016-04-05T18:27:33Z","updated_at":"2016-04-05T18:27:33Z","body":"This is how I currently handle this in my Bedrock `composer.json`\r\n```\r\n\"autoload\": {\r\n    \"classmap\": [\"vendor/johnbillion\"]\r\n  },\r\n```\r\nThen, believe it or not, you can autoload the library as simple as this:\r\n```php\r\nclass_exists('Extended_CPT', true);\r\n```\r\nThat could also be part of a conditional to bail if the class did not exist, but it does the job since the class and the files live together.\r\n\r\nI generally find that using the `files` key in the autoloader is best to be avoided when possible, because of the load timing.  The oscarotero/env library handles this well I think by using a static method on the main class for loading the functions to [expose the global functions](https://github.com/oscarotero/env#the-env-function).  This lets you use the optimal deferred class loading and only bring in the functions when needed - at the right time.\r\n\r\n@ekandreas @vinkla"}}