{"id":22123498,"url":"https://github.com/proai/lumen-annotations","last_synced_at":"2025-07-25T15:31:23.219Z","repository":{"id":62530821,"uuid":"46868183","full_name":"ProAI/lumen-annotations","owner":"ProAI","description":":bookmark_tabs: Laravel Lumen 5 route and event binding annotations","archived":false,"fork":false,"pushed_at":"2019-11-22T00:38:22.000Z","size":42,"stargazers_count":10,"open_issues_count":3,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-07T06:20:37.254Z","etag":null,"topics":["annotations","laravel-lumen","php"],"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/ProAI.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":"2015-11-25T14:57:21.000Z","updated_at":"2024-07-09T09:49:16.000Z","dependencies_parsed_at":"2022-11-02T15:32:02.133Z","dependency_job_id":null,"html_url":"https://github.com/ProAI/lumen-annotations","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProAI%2Flumen-annotations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProAI%2Flumen-annotations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProAI%2Flumen-annotations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProAI%2Flumen-annotations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ProAI","download_url":"https://codeload.github.com/ProAI/lumen-annotations/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227586817,"owners_count":17790102,"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":["annotations","laravel-lumen","php"],"created_at":"2024-12-01T15:33:57.142Z","updated_at":"2024-12-01T15:33:57.820Z","avatar_url":"https://github.com/ProAI.png","language":"PHP","readme":"# Lumen Annotations\n\n[![Latest Stable Version](https://poser.pugx.org/proai/lumen-annotations/v/stable)](https://packagist.org/packages/proai/lumen-annotations) [![Total Downloads](https://poser.pugx.org/proai/lumen-annotations/downloads)](https://packagist.org/packages/proai/lumen-annotations) [![Latest Unstable Version](https://poser.pugx.org/proai/lumen-annotations/v/unstable)](https://packagist.org/packages/proai/lumen-annotations) [![License](https://poser.pugx.org/proai/lumen-annotations/license)](https://packagist.org/packages/proai/lumen-annotations)\n\nThis package enables annotations in Laravel Lumen to define routes and event bindings.\n\n## Installation\n\nLumen Annotations is distributed as a composer package. So you first have to add the package to your `composer.json` file:\n\n```\n\"proai/lumen-annotations\": \"~1.0\"\n```\n\nThen you have to run `composer update` to install the package. Once this is completed, you have to add the service provider in `bootstrap/app.php`:\n\n```\n$app-\u003eregister(ProAI\\Annotations\\AnnotationsServiceProvider::class);\n```\n\nCopy `config/annotations.php` from this package to your configuration directory to use a custom configuration file.\n\n##### Include generated routes\n\nOnce you have run `php artisan route:scan` (see below), you have to include the generated `routes.php` file in your `bootstrap/app.php` file:\n\n```php\nrequire __DIR__.'/../storage/framework/routes.php';\n```\n\n##### Include generated event bindings\n\nAfter you have executed `php artisan event:scan` (see below), you have to add the service provider to the providers array in `config/app.php`:\n\n```\n'ProAI\\Annotations\\EventServiceProvider'\n```\n\n## Usage\n\nBy using annotations you can define your routes directly in your controller classes and your event bindings directly in your event handlers (see examples for usage of annotations).\n\n##### Class Annotations\n\nFor routes:\n\nAnnotation | Description\n--- | ---\n`@Controller` | This annotation must be set to indicate that the class is a controller class. Optional parameters `prefix` and `middleware`.\n`@Resource` | First parameter is resource name. Optional parameters `only` and `except`.\n`@Middleware` | First parameter is middleware name.\n\nFor events:\n\nAnnotation | Description\n--- | ---\n`@Hears` | This annotation binds an event handler class to an event.\n\n##### Method Annotations\n\nFor routes:\n\nAnnotation | Description\n--- | ---\n`@Get`,\u003cbr\u003e`@Post`,\u003cbr\u003e`@Options`,\u003cbr\u003e`@Put`,\u003cbr\u003e`@Patch`,\u003cbr\u003e`@Delete`,\u003cbr\u003e`@Any` | First parameter is route url. Optional parameters `as` and `middleware`.\n`@Middleware` | First parameter is middleware name.\n\n### Commands\n\nAfter you have defined the routes and event bindings via annotations, you have to run the scan command:\n\n* Use `php artisan route:scan` to register all routes.\n* Use `php artisan route:clear` to clear the registered routes.\n* Use `php artisan event:scan` to register all event bindings.\n* Use `php artisan event:clear` to clear the registered events.\n\n### Examples\n\n##### Example #1\n\n```php\n\u003c?php\n\nnamespace App\\Http\\Controllers;\n\nuse ProAI\\Annotations\\Annotations as Route;\n\n/**\n * Class annotation for UserController (belongs to all class methods).\n *\n * @Route\\Controller(prefix=\"admin\")\n */\nclass UserController\n{\n    /**\n     * Method annotations for showProfile() method.\n     *\n     * @Route\\Get(\"/profiles/{id}\", as=\"profiles.show\")\n     * @Route\\Middleware(\"auth\")\n     */\n    public function showProfile()\n    {\n      return view('profile');\n    }\n\n}\n```\n\n##### Example #2\n\n```php\n\u003c?php\n\nnamespace App\\Http\\Controllers;\n\nuse ProAI\\Annotations\\Annotations as Route;\n\n/**\n * Class annotations for resource controller CommentController (belongs to all class methods).\n *\n * @Route\\Controller\n * @Route\\Resource(\"comments\", only={\"create\", \"index\", \"show\"})\n * @Route\\Middleware(\"auth\")\n */\nclass CommentController\n{\n    ...\n}\n```\n\n##### Example #3\n\n```php\n\u003c?php\n\nnamespace App\\Handlers\\Events;\n\nuse ProAI\\Annotations\\Annotations\\Hears;\n\n/**\n * Annotation for event binding.\n *\n * @Hears(\"UserWasRegistered\")\n */\nclass SendWelcomeMail\n{\n    ...\n}\n```\n\n## Support\n\nBugs and feature requests are tracked on [GitHub](https://github.com/proai/lumen-annotations/issues).\n\n## License\n\nThis package is released under the [MIT License](LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fproai%2Flumen-annotations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fproai%2Flumen-annotations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fproai%2Flumen-annotations/lists"}