joanhey / AdapterMan

Run almost any PHP app faster and asynchronously with Workerman, without touch 1 line of code in your fw or app. Also use it as Serverless.
https://twitter.com/adaptermanphp
MIT License
763 stars 50 forks source link

framework thinkphp Still a bit of a problem #25

Closed yangguangwuwu closed 1 year ago

yangguangwuwu commented 1 year ago

https://github.com/joanhey/AdapterMan/blob/master/src/frameworks/think.php

 if (is_dir($routePath)) {
      $files = glob($routePath . '*.php');
      foreach ($files as $file) {
          // Change include to include_once
          include_once $file;
      }
  }

Change include to include_once

think\Http

line 222
 /**
     * 加载全局中间件
     */
    protected function loadMiddleware(): void
    {
        if (is_file($this->app->getBasePath() . 'middleware.php')) {
            $this->app->middleware->import(include $this->app->getBasePath() . 'middleware.php');
        }
    }

Change include to include_once

include $this->app->getBasePath() . 'middleware.php'   
include_once $this->app->getBasePath() . 'middleware.php'
yangguangwuwu commented 1 year ago

@walkor

joanhey commented 1 year ago

I don't know ThinkPHP, so I can't help you here. Sorry.

walkor commented 1 year ago

@yangguangwuwu If you find a problem, welcome to send pr to improve it.