@@ -6,6 +6,10 @@ The Filesystem Component
6
6
7
7
The Filesystem components provides basic utilities for the filesystem.
8
8
9
+ .. versionadded :: 2.1
10
+ The Filesystem Component is new to Symfony 2.1. Previously, the ``Filesystem ``
11
+ class was located in the ``HttpKernel `` component.
12
+
9
13
Installation
10
14
------------
11
15
@@ -40,40 +44,37 @@ endpoint for filesystem operations::
40
44
:method: `Symfony\\ Component\\ Filesystem\\ Filesystem::remove ` and
41
45
:method: `Symfony\\ Component\\ Filesystem\\ Filesystem::touch ` can receive a
42
46
string, an array or any object implementing :phpclass: `\\ Traversable ` as
43
- target argument.
47
+ the target argument.
44
48
45
49
46
50
Mkdir
47
51
~~~~~
48
52
49
53
Mkdir creates directory. On posix filesystems, directories are created with a
50
- default mode value `0777 `. You can use the second argument to set your own mode.
54
+ default mode value `0777 `. You can use the second argument to set your own mode::
51
55
52
56
$fs->mkdir('/tmp/photos', 0700);
53
57
54
-
55
58
.. note ::
56
59
57
- You can pass an array or any :phpclass: `\\ Traversable ` object as the first
60
+ You can pass an array or any :phpclass: `Traversable ` object as the first
58
61
argument.
59
62
60
-
61
63
Exists
62
64
~~~~~~
63
65
64
- Exists checks the presence of all files or directories and return false if a
65
- file is missing.
66
+ Exists checks for the presence of all files or directories and returns false if a
67
+ file is missing::
66
68
67
69
// this directory exists, return true
68
70
$fs->exists('/tmp/photos');
69
71
70
72
// rabbit.jpg exists, bottle.png does not exists, return false
71
- $fs->exists(array('rabbit.jpg', 'bottle.png));
72
-
73
+ $fs->exists(array('rabbit.jpg', 'bottle.png'));
73
74
74
75
.. note ::
75
76
76
- You can pass an array or any :phpclass: `\\ Traversable ` object as the first
77
+ You can pass an array or any :phpclass: `Traversable ` object as the first
77
78
argument.
78
79
79
80
Copy
@@ -89,11 +90,10 @@ behavior can be overridden by the third boolean argument::
89
90
// image.jpg will be overridden
90
91
$fs->copy('image-ICC.jpg', 'image.jpg', true);
91
92
92
-
93
93
Touch
94
94
~~~~~
95
95
96
- Touch sets access and modification time to a file. The current time is used by
96
+ Touch sets access and modification time for a file. The current time is used by
97
97
default. You can set your own with the second argument. The third argument is
98
98
the access time::
99
99
@@ -104,10 +104,9 @@ the access time::
104
104
// set access time 10 seconds in the past
105
105
$fs->touch('file.txt', time(), time() - 10);
106
106
107
-
108
107
.. note ::
109
108
110
- You can pass an array or any :phpclass: `\\ Traversable ` object as the first
109
+ You can pass an array or any :phpclass: `Traversable ` object as the first
111
110
argument.
112
111
113
112
Chown
@@ -121,10 +120,9 @@ recursive option::
121
120
// change the owner of the video directory recursively
122
121
$fs->chown('/video', 'www-data', true);
123
122
124
-
125
123
.. note ::
126
124
127
- You can pass an array or any :phpclass: `\\ Traversable ` object as the first
125
+ You can pass an array or any :phpclass: `Traversable ` object as the first
128
126
argument.
129
127
130
128
Chgrp
@@ -141,7 +139,7 @@ recursive option::
141
139
142
140
.. note ::
143
141
144
- You can pass an array or any :phpclass: `\\ Traversable ` object as the first
142
+ You can pass an array or any :phpclass: `Traversable ` object as the first
145
143
argument.
146
144
147
145
Chmod
@@ -155,10 +153,9 @@ recursive option::
155
153
// change the mod of the src directory recursively
156
154
$fs->chmod('src', 0700, true);
157
155
158
-
159
156
.. note ::
160
157
161
- You can pass an array or any :phpclass: `\\ Traversable ` object as the first
158
+ You can pass an array or any :phpclass: `Traversable ` object as the first
162
159
argument.
163
160
164
161
Remove
@@ -168,7 +165,6 @@ Remove let's you remove files, symlink, directories easily::
168
165
169
166
$fs->remove(array('symlink', '/path/to/directory', 'activity.log'));
170
167
171
-
172
168
.. note ::
173
169
174
170
You can pass an array or any :phpclass: `\\ Traversable ` object as the first
@@ -177,7 +173,7 @@ Remove let's you remove files, symlink, directories easily::
177
173
Rename
178
174
~~~~~~
179
175
180
- Rename is used to rename file and directories::
176
+ Rename is used to rename files and directories::
181
177
182
178
//rename a file
183
179
$fs->rename('/tmp/processed_video.ogg', '/path/to/store/video_647.ogg');
@@ -187,8 +183,8 @@ Rename is used to rename file and directories::
187
183
symlink
188
184
~~~~~~~
189
185
190
- Create a symbolic link from target to destination. If the filesystem does not
191
- support symbolic links, a third boolean argument is available::
186
+ Creates a symbolic link from the target to the destination. If the filesystem
187
+ does not support symbolic links, a third boolean argument is available::
192
188
193
189
// create a symbolic link
194
190
$fs->symlink('/path/to/source', '/path/to/destination');
@@ -229,11 +225,10 @@ isAbsolutePath returns true if the given path is absolute, false otherwise::
229
225
Error Handling
230
226
--------------
231
227
232
- Whenever something wrong happends, a :phpclass: `\\ RuntimeException ` is thrown.
233
-
228
+ Whenever something wrong happens, a :phpclass: `RuntimeException ` is thrown.
234
229
235
230
.. note ::
236
231
237
232
Prior to version 2.1, :method: `Symfony\\ Component\\ Filesystem\\ Filesystem::mkdir `
238
- was returning a boolean and did not throw exceptions. As of 2.1, a
239
- :phpclass: `\\ RuntimeException ` is thrown if a directory creation fails.
233
+ returned a boolean and did not throw exceptions. As of 2.1, a
234
+ :phpclass: `RuntimeException ` is thrown if a directory creation fails.
0 commit comments