2015-01-06 10:24
浏览 144


I am using composer autoloader for my classes too, but my problem is that files with my classes follow the pattern ClassName.class.php and composer can load files only with .php extension.

Is there any way how to define file pattern in composer.json? I was checking classmap, but it doesn't support patterns.

图片转代码服务由CSDN问答提供 功能建议

我也在为我的类使用 composer autoloader,但问题是我的问题是 我的类遵循模式 ClassName.class.php composer 只能使用 .php 扩展名加载文件。

有没有办法在 composer.json 中定义文件模式? 我正在检查 classmap ,但它不支持模式。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • dorkahemp972157683 2015-01-06 10:31

    Classmap autoloading should be your friend, see

    Just specify the path to wherever you've got your files, let's say when your files reside in src, for example, src/Foo/Bar.class.php, then update your composer.json like this

        "autoload": {
            "classmap": [

    You will need to regenerate the classmap, though, every time you add a new file:

    $ composer dump-autoload
    解决 无用
    打赏 举报

相关推荐 更多相似问题