php 重新载入类文件夹,php-如何配置Behat从应用程序特定文件夹自动加载类

我正在尝试安装&在我现有的小型项目上配置Behat.我了解将* .feature文件放入features文件夹的概念,并且还可以将我的实际* Context.php文件放入features / bootstrap文件夹.当我查看文档中提到实际功能实现的部分时,它暗示Behat默认情况下期望您将应用程序特定的类放到同一文件夹中:

We put the Shelf class into features/bootstrap/Shelf.php because

features/bootstrap is an autoloading folder for Behat. Behat has a

built-in PSR-0 autoloader, which looks into features/bootstrap. If

you’re developing your own application, you probably would want to put

classes into a place appropriate for your app.

但是,在文档的任何地方都没有提到我将如何配置Behat以便能够识别实际app文件夹中的类.

这是我的项目目录结构:

/

-/app

--/classes --where my apps classes actually live

-/features --behat generated folder

--/bootstrap --behat generated folder

-/public

-/system

-/vendor -- composer included libraries

我的项目使用自己的自动装带器在app / classes文件夹中搜索的类,并且类名使用下划线,其中路径分隔符位于目录分隔符中.例如可在app / classes / controller / app.php中找到Controller_App类

如何配置Behat,使其不希望在features / bootstrap文件夹中找到我的应用程序类?

解决方法:

解决方案是将以下内容添加到composer.json中:

"autoload": {

"psr-0": {"":"app/classes"}

}

然后运行composer dump-autoload

然后就可以了!

标签:behat,tdd,bdd,php

来源: https://codeday.me/bug/20191111/2021389.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值