在php交互式shell中使用作曲家添加的依赖项

问题描述 投票:1回答:2

我试图在php shell中使用我的作曲家添加的依赖项,但它不起作用。

我正在使用这个要点[https://gist.github.com/gigorok/5ca39384635113495796]

php -a -d auto_prepend_file=./vendor/autoload.php

我试图跑,同样的:

use Carbon\Carbon;
Carbon::parse('today');

在这一行后我得到:PHP警告:未捕获错误:在PHP shell代码中找不到类'Carbon':1

值得注意的是,我有一个运行的codecept测试,它使用具有相同使用声明的Carbon并且它们可以工作。

php composer-php
2个回答
0
投票

正如PHP documentation中所述,自动加载在交互式shell中不起作用:

如果在CLI交互模式下使用PHP,则无法进行自动加载


-1
投票

这可能有所帮助。

cd /your/application/dir
rm bootstrap/compiled.php
rm -rf vendor
composer install --no-dev
© www.soinside.com 2019 - 2024. All rights reserved.