Vinee
Vinee

Reputation: 1654

How to append content in file using symfony2 Filesystem?

As question is self explanatory. And very common but how can i do with the help of symfony2 components (Filesystem).

I do not see read function in filesystem.

After lot of googles, I could not fine. Please help!

Upvotes: 5

Views: 10623

Answers (2)

Hyunmin Kim
Hyunmin Kim

Reputation: 971

There is no function in Symfony2's Filesystem component that appends content to a file. Just use php's built in function:

file_put_contents($file, $content, FILE_APPEND);

PHP Documentation on file_put_contents

Symfony2 API for FileSystem Component

EDIT:

Since Symfony 3.3, it is possible to append content in file:

$fs = new Filesystem();
$fs->appendToFile('logs.txt', 'Email sent to [email protected]');

Symfony Filesystem Component

Upvotes: 10

Nicolas
Nicolas

Reputation: 414

Since Symfony 3.3, it is possible to append content in file:

$fs = new Filesystem();
$fs->appendToFile('logs.txt', 'Email sent to [email protected]');

Symfony Filesystem Component

Upvotes: 2

Related Questions