webman视图模板报错:Class not found

0

使用Twig的模板
在浏览器中调用Index.php中的view方法:
ip:8787/index/view,报错如下
Error: Class 'Twig\Environment' not found in /home/webman/webman/support/view/Twig.php:35


使用think-template
Error: Class 'think\Template' not found in /home/webman/webman/support/view/ThinkPHP.php:34


使用Blade
Error: Class 'Jenssegers\Blade\Blade' not found in /home/webman/webman/support/view/Blade.php:35

已邀请:

six

赞同来自:

要composer安装的,你看下文档呢。

jones

赞同来自:

三个模板都安装了,安装时wemman仍然在运行,没有报错。以为一切正常,就按文档尝试用三个模板试试。发现上述问题。
暂时解决上述问题的过程如下:
1、停掉webman,再次启动webman,报错如下:


PHP Fatal error:  Uncaught Error: Call to private Dotenv\Repository\Adapter\EnvConstAdapter::__construct() from context 'Illuminate\Support\Env' in /home/webman/webman/vendor/illuminate/support/Env.php:58
Stack trace:
#0 /home/webman/webman/vendor/illuminate/support/Env.php(81): Illuminate\Support\Env::getRepository()
#1 /home/webman/webman/vendor/illuminate/support/helpers.php(276): Illuminate\Support\Env::get('APP_DEBUG', false)
#2 /home/webman/webman/config/app.php(16): env('APP_DEBUG', false)
#3 /home/webman/webman/vendor/workerman/webman-framework/src/Config.php(36): include('/home/web...')
#4 /home/webman/webman/start.php(22): Webman\Config::load('/home/web...', Array)
#5 {main}
thrown in /home/webman/webman/vendor/illuminate/support/Env.php on line 58

Fatal error: Uncaught Error: Call to private Dotenv\Repository\Adapter\EnvConstAdapter::__construct() from context 'Illuminate\Support\Env' in /home/webman/webman/vendor/illuminate/support/Env.php:58
Stack trace:
#0 /home/webman/webman/vendor/illuminate/support/Env.php(81): Illuminate\Support\Env::getRepository()
#1 /home/webman/webman/vendor/illuminate/support/helpers.php(276): Illuminate\Support\Env::get('APP_DEBUG', false)
#2 /home/webman/webman/config/app.php(16): env('APP_DEBUG', false)
#3 /home/webman/webman/vendor/workerman/webman-framework/src/Config.php(36): include('/home/web...')
#4 /home/webman/webman/start.php(22): Webman\Config::load('/home/web...', Array)
#5 {main}
thrown in /home/webman/webman/vendor/illuminate/support/Env.php on line 58

2、删除blade
composer remove jenssegers/blade
再次尝试使用think-template/Twig均正常了。
追问:Blade模板的问题怎么解决?

walkor

赞同来自:

Blade 加一句


composer require vlucas/phpdotenv ^4.0

jones

赞同来自:

感谢walkor! 加上之后,启动webman不报错了,但是设置为Blade模板后,貌似不起作用,显示结果为:
hello {{ $name }}
view.html文件内容如下:


<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="/favicon.ico" />
<title>webman</title>

</head>
<body>
hello {{ $name }}
</body>
</html>

要回复问题请先登录注册