2015-08-24 31 views
7

Kabuk (shell_exec) aracılığıyla PHP'de PDF oluşturmak için phantomJS kullanıyorum. Komut, üretim sunucusunda gayet iyi çalışıyor ve PhantomJS komutunu doğrudan terminalime bağlarsam iyi çalışıyor.Boş sayfa döndüren PhantomJS komut dosyası

Ancak yerel dev ortamımda komut dosyasını çalıştırdığımda çalışmaz. İlgili bir izin sorunu olup olmadığını merak ediyorum.

/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: Ben

... şimdi bu üst düzey bir konudur tahmin ediyorum çünkü benim yerel çevre özelliklerini inceleyeceğiz shell_exec() aracılığıyla yürütmek gerekiyordu komutu dalış olmaz

php kodu:

public function pdfResponse($url, $script, $remote_filename) 
{ 
    $tempFile = tempnam('/tmp', 'pjs'); 
    // The extension specifies output format. Use pdf 
    $tempFilePdf = $tempFile . '.pdf'; 
    rename($tempFile, $tempFilePdf); 

    # nginx should restrict access to the 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; 
} 
+1

Aynı sürümleri yüklediniz mi? Lütfen "onConsoleMessage", "onError", "onResourceError", "onResourceTimeout" olaylarına kayıt olun ([Örnek] (https://gist.github.com/artjomb/4cf43d16ce50d8674fdf)). Belki de hatalar vardır. –

+0

$ $ değerinin günlüğünü kaydetmeyi denediniz mi? – VolenD

+0

@ user3584460 $ output false olarak değerlendirildi, bu yüzden sorun bu değil –

cevap

1

farklı bir versiyonu olduğu ortaya çıktı phantomjs prod sunucusunda yerel olarak yüklendi. İlginç bir şekilde, hata daha yeni sürüm (2.0.0) ile 1.9.8 arasında gerçekleşti.

+2

Kendi yanıtınızı kabul edildi olarak işaretlemelisiniz, böylece cevapsız listede görünmeyecektir. –

İlgili konular