Any reason not to make heavy use of PHP's exec()?
If I control the server environment and filter out harmful injections, any reason why I shouldn't exec( 'mkdir '.$perm.' '.$name ) in PHP?
And rather than using php GD, can I not use exec('mogrify -resize '.$width.' '.$myfile) ?
And for almost any other file-system/file-manipulation operation, can I not use command-line via exec and parse the result? Am I being n00开发者_运维知识库b?
I have to write some thumbnailing/resizing logic (again!!!!), and will gladly take a shortcut if I see one - providing it's not a mouse trap...
Well, one big argument against this is that you make the script more dependent on the underlying system. It won't be as easy to port it to another server that doesn't have ImageMagick, or runs Windows where the command line commands look different.
Other than that, I'd say there is nothing fundamentally wrong with it. If IM is available, I'd gladly use that for resize operations.
Note that there is a PHP extension featuring an interface to IM as well.
On UNIX exec() will make a fork of the initiating process, such as apache, which is a costly OS action.
精彩评论