Problem with Two vendor/autoload.php in same projects at root level and inside a specific folder
I am running two different scenarios for my problem in a project. Frontend is all handled by Laravel. But for file uploads via FTP, I need to run some PHP scripts for the uploaded files. Inside my project root /var/www, I made a folder called scripts that has a bash script called monitor.sh. This bash script makes a php command call to a php script. I have another composer.json file in this directory. This means to say that I have two composer.json files, one at root level and other at the children directory which is scripts folder in my case. So, when there is file upload event trigger, I run the php script inside scripts folder.
Under this scenario, my php script includes the Intervention Image Library as:
require_once 'vendor/autoload.php';
use Intervention\Image\ImageManagerStatic as Image;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;
Image::configure(array('driver' => 'imagick'));
.....
If I run the php scripts from php cli, I don't have any issues in running the code. But when I call the php script from bash script, Fatal Error:
Read Exception `/var/www/storage/app/public/raw_image/image.png' @ error/png.c/MagickPNGErrorHandler/1643
So, I changed the memory_limit config in php.ini file for php cli from -1 to 128MB and I got another error:
Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 524288 bytes) in /var/www/vendor/composer/autoload_classmap.php on line 2051
At this point, I notice that the autoload file being used is from the root folder. Am I violating how autoload works?
Please or to participate in this conversation.