Closed taufik-nurrohman closed 3 years ago
purge()
for recursive file delete?
Look like it is okay to use delete
:
There is no delete keyword or function in the PHP language. If you arrived at this page seeking to delete a file, try
unlink()
. To delete a variable from the local scope, check outunset()
.
So, the CRUD functions proposal would be:
delete()
move()
paste()
push()
function below)save()
seal()
content()
function should be read only after this, as create task will be managed by save()
.
Need a replacement for File::push()
. push()
is not the candidate here as File::pull()
accept private file path, while File::push()
accept $_FILES
array.
Maybe store()
would be appropriate.
However, push()
is still considered useful, as if it can accept either private file path or a public file URL. If it uses private file path, it will behaves like PHP copy()
function with the benefit of automatic folder creation if it does not exist. If it uses public file URL, it will behaves like PHP curl()
that stores the result to the server (e.g. can be used to make an upload functionality with URL input).
File
class and its derivative classes such asPage
,Tag
andUser
should be read-only. This also includes theFolder
class.I realized that native PHP functions aren’t that bad. Adding and removing files/folders using native PHP functions should increase the performance.
file_get_contents()
andfile_put_contents()
are quite common. Even, we have the short function equivalent namedcontent()
. Thecontent()
function should be enough to do a quick CRUD task. The missing functions in my opinion are:File::exist()
andFolder::exist()
may be replaced by theexist()
function.touch()
with adaptive mode input (e.g. can accept octal number in string format captured from form data). This can be replaced with a new function, probably I will give a name to itpoke()
orseal()
.unlink()
that can remove folder with its contents. This should be replaced with a new function. But I don’t have any idea about the function name for this kind of task. As I know,delete
keyword is not reserved in PHP, and there is no PHP function nameddelete()
. But I am still not sure. This name is too generic that probably, in the future, PHP would propose a native function nameddelete()
anyway.