Laravel 5.5 为什么产品页面是空的?

Laravel 5.5 Why product page is empty?

我想展示我的产品。一切似乎都很好,但产品页面每次都以空白页打开。我哪里弄错了?

路线;

Route::get('product/{slug}',['as'=>'product.show','uses'=>'ProductController@getProduct']);

控制器;

public function getProduct($slug){

        $product = Product::where('product_slug',$slug)->first();

        return view('frontend.product',compact('product'));
    }

我在我的产品中尝试了 dd 方法 blade。然后它给了我这个错误

file_put_contents(/var/www/laravel/storage/framework/views/7cdf86b0b5c552ccae1fab5d7990ec98a9c7cc32.php): failed to open stream: Permission denied

你可以试试 php artisan view:clear 或者在视图 return 之前的方法中设置一个 dd('test'); 以查看它是否会触发。

您需要运行此命令以允许Laravel为视图创建缓存:

chmod -R 755 ./storage

来自the docs

Directory Permissions

After installing Laravel, you may need to configure some permissions. Directories within the storage and the bootstrap/cache directories should be writable by your web server or Laravel will not run. If you are using the Homestead virtual machine, these permissions should already be set.

https://laravel.com/docs/5.5#configuration