swoft-cloud / swoft

🚀 PHP Microservice Full Coroutine Framework
https://swoft.org
Apache License 2.0
5.58k stars 788 forks source link

composer require swoft/session issue #1057

Closed dcdebug closed 4 years ago

dcdebug commented 4 years ago
Q A
Bug report? yes/no
Feature request? yes/no
Swoft version x.y.z
Swoole version x.y.z (by php --ri swoole)
PHP version x.y.z (by php -v)
Runtime environment Win10/Mac/CentOS 7/Ubuntu/Docker etc.

Describe the bug A clear and concise description of what the bug is.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Details

Describe what you are trying to achieve and what goes wrong.

// paste output here

Provide minimal script to reproduce the issue

// 
darrykinger@deary:~/php_developer/swoft$ composer require swoft/session
Using version ^2.0 for swoft/session
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 6 installs, 0 updates, 0 removals
  - Installing kylekatarnls/update-helper (1.2.0): Downloading (100%)         
  - Installing symfony/translation-contracts (v1.1.7): Downloading (100%)         
  - Installing symfony/polyfill-mbstring (v1.12.0): Downloading (100%)         
  - Installing symfony/translation (v4.3.5): Downloading (100%)         
  - Installing nesbot/carbon (1.39.1): Downloading (100%)         
  - Installing swoft/session (v2.0.6): Downloading (100%)         
symfony/translation suggests installing symfony/config
Writing lock file
Generating autoload files
Carbon 1 is deprecated, see how to migrate to Carbon 2.
https://carbon.nesbot.com/docs/#api-carbon-2
    You can run './vendor/bin/upgrade-carbon' to get help in updating carbon and other frameworks and libraries that depend on it.

how i fix this ? 2.x document can't found the session info;

inhere commented 4 years ago

hi @dcdebug The session component has not been migrated to 2.0. It may take a while to wait.

dcdebug commented 4 years ago

我使用的swoft是最新版,都是走的官方的2.x的文档, 那么我目前使用session 有没有比较好的方案? ? ? 使用原生的php session 的话,如何避免:session_start(): Cannot start session when headers already sent At /home/darrykinger/php_developer/swoft/app/Http/Controller/UserController.php line 37 的错误提示? 我的业务需求是实现用户的登录,将用户的登录信息保存到session

inhere commented 4 years ago

可以用jwt替代,也比较简单。用户的登录信息存到redis。

全局中间件检查token,匹配到信息就存储到context,这样在后面都可以用。

dcdebug commented 4 years ago

OK,谢谢,小型系统,暂时不考虑使用redis ,考虑使用mysql代替,用户人不多,拿swoole+swoft练练手,多谢指教

dcdebug commented 4 years ago

可以用jwt替代,也比较简单。用户的登录信息存到redis。

全局中间件检查token,匹配到信息就存储到context,这样在后面都可以用。

context 是什么? 不是存储在浏览器中吧?我发现使用jwt 用于api的授权比较好,但是jwt+redis ,在检测客户端的cookie的时候,很麻烦..

nanyounanyounan commented 4 years ago

很期待swoft/session组件迁移到2.0x版本使用,目前jwt做管理后台很难做...

inhere commented 4 years ago

很期待swoft/session组件迁移到2.0x版本使用,目前jwt做管理后台很难做...

@nanyounanyounan session 2.0 版本的已经发布了啊

nanyounanyounan commented 4 years ago

可是2.0文档上没有说明,而且我composer下来后,使用的时候报错,session组件信号量 监听不到 什么的问题,然后就放弃使用了,十分感谢您的回复@inhere

inhere commented 4 years ago

你是哪里使用不对吧!demo仓库 https://github.com/swoft-cloud/swoft 里也早就带了session组件呢。

文档也是有的 http://swoft.io/docs/2.x/zh-CN/extra/http-session.html

nanyounanyounan commented 4 years ago

对不起,打扰您了,是我的不好,新文档没找到,谢谢指导@inhere