问题描述
我想将phpspec2与CodeIgniter 2集成在一起.我已经按照 phpspec网站所述使用composer成功安装了phpspec.现在,我想将其集成到我的CodeIgniter 2安装中.我已经找到有关此主题的 AniDear文章并按照说明进行了所有操作.但是,当我运行bin/phpspec
时,我得到一个错误:
I want to integrate phpspec2 with CodeIgniter 2. I've succesfully installed phpspec using composer as described on phpspec website. Now I'd like to integrate it into my CodeIgniter 2 installation. I've found an article by AniDear on this subject and did everything as described. However when I run bin/phpspec
I get an error:
PHP Warning: require(core/Common.php): failed to open stream: No such file or directory
in C:\xampp\htdocs\eljotengine\spec\ci_bootstrap.php on line 37
Warning: require(core/Common.php): failed to open stream: No such file or directory in C:\xampp\htdocs\eljotengine\spec\ci_bootstrap.php on line 37
,依此类推.我的文件结构如下:
and so on. My file structure looks like this:
eljotengine
|-application
|-sytem
|- ... other CI
|-spec
| |- ci_bootstrap.php
我正在Windows 7上使用xampp.我的ci_bootstrap.php
文件看起来类似于上述AniDear文章中的文件.
I am using xampp on Windows 7. My ci_bootstrap.php
file looks like the one in the above mentioned article by AniDear.
我试图更改ci_bootstrap.php
文件中的路径(这似乎是问题),但是并没有太大改变.
I've tried to change the paths in the ci_bootstrap.php
file (it seems to be the problem) however it did not change much.
有什么想法可以使这项工作成功吗?
Any ideas how to make this work?
问候:)
推荐答案
我也对PHPSpec2有问题.由于我仅在PHPSpec(而不是PHPSpec2)上进行过尝试,因此建议您改为安装PHPSpec.只需将"phpspec/phpspec2": "*"
行上的composer.json文件更改为"phpspec/phpspec": "*"
,然后再次运行composer update
.
I am having problem with PHPSpec2 too.Since I have only tried it with PHPSpec (not PHPSpec2), I would suggest you to install PHPSpec instead. Just change the file composer.json, on the line "phpspec/phpspec2": "*"
to "phpspec/phpspec": "*"
, then runs composer update
again.
通过在项目路径上使用命令vendor\bin\phpspec.php.bat spec
运行此phpspec,而"spec"是包含spec文件的文件夹.
Run this phpspec, by using command vendor\bin\phpspec.php.bat spec
on your project path, whereas "spec" is the folder containing spec files.
由于您是从项目目录中运行phpspec,因此建议按照以下说明更改ci_bootstrap.php中的内容
And since you're running phpspec from your project directory, I suggest changing content inside ci_bootstrap.php as follow
define('BASEPATH',realpath('system/').'/'); //set absolute path to CI system/
define('APPPATH', 'application/'); //set relative path to CI application
set_include_path(
get_include_path().PATH_SEPARATOR.
realpath(APPPATH).PATH_SEPARATOR.
realpath(BASEPATH).PATH_SEPARATOR.
'spec'); //adding 'spec' in path, for easily do require 'ci_bootstrap.php' from inside spec files
require BASEPATH.'core/Common.php';
require APPPATH.'config/constants.php';
require BASEPATH.'core/Controller.php';
这篇关于将Codeigniter 2与phpspec2集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!