# pdflatex fails in some cases silently when called by php

I'd like to generate a PDF file based on some inputs of an HTML-form. As I also need to append further PDF-files to this document, that may have been attached to the form I decided on using LaTeX to do the job (as most php-based tools fail with PDF-files >v1.4).

I started with this example (https://github.com/mike42/web-pdf) to work and adopted minimal changes to it (primarily I settled on pdflatex instead of xelatex as the pdfpages-package seems to require pdflatex to work).

While this works on my local development environment (xampp), on the server however it fails silently and I cannot detect why. For testing, whether I can get pdflatex at least to compile something I am using the following working example (got it from here -> https://gist.github.com/Michael0x2a/e46e12a66b7dc604db5e):

\documentclass{article}
\usepackage[utf8]{inputenc}

\begin{document}

Name, date, Exercise X

\section*{Part a}

\section*{Part b}

etc

\end{document}


I have tested for given rights to read and write files as well as proved for pdflatex being basically working (e.g. -version and -help give expected results). But when trying to compile a tex-file the console output is completly empty (not even the greeting "This is pdftex..."), no files are created, the file pdflatex.log doesn't contain anything regarding this issue, I only get the exit code 1 (I've tried xelatex once and got basically the same, except for the exit code this time being 127). When using pdflatex right on the server, using the same user who would access it via php, it works as expected.

I am using pdfTeX 3.14159265-2.6-1.40.19 distributed by TeX Live 2019 on a Debian System.

Thanks to this question (latex compilation via php's shell_exec) I tried calling pdflatex starting from root (i.e. my command is /usr/bin/pdflatex now).
• Probably an issue with the PATH. Exit code 127 definitely indicates it couldn't find the command. Exit code 1 is definitely a mystery, but if you're curious you could try adding 2>&1 to capture stderr as well in the return value of shell_exec and see what it was. Then again, if it works with the full path, it works. Apr 28 at 16:12