失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > php 重新载入类文件夹 php-如何配置Behat从应用程序特定文件夹自动加载类

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

时间:2020-06-12 20:27:10

相关推荐

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/1111/389.html

如果觉得《php 重新载入类文件夹 php-如何配置Behat从应用程序特定文件夹自动加载类》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。