Laravel Sentinel引用了错误的配置文件 [英] Laravel Sentinel referencing the wrong config file

查看:95
本文介绍了Laravel Sentinel引用了错误的配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我使用Cartalyst Sentinel在Laravel 5.1中管理身份验证和角色.最初,我下载了软件包,并添加了其他查询范围,并在vendor/../EloquentUser类中定义了关系. Composer今天更新了该程序包,很自然地删除了我所有的代码.到那时,我意识到我需要拥有自己的User类,该类扩展了EloquentUser并修改了已发布的配置文件以使用我自己的User类.但是,Sentinel似乎正在使用/vendor目录中的配置文件,因为当我修改该配置文件以使用我的用户模型时,它起作用了,即查询范围和关系开始对我的用户起作用.但是更改已发布的配置对我的应用程序没有影响.

So im using Cartalyst Sentinel to manage authentication and roles in Laravel 5.1. At first i downloaded the package and was adding additional query scopes and defining relations in the vendor/../EloquentUser class. Composer updated the package today and naturally all my code was removed. At which point i realized that i needed to have my own User class which extended EloquentUser and modify the published config file to use my own User class. However it seems that Sentinel is using the config file within the /vendor directory because when i modify that one to use my User model, it works, that is the query scopes and relations start to work on my users. But changing the published config has no effect on my application.

对于Laravel和作曲者以及其他所有人来说,我不是很陌生,来自Codeigniter,所以也许我在设置它时做错了什么或搞砸了?

Im fairly new to Laravel and composer and all, coming from Codeigniter, so maybe i am doing something wrong or messed up while setting it up?

推荐答案

好吧,所以我一直在与Laravel纠缠一段时间,并逐渐了解它的工作原理.

Okay so i have been tinkering with Laravel for a while and gotten to know how it works better.

我犯的错误是我在文件的顶部包含了该语句(老实说,卡塔利斯特的文档中是这样的,我认为它对新蜜蜂有误导性):

The mistake i had made was that i was including this statement on the top of my file (honestly Cartalyst's documentation had it so, i think its misleading for a newbee):

use Cartalyst\Sentinel\Native\Facades\Sentinel;

然后执行:

Sentinel::getUser();

所以很明显,它引用了vendor(Native)文件夹中的配置文件.

So obviously it was referencing the config file in the vendor (Native) folder.

正确的方法是使用顶部的Sentinel Facade:

The correct way is to use the Sentinel Facade on the top:

use Sentinel;

,然后它将引用已发布的配置文件.

and then it will reference the published configuration file.

我希望这对其他犯同样错误的新手有所帮助. :)

I hope this helps any other newbee who makes the same mistake. :)

这篇关于Laravel Sentinel引用了错误的配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆