DEV Community

marius-ciclistu
marius-ciclistu

Posted on • Originally published at marius-ciclistu.Medium on

Maravel Micro-Framework 10.52.20 and Maravelith 10.52.10 are optimized by default


Maravel-Framework optimized

Version 10.61.17 of Maravel-Framework allows Maravel Micro-Framework 10.52.20 and Maravelith 10.52.10 to run by default optimized:

Maravel:

    "scripts": {
        "post-autoload-dump": [
            "[$COMPOSER_DEV_MODE -eq 0] && php artisan route:cache || echo artisan route:cache failed",
            "[$COMPOSER_DEV_MODE -eq 0] && php artisan config:cache || echo artisan config:cache failed",
            "[$COMPOSER_DEV_MODE -eq 0] && php artisan autowiring:cache || echo 'autowiring:cache failed'",
            "[$COMPOSER_DEV_MODE -eq 0] && php artisan event:cache || echo artisan event:cache failed"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    },
Enter fullscreen mode Exit fullscreen mode

Maravelith:

    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi",
            "[$COMPOSER_DEV_MODE -eq 0] && php artisan route:cache || echo artisan route:cache failed",
            "[$COMPOSER_DEV_MODE -eq 0] && php artisan config:cache || echo artisan config:cache failed",
            "[$COMPOSER_DEV_MODE -eq 0] && php artisan autowiring:cache || echo 'autowiring:cache failed'",
            "[$COMPOSER_DEV_MODE -eq 0] && php artisan event:cache || echo artisan event:cache failed",
            "[$COMPOSER_DEV_MODE -eq 0] && php artisan view:cache || echo artisan view:cache failed"
        ],
        "post-update-cmd": [
            "[$COMPOSER_DEV_MODE -eq 1] && php artisan vendor:publish --tag=laravel-assets --ansi --force"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    },
Enter fullscreen mode Exit fullscreen mode

This means that if the routes or config contain closures , they will NOT be cached.

When in require-dev environment, the maravel-framework-dev service provider will be auto-registered in Maravel Micro-Framework, exposing the development commands.

For docker deploys with :

composer install --no-scripts
Enter fullscreen mode Exit fullscreen mode

The dump-autoload must be run:

composer dump-autoload
Enter fullscreen mode Exit fullscreen mode

or the cache commands must be called when the container starts.

To speed up the execution of class_exists calls, you can use:

composer install --no-interaction --prefer-dist --no-progress --optimize-autoloader --no-scripts --no-dev --classmap-authoritative
Enter fullscreen mode Exit fullscreen mode

NOTE:
Do not use env() helper outside of the config files if the config is cached!

Top comments (0)