{"id":19039617,"url":"https://github.com/windwalker-io/windwalker-controller","last_synced_at":"2026-04-10T05:52:06.661Z","repository":{"id":20479611,"uuid":"23757537","full_name":"windwalker-io/windwalker-controller","owner":"windwalker-io","description":"[READ ONLY] Subtree split of Windwalker Framework","archived":false,"fork":false,"pushed_at":"2016-04-02T05:29:14.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-21T22:30:47.247Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/ventoviro/windwalker","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/windwalker-io.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":"2014-09-07T10:31:54.000Z","updated_at":"2024-12-16T13:50:17.000Z","dependencies_parsed_at":"2022-07-31T21:18:12.023Z","dependency_job_id":null,"html_url":"https://github.com/windwalker-io/windwalker-controller","commit_stats":null,"previous_names":["ventoviro/windwalker-controller"],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/windwalker-io/windwalker-controller","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windwalker-io%2Fwindwalker-controller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windwalker-io%2Fwindwalker-controller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windwalker-io%2Fwindwalker-controller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windwalker-io%2Fwindwalker-controller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/windwalker-io","download_url":"https://codeload.github.com/windwalker-io/windwalker-controller/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windwalker-io%2Fwindwalker-controller/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266127212,"owners_count":23880420,"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-11-08T22:17:55.438Z","updated_at":"2025-12-18T09:04:51.334Z","avatar_url":"https://github.com/windwalker-io.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Windwalker Controller\n\nThe Windwalker Controller package is a simple interface to control some business logic, id didn't dependency to any other packages.\n You may integrate it to any systems.\n\n## Installation via Composer\n\nAdd this to the require block in your `composer.json`.\n\n``` json\n{\n    \"require\": {\n        \"windwalker/controller\": \"~2.0\"\n    }\n}\n```\n\n## Create Your Controller\n\n``` php\nuse Windwalker\\Controller\\Controller;\n\nclass IndexController extends AbstractController\n{\n    public function execute()\n    {\n        return 'Index';\n    }\n}\n\n$controller = new IndexController;\n\n$output = $contorller-\u003eexecute();\n```\n\nWindwakler Controller is a \"Single Action Controller\", follows single responsibility principle,\nevery controller just maintain one task(action). It is inspired from [Joomla New MVC](http://magazine.joomla.org/issues/issue-nov-2013/item/1580-new-mvc-for-joomla-cms). You can create\n`IndexController`, `CreateController`, `UpdateController` and `DeleteController` for [CRUD](http://en.wikipedia.org/wiki/Create,_read,_update_and_delete).\n\n## Using Input and Application\n\nBy default, controller maintains an input and an application object. We can set it when construct:\n\n``` php\nuse Windwalker\\Controller\\Controller;\n\nclass IndexController extends AbstractController\n{\n    public function execute()\n    {\n        // Get params from http request\n        $method = $this-\u003einput-\u003eget('_method');\n\n        $this-\u003eapp-\u003eredirect('...');\n\n        return true;\n    }\n}\n\n$input = new Input;\n$app = new WebApplication;\n\n$controller = new IndexController($input, $app);\n\n$output = $contorller-\u003eexecute();\n```\n\nIt didn't dependency to Windwalker self, you can push other framework's input and application into it:\n\n``` php\n$input = new Request;\n$app = new HttpKernel;\n\n$controller = new IndexController($input, $app);\n\n$output = $contorller-\u003eexecute();\n```\n\n## HMVC\n\nUsing [HMVC](http://en.wikipedia.org/wiki/Hierarchical_model%E2%80%93view%E2%80%93controller) in Windwalker controller is very easy:\n\n``` php\nclass IndexController extends AbstractController\n{\n    public function execute()\n    {\n        $this-\u003einput-\u003eset('id', 123);\n\n        $foo = new FooController($this-\u003einput, $this-\u003eapp);\n\n        echo $foo-\u003eexecute();\n\n        return true;\n    }\n}\n```\n\n## Multi Action Controller\n\nIf you are familiar to common multiple action pattern, use `AbstractMultiActionController`:\n\n``` php\nuse Windwalker\\Controller\\AbstractMultiActionController;\n\nclass ArticleController extends AbstractMultiActionController\n{\n    public function indexAction()\n    {}\n\n    public function saveAction($id = null, $data = array())\n    {}\n\n    public function deleteAction($id = null)\n    {}\n}\n\n$controller = new ArticleController;\n\n// Will call saveAction()\n$controller-\u003esetActionName('save')\n    -\u003esetArguments(array(5, $data))\n    -\u003eexecute();\n```\n\nIf no action set, will call `doExecute()` instead, but you still need to override `doExecute()` first.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwindwalker-io%2Fwindwalker-controller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwindwalker-io%2Fwindwalker-controller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwindwalker-io%2Fwindwalker-controller/lists"}