{"id":36988898,"url":"https://github.com/elbakerino/console-di-annotations","last_synced_at":"2026-01-13T23:27:41.580Z","repository":{"id":56976272,"uuid":"225214087","full_name":"elbakerino/console-di-annotations","owner":"elbakerino","description":"PHP Console App: auto-config skeleton with Dependency Injection, Annotations.","archived":true,"fork":false,"pushed_at":"2021-01-01T15:55:30.000Z","size":27,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-04T19:24:40.881Z","etag":null,"topics":["php","php-annotation","php-cli","php-console","php-di","php-skeleton"],"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/elbakerino.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":"2019-12-01T19:06:38.000Z","updated_at":"2023-01-21T14:33:02.000Z","dependencies_parsed_at":"2022-08-21T07:40:34.161Z","dependency_job_id":null,"html_url":"https://github.com/elbakerino/console-di-annotations","commit_stats":null,"previous_names":[],"tags_count":1,"template":true,"template_full_name":null,"purl":"pkg:github/elbakerino/console-di-annotations","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elbakerino%2Fconsole-di-annotations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elbakerino%2Fconsole-di-annotations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elbakerino%2Fconsole-di-annotations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elbakerino%2Fconsole-di-annotations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elbakerino","download_url":"https://codeload.github.com/elbakerino/console-di-annotations/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elbakerino%2Fconsole-di-annotations/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28405131,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["php","php-annotation","php-cli","php-console","php-di","php-skeleton"],"created_at":"2026-01-13T23:27:41.047Z","updated_at":"2026-01-13T23:27:41.566Z","avatar_url":"https://github.com/elbakerino.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Console with DI and Annotations\n\nBuild PHP Console applications with Dependency Injection and Annotations.\n\nSetup app skeleton and install dependencies with [composer](https://getcomposer.org/):\n\n    composer create-project elbakerino/console\n    \nThat's it - ready to code!\n\n**Run demo commands:**    \n\n    # get help\n    php cli -h\n\n    # how to access operands, see `Commands\\Demo-\u003ehandle`    \n    php cli demo\n    php cli demo World\n    php cli demo:welcome\n    php cli demo:bye\n    \nFor [Docker](https://www.docker.com/), download repository and spin up services:\n    \n    git clone https://github.com/elbakerino/console-di-annotations.git\n    \n    docker-compose up\n    \n    # open second terminal:\n    # open `bash` in docker service `app` with user `www-data`\n    docker-compose exec -u www-data app bash\n    composer install\n\n## Command Setup\n\nAt [_commands.php](_commands.php) demo [GetOpt-PHP](http://getopt-php.github.io/getopt-php/commands.html) commands are registered with inline documentation.\n\nHere also the commands are registered for found annotations.\n\nFor only manual command, it's as short as:\n\n```php\n\u003c?php\nreturn static function(GetOpt\\GetOpt $get_opt) {\n    // already dependency injected!\n\n    $get_opt-\u003eaddCommand(new GetOpt\\Command('demo', [Commands\\Demo::class, 'handle']));\n    //                   new GetOpt\\Command(\u003cname\u003e,  \u003chandler\u003e,                     \u003coptions\u003e[optional])\n};\n```\n\nYou can register commands with annotations, like the demo commands *(todo: annotation command docs)*.\n\nSee [Commands\\Demo](Commands/Demo.php) for a demo `class` command handler, any `callable`/`resolvable` is possible as command handler.\n\nSee [Commands\\DemoMultiple](Commands/DemoMultiple.php) for a demo `class` command handler which uses annotations at method level, not class level.\n\nSchematic use of defined commands:\n\n    php cli \u003cname\u003e \u003c..operand\u003e \u003c..-a=opt\u003e\n    \n## More Details\n    \nIn [launch.php](launch.php) the whole setup and auto-config is done, see inline-comments for details.\n\nIn [_definitions.php](_definitions.php) you can define/overwrite service definitions for PHP-DI.\n\nSee [Lib\\ConsoleApp](Lib/ConsoleApp.php) for the execution of GetOpt, use as base to switch to another console framework.\n\nSee [Annotations](Annotations) for example annotations, further docs on annotation will follow / can be found below in the libraries links.\n\nConfigure Docker in [docker-compose.yml](docker-compose.yml). Simply change PHP version, image base and add other PHP extensions in [Dockerfile](Dockerfile), rebuild image with `docker-compose up --build`. When changing [docker-opcache.ini](docker-opcache.ini) or [docker-vhost.conf](docker-vhost.conf) a rebuild is needed.\n\nFor further details see:\n\n- [GetOpt-PHP Commands](http://getopt-php.github.io/getopt-php/commands.html)\n- [PHP-DI](http://php-di.org)\n- [Orbiter\\AnnotationsUtil](https://packagist.org/packages/orbiter/annotations-util) \n    - uses [Doctrine\\Annotations](https://www.doctrine-project.org/projects/annotations.html)\n    - doctrine setup helper utility\n    - with cached reflections\n    - with caching static code analyzer for e.g. getting class names by directory (needed for auto-config)\n    \nInstall any other dependency for your project from [packagist](https://packagist.org/).\n\n## Todos\n\nThere is not really more needed, you can write simple and efficient console apps.\n\nSome nice to haves would be:\n\n- [ ] print line, print success, print error helper functions\n- [ ] print in color helper functions\n- [ ] input handling helper functions\n- [ ] some middleware pipelines around commands\n    - [ ] time and performance middleware \n- [ ] logging with PSR logger (monolog) by default \n\n### Downloads\n\n- See [Composer Package](https://packagist.org/packages/elbakerino/console).\n- Repository `git clone https://github.com/elbakerino/console-di-annotations.git`\n    \n## License\n\nThis project is free software distributed under the **MIT License**.\n\nSee: [LICENSE](LICENSE).\n\n### Contributors\n\nBy committing your code to the code repository you agree to release the code under the MIT License attached to the repository.\n\n***\n\nAuthor: [Michael Becker](https://mlbr.xyz)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felbakerino%2Fconsole-di-annotations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felbakerino%2Fconsole-di-annotations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felbakerino%2Fconsole-di-annotations/lists"}