I created a script that I run off a CSV of which I manipulate the data and create a new CSV (for imports through magmi).
When I run it through the command line it goes without a hitch.
I then proceeded to create a custom module on my magento site to allow the client to upload the csv from the admin.
I then have a controller that moves the uploaded file to my script and proceed to call shell_exec which I assumed would be doing exactly what I did when running from the command line.
Instead i got the following error
PHP Fatal error: Call to undefined function snappy_uncompress() in /chroot/home/mywebsite.com/html/lib/Cm/Cache/Backend/Redis.php on line 888
I believe this is due to the fact that my script is loading Mage.
This is my controller:
public function postAction(){
if($_POST){
//Get target directory and file name
$upOne = substr(getcwd(), 0, strrpos( getcwd(), '/') );
$targetDir = $upOne . '/MyScriptDirectory/';
$targetFile = $_FILES['myFile']['name'];
//Upload file
if (move_uploaded_file($_FILES['myFile']['tmp_name'], $targetDir . $targetFile)) {
// Mage::getSingleton('core/session')->addSuccess('Success');
} else {
Mage::getSingleton('core/session')->addError('Failed to upload file');
}
//Run script with $targetFile as argument
exec ( "cd SunberryImport/ && php main.php " . $targetFile. " 2>&1",$output, $val );
//Get output and print to screen
Mage::getSingleton('core/session')->addError(implode($output));
}
$this->loadLayout();
$this->renderLayout();
}
When I moved my script within the magento application and stopped loading mage within the script I no longer got that error.
I rather keep my script separate from the main application.
Is the problem due to running mage twice in the same php session?
Sorry if I'm not being clear I'm new to both magento and this is my first Magento stack overflow question.