Rename src to src/LaravelSessionHandler.php#4
Open
fingerQin wants to merge 1 commit intossdb:masterfrom
fingerQin:patch-1
Open
Rename src to src/LaravelSessionHandler.php#4fingerQin wants to merge 1 commit intossdb:masterfrom fingerQin:patch-1
fingerQin wants to merge 1 commit intossdb:masterfrom
fingerQin:patch-1
Conversation
Laravel5.x不支持 SessionHandler类。所以,我调整之后把适合的版本提交上来。麻烦请合并一下。
|
Hi, 你这个改动相当于增加了一个新文件 |
Member
|
@winerQin 你测试过么?我怎么觉得你这个文件没有改任何东西啊,是不是至少应该extends 一下Laravel的Session Interface ? |
Contributor
Author
|
情况这样的。Laravel5.x不会自动调用open()方法。而SessionHandler类是通过open方法来初始化ssdb对象的。这样就会导致写入session的时候,报没有方法不属于这个对象的错误。所以。我写的LaravelSessionHandler类,把原先open里面的方法移到了构造方法。这个类在我的Yaf项目中通过验证。我正在本地Laravel验证。 |
Contributor
Author
|
@shen2 不需要扩展Laravel的session inteface。Laravel5.x提供了一个如下方法: // 注册 ssdb session 扩展。
Session::extend('ssdb', function($app)
{
return new \SSDB\LaravelSessionHandler(config('session.connection'));
}); |
Member
|
那你用extends方法来写吧,只修改open()和__construct() |
Contributor
Author
|
我的意思是说已有的扩展类(SessionHandler)适合普通的方案。如下: /**
* 初始化session到ssdb中。
* --------------------------------------
* 1、实现SessionHandlerInterface接口,将session保存到ssdb中。
* 2、重新开启session,让默认的session切换到自已的session接口。
* 3、第二步中直接影响Yaf\Session的工作方式。
* --------------------------------------
*/
public function _initSession() {
$config = \Yaf\Registry::get("config");
$ssdb_host = $config->database->ssdb->host;
$ssdb_port = $config->database->ssdb->port;
$sess = new ssdb\SessionHandler("tcp://{$ssdb_host}:{$ssdb_port}");
session_set_save_handler($sess);
session_start();
$session = \Yaf\Session::getInstance();
\Yaf\Registry::set("session", $session);
}而Laravel有自己的一套机制。所以,不能用普通的这种机制。所以,要按照Laravel框架要求的方案。自己实现PHP的SessionHandlerInteface接口。因为,框架不会调用open方法。所以,导致已有的类无法正确初始化对象。从而导致写入失败。在不修改普通机制的情况下,定制一个现有的。你的建议是让我继承Sessionhandler类。只修改open和__construct()。我修改之后再测试上传。Waiting for me |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Laravel5.x不支持 SessionHandler类。所以,我调整之后把适合的版本提交上来。麻烦请合并一下。