Skip to content

Commit

Permalink
[Filesystem] Document the readFile() method
Browse files Browse the repository at this point in the history
  • Loading branch information
javiereguiluz committed Mar 19, 2024
1 parent 438031c commit 742b2cc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions components/filesystem.rst
Expand Up @@ -313,6 +313,22 @@ contents at the end of some file::
If either the file or its containing directory doesn't exist, this method
creates them before appending the contents.

``readFile``
~~~~~~~~~~~~

.. versionadded:: 7.1

The ``readFile()`` method was introduced in Symfony 7.1.

:method:`Symfony\\Component\\Filesystem\\Filesystem::readFile` returns all the
contents of a file as a string. Unlike the :phpfunction:`file_get_contents` function
from PHP, it throws an exception when the given file path is not readable and
when passing the path to a directory instead of a file::

$contents = $filesystem->readFile('/some/path/to/file.txt');

The ``$contents`` variable now stores all the contents of the ``file.txt`` file.

Path Manipulation Utilities
---------------------------

Expand Down

0 comments on commit 742b2cc

Please sign in to comment.