Maravel Framework 10.60.0
marius-ciclistu

marius-ciclistu @marius-ciclistu

About: Creator of MaravelQL Definer of Equivalent constant engine torque Creator of maravel-rest-wizard / laravel-crud-wizard-free lib suites Creator of Maravel-Framework Maravel Maravelith

Location:
Romania
Joined:
Nov 17, 2025

Maravel Framework 10.60.0

Publish Date: Feb 3
0 0

Maravel Framework 10.60.0 avoid run-time reflection on method auto-wire to speed up the boot process


Maravel Framework 10.60.0

After multiple months in which I sought to reduce the reflection usage at run-time in Maravel Framework for improving its boot time , I came up with this POC which introduces 2 new commands, usable in both Maravel Micro-Framework and Maravelith Template:

php artisan autowiring:cache
php artisan autowiring:clear
Enter fullscreen mode Exit fullscreen mode

By default it will precompile at deploy time the method’s definitions from the registered Service Providers (boot method only) and from the used Controllers in the route definitions. Besides those it will also include by default (but it can also be configured in config/app.php):

/**
 * artisan autowiring::cache source paths for public methods (except __construct).
 * The Controllers and Service providers are handled automatically
 */
'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'],
    ],
],
Enter fullscreen mode Exit fullscreen mode

This will not include the __construct methods because those are handled in a different way.

Version 10.60.1 contains also:

php artisan event:cache
php artisan event:clear
Enter fullscreen mode Exit fullscreen mode

for Maravel Micro-Framework, which include events as observers. To auto-discover them, override in EventServiceProvider these methods but only when event:cache is ran on deploy :

/**
 * Determine if events and listeners should be automatically discovered.
 */
public function shouldDiscoverEvents(): bool
{
    return true;
}

/**
 * Determine if events as observers and listeners should be automatically discovered.
 */
public function shouldDiscoverEventsAsObservers(): bool
{
    return true;
}
Enter fullscreen mode Exit fullscreen mode

Comments 0 total

    Add comment