Giter Club home page Giter Club logo

Comments (3)

hhxsv5 avatar hhxsv5 commented on May 9, 2024
  • 使用Swoole Http Server后,单例、全局变量、静态变量会被常驻内存,这是导致出现此问题的根本原因。而在FPM每次请求开始时初始化变量,请求完成后所有变量会自动回收。所以表现不一样。
    要解决这个问题,最直接有效的就是每次请求前重置请求完成后清理这些请求上下文
    具体参考单例问题

  • 具体到这里issue,因FlashServiceProvider中注册的是单例,所以此单例的成员$messages也被常驻内存,调用flash("添加成功")->success()->important();是往$messages中追加,故消息提醒会叠加。
    FlashNotifier.php#L95
    Collection.php#L1719

  • 最终解决方案有两个:

  1. 通过中间件在每次请求处理前请求完成后重置messages app('flash')->clear();
  2. 每次请求处理后重新注册FlashServiceProvider,参考配置register_providers

from laravel-s.

Wqw9550 avatar Wqw9550 commented on May 9, 2024

按照文档设置 register_providers 已经解决,谢谢

from laravel-s.

Wqw9550 avatar Wqw9550 commented on May 9, 2024

按照文档设置 register_providers 已经解决,谢谢

from laravel-s.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.