I have a weird problem that is driving me crazy these days

I have a command line using mogrify (for example but it is the same with compose or convert or so).
This command line works perfectly if I enter it manually in the console. It also works if I put it in a php file (using exec() function) and then run manually "php my_file.php" but If I try to "execute" this php file through MAMP server, it seems that I get no error but absolutely nothing is done on my image ...
I tried to put the "hard path" in front of each executable (for example /opt/local/bin/mogrify instead of just mogrify) and also in front of the image file but it does not change ...
If anybody has any idea I would be grateful !
thanks and have a nice day.