php - 我创建了 laravel 包并在其他项目中需要我的包。我在项目模型中使用包特征。但我收到此错误 => 未找到特征
问题描述
我创建了 laravel 包并在其他项目中需要我的包。我在项目模型中使用包特征。
但我得到这个错误=>
Symfony\Component\Debug\Exception\FatalErrorException:未找到特征“Encryption\Src\Encryptable”
我加载包github你可以看到这个链接=>
{
"name": "kablanfatih/encryption",
"description": "A package for automatically encrypting and decrypting Eloquent attributes in Laravel , based on configuration settings.",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "kablanfatih",
"email": "kablanfatih34@gmail.com"
}
],
"minimum-stability": "dev",
"require": {},
"autoload": {
"psr-4": {
"kablanfatih\\encryption\\": "../encryption"
}
},
"autoload-dev": {
"psr-4": {
"kablanfatih\\encryption\\": "../encryption/",
"Tests\\": "tests"
}
},
"extra": {
"laravel": {
"providers": [
"Barryvdh\\Debugbar\\ServiceProvider"
],
"aliases": {
"Debugbar": "Barryvdh\\Debugbar\\Facade"
}
}
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.2@dev"
}
}
<?php
namespace App\Models;
use Encryption\Src\Encryptable;
use Illuminate\Database\Eloquent\Model;
class Question extends Model
{
use Encryptable;
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'questions';
/**
* The attributes that are mass assignable.
* @var array
*/
protected $fillable = [
'question', 'incorrect1', 'incorrect2', 'incorrect3', 'incorrect4', 'correct'
];
/**
* The attributes that are encrypted.
*
* @var array
*/
protected $encrypted = [
'question'
];
}
解决方案
您的命名空间不正确。您应该"kablanfatih\\encryption\\"
在 composer.json 中替换为Encryption\\
推荐阅读
- c - 如何在C中打印一个向量
- docusignapi - 带有 javaee-api 8.0 的 DocuSign REST API java sdk 抛出 java.lang.ClassNotFoundException: org.glassfish.jersey.internal.RuntimeDelegateImpl
- reactjs - React nobelprizes API:如何打印一年的所有获奖者?
- algorithm - 交易算法,什么是最好的?
- java - 在java中将具有8个或更多字符的double转换为sting
- php - 基于重量的累进折扣显示剩余重量以获得更好的折扣信息
- apache-spark - 如何使用 spark、s3Distcp 和 aws EMR 从一个 s3 位置读取大型数据集并将其重新分区到另一个位置
- sql - 忽略 SQL delete where exists 语句中的主键
- android - TextView的append()方法如何调用SpannableStringBuilder的replace()方法
- python - 简单的 Python - 如何在每次重复 for 循环时更改变量?