ishanvyas22 / asset-mix

Provides helpers functions for CakePHP to use Laravel Mix.
MIT License
32 stars 12 forks source link

Deprecation warnings #34

Closed marianodonal closed 2 years ago

marianodonal commented 2 years ago

Describe the bug Hi, i'm new with react and laravel mix. I'm trying to create an app when I get two deprecation warnings:

Router::plugin() is deprecated, use the non-static method RouterBuilder::plugin() instead. - /Applications/MAMP/htdocs/cakereact/vendor/ishanvyas22/asset-mix/config/routes.php, line: 11 You can disable all deprecation warnings by setting Error.errorLevel to E_ALL & ~E_USER_DEPRECATED, or add vendor/ishanvyas22/asset-mix/config/routes.php to Error.ignoredDeprecationPaths in your config/app.php to mute deprecations from only this file. [CORE/src/Core/functions.php, line 322]

Router::scope() is deprecated, use the non-static method RouterBuilder::scope() instead. - /Applications/MAMP/htdocs/cakereact/vendor/cakephp/cakephp/src/Routing/Router.php, line: 912 You can disable all deprecation warnings by setting Error.errorLevel to E_ALL & ~E_USER_DEPRECATED, or add vendor/cakephp/cakephp/src/Routing/Router.php to Error.ignoredDeprecationPaths in your config/app.php to mute deprecations from only this file. [CORE/src/Core/functions.php, line 322]

ishanvyas22 commented 2 years ago

What is exact CakePHP version you are using? Also, the package version.

marianodonal commented 2 years ago

CakePHP 4.3.0

marianodonal commented 2 years ago

I've fixed it by updating routes.php file in plugin config folder.

use Cake\Routing\RouteBuilder;
use Cake\Routing\Route\DashedRoute;

return static function (RouteBuilder $routes) {
    $routes->plugin('AssetMix', ['path' => '/asset-mix'], function (RouteBuilder $routes) {
        $routes->fallbacks(DashedRoute::class);
    });
};

I don't know how to perform a pull request, maybe I can collaborate. Thanks

Andream98 commented 2 years ago

I'm on CakePHP 4.3 with the latest version of this package and I've also changed the routes.php file because of the deprecation warnings I get when I start the CakePHP server:

<?php

    use Cake\Routing\Route\DashedRoute;
    use Cake\Routing\RouteBuilder;

    /** @var RouteBuilder $routes */
    $routes->plugin(
        'AssetMix',
        ['path' => '/asset-mix'],
        function (RouteBuilder $routes) {
            $routes->fallbacks(DashedRoute::class);
        });

@ishanvyas22 let me know which version seems more appropriate to you so that I can create a PR.

PS: I will be opening the same PR on cakephp-inertiajs too

ishanvyas22 commented 2 years ago

@Andream98 v4.3.0 seems good as it is deprecated in that version only.

You can create a PR with the change and updating CakePHP version to 4.3 in composer.json file.

ishanvyas22 commented 2 years ago

Released in 1.4.0