解决ThinkPHP5.1版本引入composer vendor扩展包的问题

 4897

下面给大家介绍解决ThinkPHP5.1版本引入composer vendor扩展包的问题,希望对需要的朋友有所帮助!


版本说明

旧版本:ThinkPHP5.0

新版本:ThinkPHP5.1

问题:TP5.1 中取消了 Loader::import 方法以及import和vendor助手函数,全部采用命名空间和自动加载机制,导致引入类库找不到报错

解决:因为“全部采用命名空间和自动加载机制”,所以对 composer/installed.json 做了修改(文字说明在下方注释中)


60b1d05b276bb.png


  1. {
  2.     "name": "curl/curl",
  3.     "version": "2.3.0",
  4.     "version_normalized": "2.3.0.0",
  5.     "source": {
  6.         "type": "git",
  7.         "url": "https://github.com/php-mod/curl.git",
  8.         "reference": "3ad560b1fc1bbdf5c7681356ab953fb961f255e5"
  9.     },
  10.     "dist": {
  11.         "type": "zip",
  12.         "url": "https://api.github.com/repos/php-mod/curl/zipball/3ad560b1fc1bbdf5c7681356ab953fb961f255e5",
  13.         "reference": "3ad560b1fc1bbdf5c7681356ab953fb961f255e5",
  14.         "shasum": ""
  15.     },
  16.     "require": {
  17.         "ext-curl": "*",
  18.         "php": "^5.6 | ^7.0"
  19.     },
  20.     "require-dev": {
  21.         "phpunit/phpunit": "^5.7",
  22.         "squizlabs/php_codesniffer": "~2.1"
  23.     },
  24.     "time": "2020-03-19T20:07:26+00:00",
  25.     "type": "library",
  26.     "installation-source": "dist",
  27.     "autoload": {
  28.         "psr-0": {
  29.             "Curl": "src/"
  30.         },
  31.         //在此处添加 files 字段,把类库文件的相对路径填入
  32.         "files":[
  33.             "vendor/curl/curl/src/Curl/Curl.php"
  34.         ]
  35.     },
  36.     "notification-url": "https://packagist.org/downloads/",
  37.     "license": [
  38.         "MIT"
  39.     ],
  40.     "authors": [
  41.         {
  42.             "name": "php-curl-class",
  43.             "homepage": "https://github.com/php-curl-class"
  44.         },
  45.         {
  46.             "name": "Hassan Amouhzi",
  47.             "email": "hassan@anezi.net",
  48.             "homepage": "http://hassan.amouhzi.com"
  49.         },
  50.         {
  51.             "name": "user52",
  52.             "homepage": "https://github.com/user52"
  53.         }
  54.     ],
  55.     "description": "cURL class for PHP",
  56.     "homepage": "https://github.com/php-mod/curl",
  57.     "keywords": [
  58.         "curl",
  59.         "dot"
  60.     ]
  61. }


本文网址:https://www.zztuku.com/detail-8906.html
站长图库 - 解决ThinkPHP5.1版本引入composer vendor扩展包的问题
申明:如有侵犯,请 联系我们 删除。

评论(0)条

您还没有登录,请 登录 后发表评论!

提示:请勿发布广告垃圾评论,否则封号处理!!

    编辑推荐