Reputation: 12455
I have symfony4 project.
I need to handle some csv file, so I made myAppCsv folder under the main directory.
protected function execute(InputInterface $input, OutputInterface $output)
{
$finder = new Finder();
$finder->in(array('myAppCsv'));
then I access folder from command like this.
$ php bin/console app:getcsv
it works well when you exec in main directory.
Now, I want to use the same command from commandline (test for crontab)
/usr/local/bin/php /Users/whitebear/httproot/myApp/bin/console app:getcsv
it shows error.
The "myAppCsv" directory does not exist.
Where should I put my original data directory and hw to handle??
Upvotes: 0
Views: 45
Reputation: 1879
You can specify the path as absolute. You can use __DIR__
contant or kernel.root_dir
parameter.
I prefer using the kernel.root_dir
in case you have to move the command in another folder.
You will have the absolute path to the folder, for example, something like:
$finder->in(
array(
sprintf('%s/../myAppCsv', $this->rootDir)
)
);
With rootDir getting from dependency injection or container
Upvotes: 1