首页 > 解决方案 > php包独立philo/laravel-blade给黑屏

问题描述

我正在尝试将这个 php 包与 php 7.0.33 一起使用,但它既没有给出任何错误也没有工作它只是给一个空白屏幕。下面是我的代码。如何调试?

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

require 'vendor/autoload.php';

use Philo\Blade\Blade;

$views = __DIR__ . '/views';
$cache = __DIR__ . '/cache';

$blade = new Blade($views, $cache);
echo $blade->view()->make('hello')->render();

标签: laravellaravel-blade

解决方案


首先,你在这里少了一个分号

error_reporting(E_ALL); <-- Missing

这就是为什么它没有显示任何内容

然后确保hello.blade.php 在您的views 文件夹中有一个结构为 HTML的文件

目录结构

views/hello.blade.php

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    Hello, World!
</body>
</html>

希望这可以帮助


推荐阅读