laravel-zero / laravel-zero

A PHP framework for console artisans

Home Page:https://laravel-zero.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error `view not found` executing the phar after build / proposed better doc

mirchaemanuel opened this issue · comments

Laravel-Zero 9.2

Added view support.

I created a view in resources/views named image-list.blade.php and I'm rendering it with termwind.

In development environment it works like a charm. But after I built the app, if I try to execute the same command I get this error:

In FileViewFinder.php line 137:
                                
  View [image-list] not found.  
                                

in storage/framework/views I can see the compiled view.

The project I'm working it is public: https://github.com/mirchaemanuel/a80-cli

I'm getting similar error for file in resource path:

In Figlet.php line 997:
                                                                                                                 
  phar:///Users/[omit]/builds/a80/resources//fonts/larry3d.flf: Font file not found  

it seems resources folder is not included in phar.

now I added resources in directories array of file box.json:

    "directories": [
        "app",
        "bootstrap",
        "config",
        "vendor",
        "resources"
    ],

and I get a new error:

In Compiler.php line 66:
                                      
  Please provide a valid cache path.  

The blade compiler required a cache path. There should be a way to provide an external cache path to phar or disable caching. The constructor of Blade compiler has a $shoudlCache parameter defaulted at true.

I'm trying to analyse a solution in the meantime.

I solved creating a view.php file inside config with this content:

<?php
return [
    'paths' => [
        resource_path('views'),
    ],

    'compiled' => getcwd()
];

and adding resources in directories array of file box.json.

@nunomaduro maybe we can add this comment in the documentation.

maybe an improved view.php could be:

<?php
return [
    'paths' => [
        resource_path('views'),
    ],

    'compiled' => \Phar::running()
        ? getcwd()
        : env('VIEW_COMPILED_PATH', realpath(storage_path('framework/views'))),
];

Closing as the docs have been updated. Thanks!