leafsphp / blade

🔪 Leaf's implementation of Laravel Blade (Adapted from jenssegers/blade)
https://leafphp.dev/modules/views/blade/
3 stars 0 forks source link

Blade issue upgrading from Leaf 2.5 to Leaf 3 #3

Closed ivan-au closed 2 months ago

ivan-au commented 4 months ago

Describe the bug I'm upgrading my application from Leaf v2.5 to Leaf v3 and I'm finding an issue with Blade.

To Reproduce Below is the log trace I get. It points to issues in dependencies used by Leaf. A quick Google search shows the same issue reported in Laravel and other apps.

Illuminate\Contracts\Container\BindingResolutionException thrown with message "Target class [blade.compiler] does not exist."

Stacktrace:
leafsphp/leaf#19 Illuminate\Contracts\Container\BindingResolutionException in my-app\vendor\illuminate\container\Container.php:914
leafsphp/leaf#18 ReflectionException in my-app\vendor\illuminate\container\Container.php:912
leafsphp/leaf#17 ReflectionClass:__construct in my-app\vendor\illuminate\container\Container.php:912
leafsphp/leaf#16 Illuminate\Container\Container:build in my-app\vendor\illuminate\container\Container.php:795
leafsphp/leaf#15 Illuminate\Container\Container:resolve in my-app\vendor\illuminate\container\Container.php:731
leafsphp/leaf#14 Illuminate\Container\Container:make in my-app\vendor\illuminate\view\ViewServiceProvider.php:168
leafsphp/leaf#13 Illuminate\View\ViewServiceProvider:Illuminate\View\{closure} in my-app\vendor\illuminate\view\Engines\EngineResolver.php:55
leafsphp/leaf#12 call_user_func in my-app\vendor\illuminate\view\Engines\EngineResolver.php:55
leafsphp/leaf#11 Illuminate\View\Engines\EngineResolver:resolve in my-app\vendor\illuminate\view\Factory.php:310
leafsphp/leaf#10 Illuminate\View\Factory:getEngineFromPath in my-app\vendor\illuminate\view\Factory.php:274
leafsphp/leaf#9 Illuminate\View\Factory:viewInstance in my-app\vendor\illuminate\view\Factory.php:146
leafsphp/leaf#8 Illuminate\View\Factory:make in my-app\vendor\leafs\blade\src\Blade.php:72
leafsphp/leaf#7 Leaf\Blade:make in my-app\vendor\leafs\blade\src\Blade.php:61
leafsphp/leaf#6 Leaf\Blade:render in my-app\app\routes.php:65
leafsphp/leaf#5 {closure} in my-app\vendor\leafs\router\src\Router\Core.php:531
leafsphp/leaf#4 call_user_func_array in my-app\vendor\leafs\router\src\Router\Core.php:531
leafsphp/leaf#3 Leaf\Router\Core:invoke in my-app\vendor\leafs\router\src\Router\Core.php:521
leafsphp/leaf#2 Leaf\Router\Core:handle in my-app\vendor\leafs\router\src\Router\Core.php:466
leafsphp/leaf#1 Leaf\Router\Core:run in my-app\vendor\leafs\leaf\src\App.php:382
#0 Leaf\App:run in my-app\public\index.php:14

Expected behavior Leaf App should run

Additional context As mentioned, I'm upgrading gtom Leaf 2.5 to Leaf 3

mychidarko commented 3 months ago

Can you walk me through your upgrade process @ivan-au

Teisi commented 3 months ago

I am brand new to leaf and would like to experiment with it. Unfortunately, I encounter the same problem when using Blade. Simple Example:

[DocumentRoot]/composer.json

{
    "require": {
        "php": "^8.2",
        "ext-json": "*",
        "guzzlehttp/guzzle": "^7.0",
        "doctrine/dbal": "^4.0",
        "leafs/leaf": "^3.5",
        "leafs/anchor": "^1.5",
        "leafs/auth": "^2.3",
        "leafs/csrf": "^0.4.1",
        "leafs/form": "^2.1",
        "leafs/router": "^0.2.3",
        "leafs/logger": "^1.3",
        "leafs/exception": "^3.2",
        "leafs/blade": "^2.0"
    }
}

[DocumentRoot]/public/index.php

<?php

require __DIR__ . '/../vendor/autoload.php';

Leaf\View::attach(\Leaf\Blade::class);
Leaf\View::blade()->configure(
    viewPaths: __DIR__ . '/../views/',
    cachePath: __DIR__ . '/../cache/views/'
);

app()->get('/', function () {
    echo app()->blade->render('home');
});

app()->run();
ivan-au commented 3 months ago

Can you walk me through your upgrade process @ivan-au

Hi @mychidarko , I followed the instructions at https://leafphp.dev/docs/migration/introduction.html#migrating-from-leaf-2:

My composer.json now:

{
    "require": {
        "html2text/html2text": "^4.3",
        "leafs/leaf": "^3.5",
        "monolog/monolog": "^3.6",
        "aws/aws-sdk-php": "^3.314",
        "vlucas/phpdotenv": "^5.6",
        "whichbrowser/parser": "^2.1",
        "leafs/session": "^2.0",
        "leafs/logger": "^1.3",
        "leafs/http": "^2.3",
        "leafs/blade": "^2.0"
    }
}
mychidarko commented 2 months ago

I just pushed out a new version of leafs/blade. Can you pls check if this fixes your issue @ivan-au @Teisi

Teisi commented 2 months ago

@mychidarko short test seems fine to me currently :) thank you.

ivan-au commented 2 months ago

Apologies for the late feedback @mychidarko , confirming that the issue was resolved for me as well. Thanks a lot!