Zend工具包含路径 [英] Zend tool include path

查看:98
本文介绍了Zend工具包含路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在不访问include_path目录的情况下安装和使用ZF(及其控制台工具)?我尝试将... Zend/library direcotry添加到include_path中,但没有成功.

Is it possible to install and use ZF (+ its console tool) without access to include_path direcotory? I've tried adding the ...Zend/library direcotry into include_path but without success.

我是这样做的:

php -r 'set_include_path(get_include_path() . PATH_SEPARATOR . "/var/www/.../Zend/library")';

在上面的函数的结果var_dump之后,它返回了旧的include_path,这应该表示成功.但是下一次对get_include_path()的调用也返回了 old 路径.

After var_dumping result of the function above it returned old include_path which should mean success. But next call of get_include_path() returned the old path too.

我还尝试设置环境变量:

I've also tried to set the environment variable:

ZF_INCLUDE_PATH_PREPEND="/var/www/.../Zend/library"

在旧的include_path目录中有我们的公司框架,因此我无法(即使我不应该)复制ZF库.

There is our company framework in the old include_path directory so I can't (even if I could I should't) copy there the ZF library.

我认为适当的框架不应像include_path那样依赖任何全局PHP设置.我认为应该可以在ZF内部配置文件中的某个位置设置包含路径.

I think a proper framework shouldn't rely on any global PHP settings as include_path is. I think it should be possible to set the include path somewhere in ZF internal configuration file.


我将set_include_path('/var/www/.../Zend/library')添加到zf.php文件中,该工具停止抛出错误的include_path"错误.实际上,它停止打印任何输出.当执行命令zf create project test时,它什么也不做. 〜/.zf文件夹未创建.

edit:
I added set_include_path('/var/www/.../Zend/library') into zf.php file and the tool stopped throwing 'wrong include_path' error. In fact it sopped printing any output. When executing command zf create project test it does nothing. ~/.zf folder wasn't created.

推荐答案

如果您无法在某些全局"包含路径中复制zf库,例如/usr/share/php/,您仍然可以将其复制到项目所在的位置,然后从此处启动zf工具.文件夹结构,如:

If you can't copy the zf library in some "global" include path, e.g. /usr/share/php/, you can still copy it where your project is and start the zf tool from there. A folder structure like:

/var/www/zf_tool
                `/bin/
                      `zf.sh
                      `zf.php
                `/library
                      `/Zend

复制库下的Zend文件夹以及bin下的zf.shzf.php脚本,并将它们设置为可执行文件chmod a+x zf.sh zf.php(如果尚未执行). 接下来,如果您运行/var/www/project/bin/zf.sh,它将在include_path中查找zf文件,但是如果不存在,它将在一个文件夹中进入library文件夹.只有在zf库中找不到该库时,它才会因错误而死亡.最后,创建一个新的zf项目很简单:

Copy the Zend folder under library, and the zf.sh and zf.php scripts under bin and set them to be executable chmod a+x zf.sh zf.php if they are not already. Next, if you run /var/www/project/bin/zf.sh it'll look for zf files in the include_path, but if it's not there, it'll go up one folder and go into the library folder. Only if the zf library is not to be found there, it'll die with an error. In the end, creating a new zf project is simple as:

$ pwd
/var/www/zf_tool/bin
$ ./zf.sh create project /var/www/test_project

就是这样. HTH:)

That's it. HTH :)

这篇关于Zend工具包含路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆