Draft documentation

Spent some time writing draft docs. Most interesting now is this one:

It is definitely not final. The purpose is to verify complexinty is not too much.

2 Likes

I liked it. Yii3 is definitely wired up differently than Yii1 or Yii2. The tutorial is a must.

Now in order to map our handler to URL we need to configure router.

From looking at this tutorial and browsing the demo code, I get the impression that there is no longer any “convention” for controller/action being a route by default. And that all routes must now be explicitely configured to their individual controller/action and params. Is this correct? Or are there some conventions that still work if a route has not been defined.

I am confused as to how the ‘say’ view gets wired in. I don’t see any reference to it. Is this done by convention? Is there a way to use an alternate view? Also I think it would help to mention where to put the view file.

I’ve started reading through what you have in the docs. Yii3 is really exciting!

In its current state — yes. We may introduce convention later.

Will fix that. Seems I forgot to put whole block there explaining how to get view up and running :slight_smile:

This ‘say’ is not IDE friendly. If we rename method name of controller class IDE can not make correct refractoring.

Depends on IDE but generally it is true. Any suggestions to make it better?

Currently, I see lambda as the only solution.

     $routes = [
            Route::get('/say/{message}')->to(fn($message) =>  (new SiteController($container))->say($message)),
        ];

Or Psr Request object as action parameter, but I think to have to get parameters as action params is better for maintainability. PsrRequest can come from $container. ActionCaller also integrated into “to” method and can be overloaded in the second param of the “to” method, otherwise, the default version will be requested from the container.

This way you’re losing automatic dependency injection.

Actually this approach is close to Laravel, so I believe all its features from Routing should be inherited.

We can have a Factory for creating controller. We can create a factory class for every controller if we want IDE support, or we can use generic Factory and get no IDE support.

There could be a class, route generator class. We just pass a list of controllers (explicit or like a path) and this class generator creates routes array.

1 Like

Yes. I’ll post configuration concept draft later this week.

Another way is to implement IDE plugins. Not sure if I will have time and passion to do that again, but I can help with some advises, because during Yii2 support development we faced some places where it was impossible to make a good solution. For example it is impossible to wire validators names with actual implementations.

In this particular case we need reference to method. The best way is to introduce framework wide principle, like it was with arrays=>objects into Yii2. For example Laravel use className@methodName syntax to refer to methods. To do this in IDE frendly way we need such construction “new MethodRef(MethodClass:class, “methodName”)”. this could be easily wired to class method.

Makes sense, yes.

// Configuration is taking more iterations so not posting it yet.