{"id":26172025,"url":"https://github.com/oktopost/skeleton","last_synced_at":"2026-04-21T15:31:16.940Z","repository":{"id":57030781,"uuid":"52198795","full_name":"Oktopost/Skeleton","owner":"Oktopost","description":null,"archived":false,"fork":false,"pushed_at":"2023-06-04T07:48:20.000Z","size":232,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-08T04:20:03.127Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Oktopost.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}},"created_at":"2016-02-21T09:10:28.000Z","updated_at":"2022-05-08T11:34:45.000Z","dependencies_parsed_at":"2022-08-23T17:40:59.340Z","dependency_job_id":null,"html_url":"https://github.com/Oktopost/Skeleton","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Oktopost%2FSkeleton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Oktopost%2FSkeleton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Oktopost%2FSkeleton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Oktopost%2FSkeleton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Oktopost","download_url":"https://codeload.github.com/Oktopost/Skeleton/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243104176,"owners_count":20236943,"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-03-11T19:52:59.197Z","updated_at":"2025-12-07T15:02:22.821Z","avatar_url":"https://github.com/Oktopost.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/Oktopost/Skeleton.svg?branch=master)](https://travis-ci.org/Oktopost/Skeleton)\n\n# Skeleton\n\u003e Latest version 1.2.0\n\nSkeleton is an [Inversion of Control (IoC)](https://en.wikipedia.org/wiki/Inversion_of_control) Library for PHP 7.1 or higher.\n\n[![Build Status](https://travis-ci.org/Oktopost/Skeleton.svg?branch=master)](https://travis-ci.org/Oktopost/Skeleton)\n\n- [Simple example project](https://github.com/Oktopost/Example-Skeleton)\n\n\n## Installation\n\n```shell\ncomposer require oktopost/skeleton\n```\nor inside *composer.json*\n```json\n\"require\": {\n    \"oktopost/skeleton\": \"^1.0\"\n}\n```\n\n## Basic Usage Example:\n\n```php\n// src/Proj/Base/IUserDAO.php\ninterface IUserDAO\n{\n    public function load($id);\n}\n\n// src/Proj/DAO/UserDAO.php\nclass UserDAO implements IUserDAO\n{\n    public function load($id)\n    {\n        // ...\n    }\n}\n\n\n// skeleton-config.php\n$skeleton = new \\Skeleton\\Skeleton();\n$skeleton-\u003eset(Proj\\Base\\IUserDAO::class, Proj\\DAO\\UserDAO::class);\n// or\n$skeleton-\u003eset(\"Using any string as key\", Proj\\DAO\\UserDAO::class);\n\n\n// Obtaining a new instance using\n$service = $skeleton-\u003eget(Proj\\DAO\\IUserDAO::class);\n// or\n$service = $skeleton-\u003eget(\"Using any string as key\");\n```\n\nIn this case, **$service** will be set to a new instance of the **UserDAO** class that was created by Skeleton.\n\n## Autoloading class\n\nGiven the following setup:\n\n```php\n// src/Proj/Base/IUserDAO.php\ninterface IUserDAO {}\n\n// src/Proj/Base/IUserService.php\ninterface IUserService {}\n\n// src/Proj/DAO/UserDAO.php\nclass UserDAO implements IUserDAO {}\n\n\n// skeleton-config.php\n$skeleton = new \\Skeleton\\Skeleton();\n$skeleton-\u003eset(Proj\\Base\\IUserDAO::class,     Proj\\DAO\\UserDAO::class);\n$skeleton-\u003eset(Proj\\Base\\IUserService::class, Proj\\Service\\UserService::class);\n```\n\nInstance of **UserService** may be obtained *without* autoloading using:\n\n```php\n// src/Proj/Service/UserService.php\nclass UserService implements IUserService\n{\n    public function setUserDAO(IUserDAO $dao)\n    {\n    }\n}\n\n$instance = $skeleton-\u003eget(IUserService::class);\n$instance-\u003esetUserDAO($skeleton-\u003eget(IUserDAO::class));\n```\n\nBut with autoloading you can omit the call to setUserDAO using one of the following.\n\n### Using setter methods autolaoding\n\n```php\n// skeleton-config.php\n$skeleton-\u003eenableKnot();\n\n// src/Proj/Service/UserService.php\n/**\n * @autoload\n */\nclass UserService implements IUserService\n{\n    /**\n     * @autoload\n     * Method must start with the word \"set\", have only one parameter and the @autoload annotation.\n     * Private and protected methods will be also autoloaded.\n     */\n    public function setUserDAO(IUserDAO $dao)\n    {\n    }\n}\n\n// example.php\n$instance = $skeleton-\u003eget(IUserService::class);\n```\n\n### Using data member autoloading.\n\n```php\n// skeleton-config.php\n$skeleton-\u003eenableKnot();\n\n// src/Proj/Service/UserService.php\n/**\n * @autoload\n */\nclass UserService implements IUserService\n{\n    /**\n     * @autoload\n     * @var \\Full\\Path\\To\\IUserDAO\n     * Important: Full path must be defined under the @var annotation.\n     */\n    private $dao;\n}\n\n// example.php\n$instance = $skeleton-\u003eget(IUserService::class);\n```\n\n### Using \\__construct autoloading.\n\nIn this case the *autoload* annotation is not required for the class name nor for the \\__construct method.\n\n```php\n// skeleton-config.php\n$skeleton-\u003eenableKnot();\n\n// src/Proj/Service/UserService.php\nclass UserService implements IUserService\n{\n    public function __construct(IUserDAO $dao)\n    {\n    }\n}\n\n// example.php\n$instance = $skeleton-\u003eget(IUserService::class);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foktopost%2Fskeleton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foktopost%2Fskeleton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foktopost%2Fskeleton/lists"}