PHPThumb icon indicating copy to clipboard operation
PHPThumb copied to clipboard

Use Symfony\Filesystem for file operations

Open nettles-jarrod opened this issue 12 years ago • 8 comments

This has been on my mind for some time but this issue brought it to my attention a little harder. The issue is for the 1.0 branch but it effects 2.0 as well.

Instead of rolling our own filesystem code, I propose use a library specifically designed to handle these sorts of things. That way PHPThumb is focused on images, and not filesystem operations.

Also, abstracting out our operations will allow us to mock those operations, enhancing our unit testing capabilities.

nettles-jarrod avatar Mar 10 '13 06:03 nettles-jarrod

For the amount of filesystem operations this library does I'm not sure requiring another library would be beneficial. Wouldn't SplFileInfo and SplFileObject work instead? http://www.php.net/manual/en/spl.files.php

mikealmond avatar Mar 28 '13 17:03 mikealmond

Yeah. After digging in and using it a couple weeks ago I realized that Symfony\Filesystem doesn't really buy us that much. We can drop it as a dependency.

nettles-jarrod avatar Mar 28 '13 22:03 nettles-jarrod

Then why it hasn't been dropped yet?...

This is a nice light-weight image lib (just what i was looking for), but now I must alter it to use. It's completely unnecessary to bring in a lib dependence for a single file existence check.

okaresz avatar Oct 12 '13 10:10 okaresz

Yup. Which is why we said we'll drop it. Feel free to submit a pull request if you have time to work on it.

nettles-jarrod avatar Oct 12 '13 17:10 nettles-jarrod

I have same problem with the thing. I think phpthumb should use is_file instead of symfony filesystem. Why you don't use built-in function, that is better ?

ghost avatar Jan 23 '14 04:01 ghost

Again, feel free to submit a pull request fixing this. I don't have time to work on this library anymore. :(

nettles-jarrod avatar Jan 23 '14 13:01 nettles-jarrod

A pull request for three lines of changes?

Here are the changes to make it easy: in PHPThumb.php:

remove line 62.

change what is now line 91 to read: if(file_exists($filename)) { instead of if($this->filesystem->exists($filename)) {

Remove the requirement from Composer.json.

ghost avatar Jun 11 '14 20:06 ghost

I created a pull request #127

cogentParadigm avatar Sep 06 '15 02:09 cogentParadigm