{"id":20085416,"url":"https://github.com/mkgor/commando","last_synced_at":"2025-07-10T00:02:21.223Z","repository":{"id":57041977,"uuid":"232998887","full_name":"mkgor/commando","owner":"mkgor","description":"Command patten implementation, Makes your application more flexible and expandable.","archived":false,"fork":false,"pushed_at":"2020-01-10T13:07:17.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-26T15:02:21.002Z","etag":null,"topics":["composer-package","patterns","php7"],"latest_commit_sha":null,"homepage":"","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/mkgor.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":"2020-01-10T08:15:45.000Z","updated_at":"2022-02-12T08:23:11.000Z","dependencies_parsed_at":"2022-08-24T00:50:45.801Z","dependency_job_id":null,"html_url":"https://github.com/mkgor/commando","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mkgor/commando","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkgor%2Fcommando","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkgor%2Fcommando/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkgor%2Fcommando/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkgor%2Fcommando/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mkgor","download_url":"https://codeload.github.com/mkgor/commando/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkgor%2Fcommando/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264505734,"owners_count":23618962,"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":["composer-package","patterns","php7"],"created_at":"2024-11-13T15:55:53.049Z","updated_at":"2025-07-10T00:02:21.179Z","avatar_url":"https://github.com/mkgor.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Commando\nCommando is a simple implementation of \\`Command\\` pattern. It gives you simple to make your application\nmore flexible and expandable.\n\n## Contents\n- [Requirments](https://github.com/pixaye/commando#requirments)\n- [Installation](https://github.com/pixaye/commando#installation)\n- [Usage](https://github.com/pixaye/commando#usage)\n\n## Requirments\nThe only requirement for now is a **PHP 7.1+**\n\n## Installation\nThe easiest way of installation is an installtion via composer:\n\n````\ncomposer require pixaye/commando\n````\n\n## Usage\n\nFirst of all, you should initialize and store **CommandBus** object\n\n````php\n\u003c?php\n\n$bus = new \\Commando\\Bus\\StandardCommandBus([\n    Commands\\SomeCommand::class =\u003e new Handlers\\SomeCommandHandler(),\n    Commands\\SomeAnotherCommand::class =\u003e new Handlers\\SomeAnotherCommandHandler()\n]);\n\n````\n\nThen, to dispatch command, you should create command object and call **dispatch** method of bus\n\n````php\n\u003c?php\n\n$bus = new \\Commando\\Bus\\StandardCommandBus([\n    Commands\\RegisterNewUserCommand::class =\u003e new Handlers\\RegisterNewUserCommandHandler(),\n]);\n\n//For example, we want to register new user\n$registeredUser = $bus-\u003edispatch(new Commands\\RegisterNewUserCommand('John Doe', '1234567890'));\n````\n\nCommand is a simple PHP class, which can contain some properties which handler should use to do some action.\n\n````php\n\u003c?php\n\nnamespace YourProject\\Commands;\n\nuse Commando\\Command\\CommandInterface;\n\nclass RegisterNewUserCommand implements CommandInterface\n{\n    private $fullName;\n    \n    private $password;\n\n    /**\n     * @return mixed\n     */\n    public function getFullName()\n    {\n        return $this-\u003efullName;\n    }\n\n    /**\n     * @param mixed $fullName\n     */\n    public function setFullName($fullName)\n    {\n        $this-\u003efullName = $fullName;\n    }\n\n    /**\n     * @return mixed\n     */\n    public function getPassword()\n    {\n        return $this-\u003epassword;\n    }\n\n    /**\n     * @param mixed $password\n     */\n    public function setPassword($password)\n    {\n        $this-\u003epassword = $password;\n    }\n}\n````\n\nIt will call **RegisterNewUserCommandHandler**'s handle method and return it\n\n**Important!** - All handlers should implement Commando\\Handler\\HandlerInterface and every command should implement Commando\\Command\\CommandInterface\n\n````php\n\u003c?php\n\nnamespace YourProject\\Handlers;\n\nuse Commando\\Handler\\HandlerInterface;\n\nclass RegisterNewUserCommandHandler implements HandlerInterface\n{\n    /**\n     * @param RegisterNewUserCommand $command\n     * @return string\n     */\n    public function handle($command)\n    {\n        return 'User with name  ' . $command-\u003egetFullName() . ' and password = ' . $command-\u003egetPassword() . ' has been created';\n    }\n}\n````\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkgor%2Fcommando","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmkgor%2Fcommando","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkgor%2Fcommando/lists"}