Maravel Framework 10.63 avoids runtime reflection on DI
maravel-framework 10.63 improves the autowiring:cache command to include also constructors.
Why? Because runtime reflection is slow.
// config/app.php/**
* artisan autowiring:cache source paths for public methods (except __construct which is implicitly handled)
* The CallQueuedHandler, controllers, middlewares, bult-in commands, service providers
* + other classes resolved from Container during the autowiring:cache command execution are handled automatically
* 'path' can be a single class or a directory
*/
'autowiring' => [
[
'path' => \app()->path() . DIRECTORY_SEPARATOR . 'Console' . DIRECTORY_SEPARATOR . 'Commands',
'methods' => ['handle', '__invoke'],
],
[
'path' => \app()->path() . DIRECTORY_SEPARATOR . 'Jobs',
'methods' => ['handle', '__invoke'],
],
[
'path' => \app()->path() . DIRECTORY_SEPARATOR . 'Http' . DIRECTORY_SEPARATOR . 'Requests',
'methods' => ['validator', 'authorize', 'after', 'rules'],
],],
Benchmark for "Hello world" with optimizations (except Lumen):
Note:
Both Maravelith and Maravel templates can take advantage of this improvement.
If the concrete has contextual bindings (and constructor parameters) the old reflection is still used.
If the parameters are sent as array list, concrete will be instantiated directly with them. On failure, it will default to the old reflection but at the cost of building an Exception.
If the first parameters are sent as list and the last one(s) need to be auto-resolved, the above exception scenario will happen, which is slow. Always send all parameters as list, in the right order.
The method autowiring (so non __construct) does not support parameters as list!
