简体   繁体   English

Zend工具包含路径

[英]Zend tool include path

Is it possible to install and use ZF (+ its console tool) without access to include_path direcotory? 是否可以在不访问include_path目录的情况下安装和使用ZF(及其控制台工具)? I've tried adding the ...Zend/library direcotry into include_path but without success. 我尝试将... Zend / library direcotry添加到include_path中,但没有成功。

I did it this way: 我这样做是这样的:

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

After var_dump ing result of the function above it returned old include_path which should mean success. 在上面函数的var_dump结果之后,它返回了旧的include_path,这应该意味着成功。 But next call of get_include_path() returned the old path too. 但是下一次对get_include_path()的调用也返回了路径。

I've also tried to set the environment variable: 我也尝试设置环境变量:

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

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目录中有我们公司的框架,因此我无法(即使我不能)将ZF库复制到那里。

I think a proper framework shouldn't rely on any global PHP settings as include_path is. 我认为适当的框架不应像include_path那样依赖任何全局PHP设置。 I think it should be possible to set the include path somewhere in ZF internal configuration file. 我认为应该可以在ZF内部配置文件中的某个位置设置包含路径。

edit: 编辑:
I added set_include_path('/var/www/.../Zend/library') into zf.php file and the tool stopped throwing 'wrong include_path' error. 我将set_include_path('/var/www/.../Zend/library')到zf.php文件中,该工具停止抛出“错误的include_path”错误。 In fact it sopped printing any output. 实际上,它停止打印任何输出。 When executing command zf create project test it does nothing. 当执行命令zf create project test它什么也不做。 ~/.zf folder wasn't created. 尚未创建〜/ .zf文件夹。

If you can't copy the zf library in some "global" include path, eg /usr/share/php/ , you can still copy it where your project is and start the zf tool from there. 如果您无法在某些“全局”包含路径中复制zf库,例如/usr/share/php/ ,则仍可以将其复制到项目所在的位置,然后从此处启动zf工具。 A folder structure like: 文件夹结构如下:

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

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. 复制库下的Zend文件夹,以及bin下的zf.shzf.php脚本,并将它们设置为可执行的chmod a+x zf.sh zf.php如果尚未执行)。 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. 接下来,如果您运行/var/www/project/bin/zf.sh它将在include_path中查找zf文件,但是如果不存在,它将在一个文件夹中进入library文件夹。 Only if the zf library is not to be found there, it'll die with an error. 只有在zf库中找不到该库时,它才会因错误而死亡。 In the end, creating a new zf project is simple as: 最后,创建一个新的zf项目很简单:

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

That's it. 而已。 HTH :) HTH :)

Using he set/get include_path functions is only going to set it for the life of the "request" so it goes back to normal as soon as the command/web request finishes. 使用他的set / get include_path函数只会在“请求”的生命周期内进行设置,因此一旦命令/ Web请求完成,它就会恢复正常。 As far as setting the include path for your local copy you can do that in an environment variable as you tried or in your ~/.zf folder on the box. 至于设置本地副本的包含路径,您可以在尝试的环境变量中或在框上的~/.zf文件夹中进行设置。 there are configs in there and there is a setting cor include path. 那里有配置,并且有一个设置cor包含路径。

Beyond that you could also ad something like what you had in the php -r ... to the shell script youre executing directly although this wouldnt be the recommended way. 除此之外,您也可以将类似于php -r ...到您直接执行的shell脚本中,尽管这不是推荐的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM