下面thinkphp框架教程栏目将给大家介绍关于TP执行方法要引入这么多个文件对性能的影响,希望对需要的朋友有所帮助!

具体问题:

thinkphp为啥执行一个方法要引入这么多个文件,对性能有何影响?

如题,在thinkphp中某方法只输出一个echo 1, 发现要引入的文件很多,这对服务造成什么影响。

遇到并发大时候该如何优化?

array(63) {
  [0]=>
  string(43) "{MY_SITE}/index.php"
  [1]=>
  string(52) "{MY_SITE}/thinkphp/start.php"
  [2]=>
  string(51) "{MY_SITE}/thinkphp/base.php"
  [3]=>
  string(67) "{MY_SITE}/thinkphp/library/think/Loader.php"
  [4]=>
  string(73) "{MY_SITE}/vendor/composer/autoload_namespaces.php"
  [5]=>
  string(67) "{MY_SITE}/vendor/composer/autoload_psr4.php"
  [6]=>
  string(71) "{MY_SITE}/vendor/composer/autoload_classmap.php"
  [7]=>
  string(68) "{MY_SITE}/vendor/composer/autoload_files.php"
  [8]=>
  string(80) "{MY_SITE}/vendor/symfony/polyfill-mbstring/bootstrap.php"
  [9]=>
  string(86) "{MY_SITE}/vendor/guzzlehttp/promises/src/functions_include.php"
  [10]=>
  string(78) "{MY_SITE}/vendor/guzzlehttp/promises/src/functions.php"
  [11]=>
  string(82) "{MY_SITE}/vendor/guzzlehttp/psr7/src/functions_include.php"
  [12]=>
  string(74) "{MY_SITE}/vendor/guzzlehttp/psr7/src/functions.php"
  [13]=>
  string(84) "{MY_SITE}/vendor/guzzlehttp/guzzle/src/functions_include.php"
  [14]=>
  string(76) "{MY_SITE}/vendor/guzzlehttp/guzzle/src/functions.php"
  [15]=>
  string(78) "{MY_SITE}/vendor/topthink/think-captcha/src/helper.php"
  [16]=>
  string(66) "{MY_SITE}/thinkphp/library/think/Route.php"
  [17]=>
  string(67) "{MY_SITE}/thinkphp/library/think/Config.php"
  [18]=>
  string(69) "{MY_SITE}/thinkphp/library/think/Validate.php"
  [19]=>
  string(77) "{MY_SITE}/vendor/topthink/think-helper/src/helper.php"
  [20]=>
  string(69) "{MY_SITE}/vendor/yfcmf/geetest/src/helper.php"
  [21]=>
  string(78) "{MY_SITE}/vendor/qiniu/php-sdk/src/Qiniu/functions.php"
  [22]=>
  string(75) "{MY_SITE}/vendor/qiniu/php-sdk/src/Qiniu/Config.php"
  [23]=>
  string(80) "{MY_SITE}/vendor/overtrue/wechat/src/Payment/helpers.php"
  [24]=>
  string(66) "{MY_SITE}/thinkphp/library/think/Error.php"
  [25]=>
  string(57) "{MY_SITE}/thinkphp/convention.php"
  [26]=>
  string(64) "{MY_SITE}/thinkphp/library/think/App.php"
  [27]=>
  string(68) "{MY_SITE}/thinkphp/library/think/Request.php"
  [28]=>
  string(48) "{MY_SITE}/app/config.php"
  [29]=>
  string(54) "{MY_SITE}/data/conf/config.php"
  [30]=>
  string(50) "{MY_SITE}/app/database.php"
  [31]=>
  string(65) "{MY_SITE}/thinkphp/library/think/Hook.php"
  [32]=>
  string(46) "{MY_SITE}/app/tags.php"
  [33]=>
  string(48) "{MY_SITE}/app/common.php"
  [34]=>
  string(64) "{MY_SITE}/thinkphp/library/think/Env.php"
  [35]=>
  string(53) "{MY_SITE}/thinkphp/helper.php"
  [36]=>
  string(65) "{MY_SITE}/thinkphp/library/think/Lang.php"
  [37]=>
  string(67) "{MY_SITE}/thinkphp/library/think/Cookie.php"
  [38]=>
  string(64) "{MY_SITE}/thinkphp/library/think/Log.php"
  [39]=>
  string(57) "{MY_SITE}/thinkphp/lang/zh-cn.php"
  [40]=>
  string(52) "{MY_SITE}/app/lang/zh-cn.php"
  [41]=>
  string(53) "{MY_SITE}/app/home/config.php"
  [42]=>
  string(57) "{MY_SITE}/app/home/lang/zh-cn.php"
  [43]=>
  string(61) "{MY_SITE}/app/home/controller/Bet.php"
  [44]=>
  string(62) "{MY_SITE}/app/home/controller/Base.php"
  [45]=>
  string(66) "{MY_SITE}/app/common/controller/Common.php"
  [46]=>
  string(71) "{MY_SITE}/thinkphp/library/think/Controller.php"
  [47]=>
  string(77) "{MY_SITE}/thinkphp/library/traits/controller/Jump.php"
  [48]=>
  string(65) "{MY_SITE}/thinkphp/library/think/View.php"
  [49]=>
  string(78) "{MY_SITE}/thinkphp/library/think/view/driver/Think.php"
  [50]=>
  string(69) "{MY_SITE}/thinkphp/library/think/Template.php"
  [51]=>
  string(81) "{MY_SITE}/thinkphp/library/think/template/driver/File.php"
  [52]=>
  string(66) "{MY_SITE}/thinkphp/library/think/Cache.php"
  [53]=>
  string(78) "{MY_SITE}/thinkphp/library/think/cache/driver/File.php"
  [54]=>
  string(73) "{MY_SITE}/thinkphp/library/think/cache/Driver.php"
  [55]=>
  string(68) "{MY_SITE}/thinkphp/library/think/Session.php"
  [56]=>
  string(63) "{MY_SITE}/thinkphp/library/think/Db.php"
  [57]=>
  string(79) "{MY_SITE}/thinkphp/library/think/db/connector/Mysql.php"
  [58]=>
  string(74) "{MY_SITE}/thinkphp/library/think/db/Connection.php"
  [59]=>
  string(69) "{MY_SITE}/thinkphp/library/think/db/Query.php"
  [60]=>
  string(77) "{MY_SITE}/thinkphp/library/think/db/builder/Mysql.php"
  [61]=>
  string(71) "{MY_SITE}/thinkphp/library/think/db/Builder.php"
  [62]=>
  string(66) "{MY_SITE}/thinkphp/library/think/Debug.php"
}

网友回答:

使用框架本来就是牺牲些性能获取开发效率的。TP框架内部耦合度很高,因此性能比起其他框架还好呢。

看上面加载的文件,你应该使用的是TP5,TP5中使用到的是懒性加载,这种方式只在需要的时候才加载相关的类文件,相比于3.x性能上提升了不少。

另外一种就是缓存。TP3.X能够将所有的要包含的文件打包成一个文件,这样就避免了多次加载。不过在TP5是模板才有缓存。

高并发下,可以使用APC,提高硬件,使用nginx之类。

以上就是探讨关于TP执行一个方法对性能的影响的详细内容,更多请关注亿码酷站其它相关文章!


<!–亿码酷站直播班–>探讨关于TP执行一个方法对性能的影响
—–文章转载自PHP中文网如有侵权请联系ymkuzhan@126.com删除

云服务器推荐