Bug #50130

Different fallback for php.exe on windows

Added by Christian Müller over 6 years ago. Updated over 6 years ago.

Status:
Needs Feedback
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2013-07-17
Due date:
% Done:

0%


Description

It could make sense on windows (as a fallback) to try to find the php.exe in the same path as the php.ini file. Seems usual setups on windows are like that (binary download from php.net and XAMPP). Should be checked with Windows users. Could reduce entry hurdle for windows users.

History

#1 Updated by Christian Müller over 6 years ago

Just trying php.exe and relying on the PATH could also be an option.

#2 Updated by Christian Müller over 6 years ago

Some ideas from the chat, not mine...

diff --git a/Classes/TYPO3/Flow/Core/Booting/Scripts.php b/Classes/TYPO3/Flow/Core/Booting/Scripts.php
index e15d06a..28e1d6e 100644
--- a/Classes/TYPO3/Flow/Core/Booting/Scripts.php
+++ b/Classes/TYPO3/Flow/Core/Booting/Scripts.php
@@ -567,6 +567,15 @@
             $phpBinaryPathAndFilename = '"' . escapeshellcmd(\TYPO3\Flow\Utility\Files::getUnixStylePath($settings['core']['phpBinaryPathAndFilename'])) . '"';
         } else {
             $phpBinaryPathAndFilename = escapeshellarg(\TYPO3\Flow\Utility\Files::getUnixStylePath($settings['core']['phpBinaryPathAndFilename']));
+            if(!is_readable($phpBinaryPathAndFilename)){
+                // try to find on ini path, windows default
+                $iniPathInfo = pathinfo(php_ini_loaded_file());
+                $phpBinaryPathAndFilename = escapeshellarg(\TYPO3\Flow\Utility\Files::getUnixStylePath($iniPathInfo['dirname'].DIRECTORY_SEPARATOR.'php'));
+                if(!is_readable($phpBinaryPathAndFilename)){
+                    // fallback to system path
+                    $phpBinaryPathAndFilename = escapeshellarg(\TYPO3\Flow\Utility\Files::getUnixStylePath('php'));
+                }
+            }
         }
         $command .= $phpBinaryPathAndFilename;
         if (!isset($settings['core']['subRequestPhpIniPathAndFilename']) || $settings['core']['subRequestPhpIniPathAndFilename'] !== FALSE) {

#3 Updated by Christian Müller over 6 years ago

if(!is_readable($phpBinaryPathAndFilename))

should probably be: or something like that

if(!is_readable(substr($phpBinaryPathAndFilename,1,-1)))

Also available in: Atom PDF