Skip to content

Commit

Permalink
minor #19689 [Filesystem] Document the readFile() method (javiereguiluz)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 7.1 branch.

Discussion
----------

[Filesystem] Document the readFile() method

Fixes #19680.

Commits
-------

742b2cc [Filesystem] Document the readFile() method
  • Loading branch information
javiereguiluz committed Mar 19, 2024
2 parents 438031c + 742b2cc commit 6fb8d69
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 6fb8d69

Please sign in to comment.