Difference between #42 and #43 of
Yii3 - How to start

Revision #43 has been created by rackycz rackycz on Apr 1, 2026, 2:24:58 PM with the memo:

invoke
« previous (#42) next (#44) »

Changes

Title unchanged

Yii3 - How to start

Category unchanged

Tutorials

Yii version unchanged

3.0

Tags unchanged

Content changed

[...]
- But you still can use method instead of invokation. For example in file `config/common/routes.php` you can use both:
- `->action(Web\HomePage\Action::class)` // \__invoke() needed
- `->action([Web\HomePage\Action::class, 'run'])`
- Invokable objects are often used for middleware as it fits naturally into dispatcher and pipeline systems. Middleware can then be stateful. But the same aplies to interface-based approaches, you only need to specify the method.

Summary:
 
 
Whenever a method requires a **callable** as the input parameter, you can supply "named function", "anonymous function" or  "invokable object". It is up to you what you pick.
 
 
 
## Hash annotations for class attributes
PHP 8 introduces annotations like this (not only for class attributes):

- `#[Column(type: 'primary')]`
- `#[Column(type: 'string(255)', nullable: true)]`
- `#[Entity(repository: UserRepository::class)]`
[...]
2 0
5 followers
Viewed: 61 393 times
Version: 3.0
Category: Tutorials
Tags:
Written by: rackycz rackycz
Last updated by: rackycz rackycz
Created on: Oct 8, 2025
Last updated: 7 days ago
Update Article

Revisions

View all history