php - 未定义的方法 defaultStringLength()
问题描述
我想在 laravel 项目中使用 Vinelab/Neoeloquent 包。早些时候,我使用 MySql 来存储我的数据。现在我想为此目的使用 neo4j。我"vinelab/neoeloquent":"1.4.7"
在composer.json中添加了database.php
'default' => env('DB_CONNECTION','neo4j')
, 在连接数组中
'neo4j' => [
'driver' => 'neo4j',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '7474'),
'username' => env('DB_USERNAME', 'neo4j'),
'password' => env('DB_PASSWORD', 'neo4j')
]
并在 app.php'Vinelab\NeoEloquent\NeoEloquentServiceProvider'
之后,composer 更新成功。此外,我将 .env 从我之前的 MySQL 配置更改为 neo4j 的配置
DB_CONNECTION=neo4j
DB_HOST=127.0.0.1
DB_PORT=7474
DB_DATABASE=neo4j
DB_USERNAME=neo4j
DB_PASSWORD=neo4j
毕竟,我遇到了一些问题:1.它无法识别迁移文件中的功能标签
public function up()
{
Neo4jSchema::label('User', function(Blueprint $label) {
$label->unique('email');
$label->index('name');
});
}
2.即使有这个问题,当我尝试迁移时,我遇到了以下问题
In Facade.php line 223:
Call to undefined method Vinelab\NeoEloquent\Schema\Builder::defaultStringLength()
请记住,在我更改 .env 文件后,我无法更新作曲家并得到同样的错误
Illuminate\Foundation\ComposerScripts::postAutoloadDump
@php artisan package:discover
In Facade.php line 223:
Call to undefined method Vinelab\NeoEloquent\Schema\Builder::defaultStringLength()
Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1
Failed to update packages for ./composer.json.
解决方案
尝试用这个编辑你的AppServiceProvider.php,
use Illuminate\Support\Facades\Schema;
public function boot()
{
Schema::defaultStringLength(191);
}
推荐阅读
- r - 在 R 中阅读变音符号
- amazon-web-services - 使用 ebextensions 动态设置每个环境的 EC2 实例类型
- javascript - “另存为视频”但如何使用 javascript 和 html 来代替?
- python - Python:如何使用嵌套的枚举作为嵌套函数的默认参数?
- amazon-web-services - AWS CDK 中 S3 存储桶策略中的白名单 IP 地址
- oracle-apex - Oracle APEX 中的自动递增项目(序数)
- python - 如何匹配双闭花括号而不是花括号
- amazon-web-services - AWS Personalize:失败原因数据集的交互次数少于 1000
- docker - 在 Windows Server '19 上,docker 可以与 IIS 并行运行吗?
- r - 如何在 quanteda 中获得情感分数(并保留情感词)?