Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute routes example #579

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

Attribute routes example #579

wants to merge 5 commits into from

Conversation

xepozz
Copy link
Member

@xepozz xepozz commented Mar 27, 2023

image

image

image

In development I just run the worker in console php watcher.php and it rebuild the attributes map as fast as possible:
image

Related: yiisoft/router#194

@what-the-diff
Copy link

what-the-diff bot commented Mar 27, 2023

PR Summary

  • 🔧 Code Formatting Improvement
    Adjusted formatting in the application.php file
  • 📚 Documentation Update
    Added @OA\Schema reference for better API documentation
  • 🏗️ New Watcher Build Scripts
    Implemented watcher-build.php and watcher.php
  • 🛣️ Route Configuration Enhancement
    Changed route creation in config/common/routes/routes.php to use attributes
  • 🏷️ Attribute Annotations Added
    Included attribute annotations for SiteController, ApiUserController, and Actions\ApiInfo classes

@samdark
Copy link
Member

samdark commented Mar 28, 2023

Nice. That should at least go into cookbook.

->onAnyChange(function (string $type, string $path) {
echo sprintf('File changed: "%s".', $path) . PHP_EOL;
echo 'Run watcher-build...' . PHP_EOL;
`php watcher-build.php`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it disabled by default?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabled what?

@@ -36,11 +37,22 @@
use Yiisoft\Yii\RateLimiter\LimitRequestsMiddleware;
use Yiisoft\Yii\RateLimiter\Storage\StorageInterface;

$routes = [];
foreach (Attributes::findTargetMethods(Route::class) as $method) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about classes and groups?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just an example. If we want to merge it I'll migrate all routes and add groups and classes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants