【问题标题】:Composer autoload Class not found exceptionComposer 自动加载类未找到异常
【发布时间】:2017-07-21 18:03:09
【问题描述】:

我创建了一个名为Util.php 的文件,Util.php 文件中有两个类。

  • class StringUtil {}
  • class ArrayUtil {}

我怎样才能将Util.php 变成composer library 用于其他项目包括?现在我得到了Class Not Found Exception

【问题讨论】:

    标签: php composer-php autoload psr-4


    【解决方案1】:

    我创建了一个名为 Util.php 的文件,Util.php 中有两个类 文件。

    首先这是不好的做法

    无论如何,它可以帮助: https://getcomposer.org/doc/04-schema.md#files

    {
        "autoload": {
            "files": ["src/MyLibrary/functions.php"]
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2017-02-28
      • 1970-01-01
      • 2018-06-01
      • 2017-02-01
      • 1970-01-01
      • 2015-02-17
      • 2020-01-21
      • 2019-01-22
      • 2014-02-11
      相关资源
      最近更新 更多