You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a symfony php command where the parameter expects to send a csv file path. I would like to create a csv in a custom path using VFSStream. How is it possible to achieve this please ?
I can see when I create a csv file in the root directory. I see vfs embed path like this vfs:/root/foo.csv.
Instead of the above path, I would like to create foo.csv in a custom local directory.
Thanks alot.
The text was updated successfully, but these errors were encountered:
jmdeepak007git
changed the title
Create csv file to custom path in VFS
Create CSV file in the custom path using VFS
Sep 6, 2021
$root = vfsStream::setup('my_folder'); // <-- give a custom name for "root"echo$root->url();
// vfs://my_folder
However, once that php process exits that file no longer exists. If you're trying to run a symfony command like bin/console some:command vfs://path/to/some.csv it's not going to work.
If you're creating the file in-memory within the command, you don't need vfs for that.
// write CSV to memory$fh = fopen('php://temp', 'w+');
fputcsv($fh, ['a', 'b', 'c']);
fputcsv($fh, ['1', '2', '3']);
// rewind to start of filerewind($fh);
// read the file and do whatever you want with the datawhile (($data = fgetcsv($fh, 1000, ",")) !== false) {
var_dump($data);
}
fclose($fh);
HI Guys,
I have a symfony php command where the parameter expects to send a csv file path. I would like to create a csv in a custom path using VFSStream. How is it possible to achieve this please ?
I can see when I create a csv file in the root directory. I see vfs embed path like this vfs:/root/foo.csv.
Instead of the above path, I would like to create foo.csv in a custom local directory.
Thanks alot.
The text was updated successfully, but these errors were encountered: