运行 illuminate/database/capsule with bootEloquent() in PHP 解析错误
Parse error when run illuminate/database/capsule with bootEloquent() in PHP
我正在尝试使用 Slim 和软件包 illuminate/database
在 php 环境中建立 mysql 连接。按照文档我创建了一个新的 $capsule 实例,我通过 addConnection
方法传递了带有连接数据的数组,然后我有 运行 bootEloquent()
方法:
<?php
use Illuminate\Database\Capsule\Manager as Capsule;
$capsule = new Capsule;
$capsule->addConnection([
'driver' => $app->config->get('db.driver'),
'host' => $app->config->get('db.host'),
'database' => $app->config->get('db.database'),
'username' => $app->config->get('db.username'),
'password' => $app->config->get('db.password'),
'charset' => $app->config->get('db.charset'),
'collation' => $app->config->get('db.collation'),
'prefix' => $app->config->get('db.prefix')
]);
#here the output seems correct...
#var_dump($capsule);
$capsule->bootEloquent();
?>
不幸的是,当我 运行 启动 Eloquent() 时出现错误:
Parse error: parse error in
/Sites/auth/vendor/illuminate/database/Eloquent/Model.php
on line 597
问题似乎与 Eloquent 模型 有关。
我已经尝试用不同版本更新 composer.json 文件。我也重新安装了每个包,但解析错误仍然存在。
当前项目运行正在运行:PHP 版本 5.6.30.
我当前的作曲家 json 包含所有依赖项的文件
{
"autoload": {
"psr-4": {
"Business\": "app/Business"
}
},
"require": {
"slim/slim": "~2.0",
"slim/views": "0.1.*",
"twig/twig": "~1.0",
"phpmailer/phpmailer": "~5.2",
"hassankhan/config": "0.8.*",
"illuminate/database": "~5.0",
"alexgarrett/violin": "2.*",
"ircmaxell/random-lib": "~1.1"
}
}
有人能解释一下为什么我会遇到这种奇怪的糟糕情况吗?
提前致谢。
查看您的 composer.lock
以了解安装了哪个版本的 illuminate/database
。后者与 PHP 5.6.30 不兼容,但需要 PHP 7。您可以尝试通过 "illuminate/database": "~5.4.0"
强制执行该版本约束
我正在尝试使用 Slim 和软件包 illuminate/database
在 php 环境中建立 mysql 连接。按照文档我创建了一个新的 $capsule 实例,我通过 addConnection
方法传递了带有连接数据的数组,然后我有 运行 bootEloquent()
方法:
<?php
use Illuminate\Database\Capsule\Manager as Capsule;
$capsule = new Capsule;
$capsule->addConnection([
'driver' => $app->config->get('db.driver'),
'host' => $app->config->get('db.host'),
'database' => $app->config->get('db.database'),
'username' => $app->config->get('db.username'),
'password' => $app->config->get('db.password'),
'charset' => $app->config->get('db.charset'),
'collation' => $app->config->get('db.collation'),
'prefix' => $app->config->get('db.prefix')
]);
#here the output seems correct...
#var_dump($capsule);
$capsule->bootEloquent();
?>
不幸的是,当我 运行 启动 Eloquent() 时出现错误:
Parse error: parse error in /Sites/auth/vendor/illuminate/database/Eloquent/Model.php on line 597
问题似乎与 Eloquent 模型 有关。 我已经尝试用不同版本更新 composer.json 文件。我也重新安装了每个包,但解析错误仍然存在。
当前项目运行正在运行:PHP 版本 5.6.30.
我当前的作曲家 json 包含所有依赖项的文件
{
"autoload": {
"psr-4": {
"Business\": "app/Business"
}
},
"require": {
"slim/slim": "~2.0",
"slim/views": "0.1.*",
"twig/twig": "~1.0",
"phpmailer/phpmailer": "~5.2",
"hassankhan/config": "0.8.*",
"illuminate/database": "~5.0",
"alexgarrett/violin": "2.*",
"ircmaxell/random-lib": "~1.1"
}
}
有人能解释一下为什么我会遇到这种奇怪的糟糕情况吗? 提前致谢。
查看您的 composer.lock
以了解安装了哪个版本的 illuminate/database
。后者与 PHP 5.6.30 不兼容,但需要 PHP 7。您可以尝试通过 "illuminate/database": "~5.4.0"