{"id":20103123,"url":"https://github.com/dotkernel/dot-controller","last_synced_at":"2025-10-27T09:19:38.416Z","repository":{"id":10905236,"uuid":"67436366","full_name":"dotkernel/dot-controller","owner":"dotkernel","description":"DotKernel controller like middleware component","archived":false,"fork":false,"pushed_at":"2025-02-28T05:51:40.000Z","size":375,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"4.0","last_synced_at":"2025-04-28T15:50:09.063Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://docs.dotkernel.org/dot-controller/","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/dotkernel.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-05T16:38:53.000Z","updated_at":"2025-02-28T05:46:56.000Z","dependencies_parsed_at":"2024-04-03T16:44:38.805Z","dependency_job_id":"3ee92dd8-25bd-410f-998a-8e0937291fb6","html_url":"https://github.com/dotkernel/dot-controller","commit_stats":{"total_commits":42,"total_committers":7,"mean_commits":6.0,"dds":"0.38095238095238093","last_synced_commit":"be04344b56964aaface8da3de4f27599917cdb81"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotkernel%2Fdot-controller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotkernel%2Fdot-controller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotkernel%2Fdot-controller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotkernel%2Fdot-controller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dotkernel","download_url":"https://codeload.github.com/dotkernel/dot-controller/tar.gz/refs/heads/4.0","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252648533,"owners_count":21782405,"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-13T17:34:21.596Z","updated_at":"2025-10-27T09:19:38.325Z","avatar_url":"https://github.com/dotkernel.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dot-controller\n\nThis is Dotkernel's controller package that can be use like middleware inside Dotkernel or Mezzio application.\nIt provides base classes for action based controllers similar to Laminas controller component.\nIt is more lightweight though, but supports controller plugins and event listeners.\n\n## Documentation\n\nDocumentation is available at: https://docs.dotkernel.org/dot-controller/.\n\n## Badges\n\n![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-controller)\n![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-controller/4.1.0)\n\n[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/issues)\n[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/network)\n[![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/stargazers)\n[![GitHub license](https://img.shields.io/github/license/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/blob/4.0/LICENSE.md)\n\n[![Build Static](https://github.com/dotkernel/dot-controller/actions/workflows/continuous-integration.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-controller/actions/workflows/continuous-integration.yml)\n[![codecov](https://codecov.io/gh/dotkernel/dot-controller/graph/badge.svg?token=VUBG5LM4CK)](https://codecov.io/gh/dotkernel/dot-controller)\n[![PHPStan](https://github.com/dotkernel/dot-controller/actions/workflows/static-analysis.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-controller/actions/workflows/static-analysis.yml)\n\n## Installation\n\nInstall `dot-controller` by executing the following Composer command:\n\n```shell\ncomposer require dotkernel/dot-controller\n```\n\n## Usage\n\nMiddleware controllers act as a handler for multiple routes. Some conventions were made:\n\n- register controllers in the routes array just like any mezzio middleware. The requirement is that you should define an `action` route parameter(possibly optional) anywhere inside the route(e.g `/user[/{action}]`)\n- action parameter value is converted to a method name inside the controller. Underscore, dot and line characters are removed and the action name is converted to camel-case suffixed by the string `Action`. For example a route and action pair like `/user/forgot-password` will be converted to method `forgotPasswordAction`.\n- the default action value, if not present in the URI is `index`, so you should always define an `indexAction` within your controllers for displaying a default page or redirecting.\n\nIn order to create your action based controllers, you must extend the abstract class `Dot\\Controller\\AbstractActionController`.\n\n### Example\n\nCreating a UserController with default action and a register action. Will handle routes `/user` and `/user/register`.\n\n```php\nuse Dot\\Controller\\AbstractActionController;\n\nclass UserController extends AbstractActionController\n{\n    public function indexAction()\n    {\n        //...\n    }\n    \n    public function registerAction()\n    {\n        //...\n    }\n}\n```\n\nThen register this controller as a routed middleware in file `RoutesDelegator.php` just like a regular middleware.\n\n```php\n//Example from a RoutesDelegator\n$app-\u003eroute(\n    '/user[/{action}]',\n    UserController::class,\n    [RequestMethodInterface::METHOD_GET, RequestMethodInterface::METHOD_POST],\n    'user'\n);\n```\n\n### Multiple controllers for the same route\n\n**Use case:**\nYou have defined a controller inside some package, with default actions.\nYou want to add actions that fall into the same controller name(or route name more exactly).\nYou want to do this without extending the controller provided by the package.\nIn this case you can do the following:\n\n- create your own controller, independent of the package's controller which adds more actions\n- Mezzio lets you define an array of middleware for a route, so you can register this controller before the package's controller\n\nNow when a request for this route comes in, your controller will run first.\nDotkernel controllers are designed to ignore requests that cannot be matched to one of its methods, so if no action matches, it will call the next middleware, in our case, the second controller.\nIf this is the last controller, and action does not match here, it will go to the default 404 Not found page(handled by NotFoundDelegate).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotkernel%2Fdot-controller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdotkernel%2Fdot-controller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotkernel%2Fdot-controller/lists"}