在哪里设置原始数据文件夹
where to set the original data folder
我有 symfony4 项目。
我需要处理一些csv文件,所以我在主目录下创建了myAppCsv文件夹。
protected function execute(InputInterface $input, OutputInterface $output)
{
$finder = new Finder();
$finder->in(array('myAppCsv'));
然后我通过这样的命令访问文件夹。
$ php bin/console app:getcsv
在主目录中执行时效果很好。
现在,我想从命令行使用相同的命令(测试 crontab)
/usr/local/bin/php /Users/whitebear/httproot/myApp/bin/console app:getcsv
显示错误。
The "myAppCsv" directory does not exist.
我应该把我的原始数据目录和hw放在哪里??
您可以将路径指定为绝对路径。您可以使用 __DIR__
contant 或 kernel.root_dir
参数。
我更喜欢使用 kernel.root_dir
,以防您必须将命令移动到另一个文件夹中。
您将拥有文件夹的绝对路径,例如:
$finder->in(
array(
sprintf('%s/../myAppCsv', $this->rootDir)
)
);
从依赖注入或容器获取 rootDir
我有 symfony4 项目。
我需要处理一些csv文件,所以我在主目录下创建了myAppCsv文件夹。
protected function execute(InputInterface $input, OutputInterface $output)
{
$finder = new Finder();
$finder->in(array('myAppCsv'));
然后我通过这样的命令访问文件夹。
$ php bin/console app:getcsv
在主目录中执行时效果很好。
现在,我想从命令行使用相同的命令(测试 crontab)
/usr/local/bin/php /Users/whitebear/httproot/myApp/bin/console app:getcsv
显示错误。
The "myAppCsv" directory does not exist.
我应该把我的原始数据目录和hw放在哪里??
您可以将路径指定为绝对路径。您可以使用 __DIR__
contant 或 kernel.root_dir
参数。
我更喜欢使用 kernel.root_dir
,以防您必须将命令移动到另一个文件夹中。
您将拥有文件夹的绝对路径,例如:
$finder->in(
array(
sprintf('%s/../myAppCsv', $this->rootDir)
)
);
从依赖注入或容器获取 rootDir