php - shell_exec() command not working locally -
i'm trying run shell command via php. interestingly, script works fine on production server , works when plug in command shell manually. shell_exec() command not work in local dev. environment on os x - returns blank web page instead of pdf supposed generated.
i won't dive specifics of local env. since i'm guessing high-level issue...
the command supposed execute via shell_exec() looks like:
/usr/local/bin/phantomjs --ignore-ssl-errors=true --debug=true ../scripts/renderteamprofile.js https://127.0.0.1/app_dev.php/pdf/enterprise-lpc-enterprise/profile/render /private/var/tmp/pjsk2n16e.pdf
the php:
public function pdfresponse($url, $script, $remote_filename) { $tempfile = tempnam('/tmp', 'pjs'); $tempfilepdf = $tempfile . '.pdf'; rename($tempfile, $tempfilepdf); # nginx should restrict access localhost url $urllocal = preg_replace('/^https:..[^\/]+/', 'https://127.0.0.1', $url); $phantomjs = $this->container->getparameter('testsite.phantomjs_cmd'); $command = $phantomjs.' --debug=true '.$script.' '.$urllocal.' '.$tempfilepdf; $output = shell_exec($command); $content = file_get_contents($tempfilepdf); $response = new response($content, 200); $response->headers->set('content-type', 'application/pdf'); $response->headers->set('content-disposition', ('inline; filename="' . $remote_filename . '"')); return $response; }
Comments
Post a Comment