Flynsarmy / laravel-db-blade-compiler

Render Blade templates from Eloquent Model Fields
170 stars 38 forks source link

file_put_contents failed to open stream: No such file or directory #52

Open reynoldspaul opened 3 years ago

reynoldspaul commented 3 years ago

Hi, after installation, and running:

DbView::make($this)->field('email_subject')->with($data)->render();

I get the following error

file_put_contents(../app/db-blade-compiler/views/b92b4b7d77cc4fdc95e46a0d6e471b5e): 
failed to open stream: No such file or directory

I can fix this by manually creating the folder /app/db-blade-compiler/views. I have cache set to false in config

Using Laravel 8,0, latest version of this package

nexana commented 3 years ago

Encountered the same issue numerous times with different combinations of the compiler (and laravel). Maybe it would be nice to have the compiled directory as a config parameter?

kaptk2 commented 3 years ago

Or another option would be to make sure the directory exists and if it doesn't create it.

Yinci commented 3 years ago

I ran into the same issue. I just have this set above:

if (! Storage::exists('db-blade-compiler/views')) {
    Storage::makeDirectory('db-blade-compiler/views');
}

However, I shouldn't have to do this. It's weird that it doesn't even check within the package itself.

oliworx commented 1 year ago

I ran into the same issue. I just have this set above:

if (! Storage::exists('db-blade-compiler/views')) {
    Storage::makeDirectory('db-blade-compiler/views');
}

However, I shouldn't have to do this. It's weird that it doesn't even check within the package itself.

It works for me with these lines in the boot() method of the AppServiceProvider.php
(running on Laravel Vapor)

// Create storage/app/db-blade-compiler/views directory if it doesn't exist
if (!file_exists(storage_path('app/db-blade-compiler/views'))) {
    mkdir(storage_path('app/db-blade-compiler/views'), 0777, true);
}