{"id":23968999,"url":"https://github.com/joequery/composerpsr4example","last_synced_at":"2025-04-13T16:23:03.873Z","repository":{"id":139510492,"uuid":"45020142","full_name":"joequery/ComposerPSR4Example","owner":"joequery","description":"A basic example of PSR-4 Autoloading with Composer","archived":false,"fork":false,"pushed_at":"2015-10-27T06:08:21.000Z","size":360,"stargazers_count":11,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T07:21:17.619Z","etag":null,"topics":[],"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/joequery.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}},"created_at":"2015-10-27T05:57:25.000Z","updated_at":"2023-01-30T01:58:48.000Z","dependencies_parsed_at":"2023-03-13T14:42:49.932Z","dependency_job_id":null,"html_url":"https://github.com/joequery/ComposerPSR4Example","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/joequery%2FComposerPSR4Example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joequery%2FComposerPSR4Example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joequery%2FComposerPSR4Example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joequery%2FComposerPSR4Example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joequery","download_url":"https://codeload.github.com/joequery/ComposerPSR4Example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248742005,"owners_count":21154425,"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":[],"created_at":"2025-01-07T00:57:34.306Z","updated_at":"2025-04-13T16:23:03.856Z","avatar_url":"https://github.com/joequery.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Composer PSR-4 Example\n======================\n\nWhen attempting to learn how to use namespaces in PHP combined with Composer's\nPSR-4 autoloading spec, I couldn't find a solid working example. I understood\nthe theory of autoloading, I understood why Namespaces were good - I just wanted\na working template so I could start coding.\n\nWell, I couldn't find one, so I'm making one.\n\nUsage\n-----\n\nInstall the dependencies (currently only phpunit)\n\n    $ php composer.phar install\n\nRun the unit test to verify everything works correctly\n\n    ~$ ./vendor/bin/phpunit tests/\n\nYou should see the following output\n\n    PHPUnit 4.8.16 by Sebastian Bergmann and contributors.\n\n    .\n\n    Time: 41 ms, Memory: 3.75Mb\n\n    OK (1 test, 1 assertion)\n\n\nHow to use namespaces with Composer\n-----------------------------------\n\nSuppose you want to create a namespace named `MyNameSpace`\n\n1. Map `MyNameSpace` to a base directory via the composer.json file\n2. Within the base directory for the namespace, create a php file named `MyClass.php`\n3. Inside `MyClass.php`, declare the namespace `MyNameSpace`\n4. Inside `MyClass.php`, ensure the class `MyClass` has been defined, and that\n   it matches the php file name exactly\n5. Files that wish to use `MyClass` can now access it via `use\n   MyNameSpace\\MyClass`.\n\nAdding/editing namespaces\n-------------------------\n\nAny time you update composer.json with new namespace information, you must run\nan update.\n\n    $ php composer.phar update\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoequery%2Fcomposerpsr4example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoequery%2Fcomposerpsr4example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoequery%2Fcomposerpsr4example/lists"}