{"id":15345483,"url":"https://github.com/akrabat/rka-slim-controller","last_synced_at":"2025-04-15T02:36:53.807Z","repository":{"id":24621309,"uuid":"28030284","full_name":"akrabat/rka-slim-controller","owner":"akrabat","description":"Dynamically instantiated controller classes for Slim Framework 2","archived":false,"fork":false,"pushed_at":"2015-04-09T20:57:11.000Z","size":271,"stargazers_count":48,"open_issues_count":1,"forks_count":4,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-28T15:11:18.311Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akrabat.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":"2014-12-15T09:47:29.000Z","updated_at":"2024-01-17T15:49:28.000Z","dependencies_parsed_at":"2022-08-06T02:15:29.526Z","dependency_job_id":null,"html_url":"https://github.com/akrabat/rka-slim-controller","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akrabat%2Frka-slim-controller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akrabat%2Frka-slim-controller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akrabat%2Frka-slim-controller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akrabat%2Frka-slim-controller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akrabat","download_url":"https://codeload.github.com/akrabat/rka-slim-controller/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248703190,"owners_count":21148118,"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":"2024-10-01T11:13:36.245Z","updated_at":"2025-04-15T02:36:53.559Z","avatar_url":"https://github.com/akrabat.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RKA Slim Controller\n\nAn extension to [Slim Framework][1] that allows you use to dynamically\ninstantiated controllers with action methods wherever you would use a\nclosure when routing.\n\nThe controller can optionally be loaded from Slim's DI container,\nallowing you to inject dependencies as required.\n\n[1]: http://www.slimframework.com/\n\n## Installation\n\n    composer require akrabat/rka-slim-controller\n\n\n## Usage\n\nUse the string format `{controller class name}:{action method name}`\nwherever you would usually use a closure:\n\ne.g.\n\n    $app = new \\RKA\\Slim();\n    $app-\u003eget('/hello:name', 'App\\IndexController:home');\n\n\nYou can also register the controller with Slim's DI container:\n\n    $app = new \\RKA\\Slim();\n\n    $app-\u003econtainer-\u003esingleton('App\\IndexController', function ($container) {\n        // Retrieve any required dependencies from the container and\n        // inject into the constructor of the controller\n\n        return new \\App\\IndexController();\n    });\n\n    $app-\u003eget('/', 'App\\IndexController:index');\n\n\n## Controller class methods\n\n*RKA Slim Controller* will call the controller's `setApp()`, `setRequest()`\nand `setResponse()` methods if they exist and populate appropriately. It will\nthen call the controller's `init()`` method.\n\nHence, a typical controller may look like:\n\n    \u003c?php\n    namespace App;\n\n    class IndexController\n    {\n        // Optional properties\n        protected $app;\n        protected $request;\n        protected $response;\n\n        public function index()\n        {\n            echo \"This is the home page\";\n        }\n\n        public function hello($name)\n        {\n            echo \"Hello, $name\";\n        }\n\n        // Optional setters\n        public function setApp($app)\n        {\n            $this-\u003eapp = $app;\n        }\n\n        public function setRequest($request)\n        {\n            $this-\u003erequest = $request;\n        }\n\n        public function setResponse($response)\n        {\n            $this-\u003eresponse = $response;\n        }\n\n        // Init\n        public function init()\n        {\n            // do things now that app, request and response are set.\n        }\n    }\n\n\n## Example project\n\nLook at [slim-di](https://github.com/akrabat/slim-di).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakrabat%2Frka-slim-controller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakrabat%2Frka-slim-controller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakrabat%2Frka-slim-controller/lists"}