【发布时间】:2013-08-21 04:26:54
【问题描述】:
我有一个项目,我使用 Composer 并通过它导入很多东西...我需要在我的索引(项目的根目录)中使用 autoload.php,并且 istead Slim、Mongo、Twig 工作得很好。但是当我调用一个 Respect/Validation 类时它不起作用;如果我只是使用尊重/验证,错误是:
Class 'Respect\Validation\Validator' not found in (path of file when i need it).
如果我尝试在这里也需要 autoload.php 错误是:
**Warning**: require_once(vendor/autoload.php): failed to open stream: No such file or directory in (path of file when i need it)
**Fatal error**: require_once(): Failed opening required 'vendor/autoload.php' (include_path='.;C:\xampp\php\PEAR') in (path of file when i need it)
【问题讨论】:
-
我已经在 Composer/bin 中通过 cmd... dir=$(d=$(dirname "$0"); cd "$d" $$ pwd) if command -v 'cygpath ' >/dev/null 2>&1;然后 dir=$(cygpath -m $dir); fi dir=$(echo $dir | sed 's/ /\ /g') php "${dir}/composer.phar" $* –
-
您是否尝试过以您需要的相对方式包含文件 autoload.php?
-
我试过了,就像我说的那样,我说 autoload.php 找不到文件,但是如果我只留下“使用”告诉我,告诉我找不到 Validator 类。
-
您需要
require_once('../../../../vendor/autoload.php')。这样包含你需要的文件。
标签: php dependencies composer-php respect-validation