{"id":21874720,"url":"https://github.com/gustavonecore/hexgen","last_synced_at":"2025-03-21T23:21:47.895Z","repository":{"id":94470437,"uuid":"115750336","full_name":"gustavonecore/hexgen","owner":"gustavonecore","description":"Command and handler generator for hexagonal approach","archived":false,"fork":false,"pushed_at":"2017-12-29T20:27:30.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-26T17:43:44.109Z","etag":null,"topics":["cli","command-handler","command-line","hexagonal-architecture","php","php7"],"latest_commit_sha":null,"homepage":null,"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/gustavonecore.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-29T19:56:42.000Z","updated_at":"2022-02-12T14:37:00.000Z","dependencies_parsed_at":"2023-05-14T08:00:42.935Z","dependency_job_id":null,"html_url":"https://github.com/gustavonecore/hexgen","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gustavonecore%2Fhexgen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gustavonecore%2Fhexgen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gustavonecore%2Fhexgen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gustavonecore%2Fhexgen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gustavonecore","download_url":"https://codeload.github.com/gustavonecore/hexgen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244881289,"owners_count":20525623,"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":["cli","command-handler","command-line","hexagonal-architecture","php","php7"],"created_at":"2024-11-28T07:13:09.443Z","updated_at":"2025-03-21T23:21:47.876Z","avatar_url":"https://github.com/gustavonecore.png","language":"PHP","readme":"Hexgen Command \u0026 Handler generator\n===============\nThis is a library to generate command and handlers for an hexagonal architecture approach\n\n### Requirements\n\n- PHP \u003e= v7.0\n\n### Install it with composer\n\n- Execute composer `php composer.phar install`.\n\n- Create your local config `cp config/base.php config/local.php`\n\n### Options\n  - `command_namespace` (**Required**) Namespace for the created commands\n  - `handler_namespace` (**Required**)Namespace for the created handlers\n  - `command_interface_namespace` (**Required**) Namespace of the command interface (needed)\n  - `handler_interface_namespace` (**Required**) Namespace of the handler interface (needed)\n  - `output` (**Required**) Folder to put your beautiful generated files\n  - `dependencies` This is an array used to map your existing services using any PSR container with aliases support.\n\n### Example of usage\n\nIf you want to create a new command and handler, just run the index script with some options like:\n\n**CreateGoose command \u0026 handler**\n`php src/index.php --name=Goose\\\\CreateGoose --arguments=name,dob --services=database,guzzle,jwt`\n\n**Notice** how the script is using the services to inject those into the handlers like:\n\n***Injected services***\n`use mef\\Sql\\Driver\\SqlDriver;`\n`use GuzzleHttp\\Client;`\n`use Firebase\\JWT\\JWT;`\n\nThis dependencies are defined in the config file:\n\n\t'dependencies' =\u003e [\n\t\t'guzzle' =\u003e 'GuzzleHttp\\\\Client',\n\t\t'database' =\u003e 'mef\\\\Sql\\\\Driver\\\\SqlDriver',\n\t\t'jwt' =\u003e 'Firebase\\\\JWT\\\\JWT',\n\t],\n\nThis will create the **Goose** folder inside `output/commands` and `output/handlers` folders, and here will be placed the new command and handler.\n\n**Command**\n\n    \u003c?php namespace Goose\\App\\Command\\Goose;\n    \n    use Goose\\App\\Command\\CommandInterface;\n    \n    /**\n     * Command for CreateGoose\n     */\n    class CreateGooseCommand implements CommandInterface\n    {\n    \t/**\n    \t* @var string Name\n    \t*/\n    \tprotected $name;\n    \n    \t/**\n    \t* @var string Dob\n    \t*/\n    \tprotected $dob;\n    \n    \t/**\n    \t * Create the command\n    \t *\n    \t * @param string $name\n    \t * @param string $dob\n    \t */\n    \tpublic function __construct(string $name, string $dob)\n    \t{\n    \t\t$this-\u003ename = $name;\n    \t\t$this-\u003edob = $dob;\n    \t}\n    \n    \t/**\n    \t * @return string\n    \t */\n    \tpublic function getName() : string\n    \t{\n    \t\treturn $this-\u003ename;\n    \t}\n    \t/**\n    \t * @return string\n    \t */\n    \tpublic function getDob() : string\n    \t{\n    \t\treturn $this-\u003edob;\n    \t}\n    }\n\n\n**Handler**\n\n    \u003c?php namespace Goose\\App\\Handler\\Goose;\n    \n    use Goose\\App\\Handler\\HandlerInterface;\n    use Goose\\App\\Command\\Goose\\CreateGooseCommand;\n    use mef\\Sql\\Driver\\SqlDriver;\n    use GuzzleHttp\\Client;\n    use Firebase\\JWT\\JWT;\n    \n    /**\n     * Handle the CreateGoose command\n     */\n    class CreateGooseHandler implements HandlerInterface\n    {\n    \t/**\n    \t* @var \\mef\\Sql\\Driver\\SqlDriver\n    \t*/\n    \tprotected $database;\n    \n    \t/**\n    \t* @var \\GuzzleHttp\\Client\n    \t*/\n    \tprotected $guzzle;\n    \n    \t/**\n    \t* @var \\Firebase\\JWT\\JWT\n    \t*/\n    \tprotected $jwt;\n    \n    \t/**\n    \t * Create the command\n    \t *\n    \t * @param \\mef\\Sql\\Driver\\SqlDriver $database\n    \t * @param \\GuzzleHttp\\Client $guzzle\n    \t * @param \\Firebase\\JWT\\JWT $jwt\n    \t */\n    \tpublic function __construct(SqlDriver $database, Client $guzzle, JWT $jwt)\n    \t{\n    \t\t$this-\u003edatabase = $database;\n    \t\t$this-\u003eguzzle = $guzzle;\n    \t\t$this-\u003ejwt = $jwt;\n    \t}\n    \n    \t/**\n    \t * Handle command\n    \t */\n    \tpublic function handle(CreateGooseCommand $command)\n    \t{\n    \t\treturn [];\n    \t}\n    }\n\nOutput\n\n- Command `output/commands/Goose/CreateGooseCommand.php`\n- Handler `output/commands/Goose/CreateGooseHandler.php`\n\n\n### TODO\n\n 1. Decouple the script in **beautiful** classes\n 2. Allow to the user define the type of data for the command arguments\n 3. Add aliases for service names\n 4. Add a new `--crud` option to generate a new **CRUD** for any new context, like: `CreateThing, UpdateThing, DeleteThing, SearchThing`.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgustavonecore%2Fhexgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgustavonecore%2Fhexgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgustavonecore%2Fhexgen/lists"}