Subject: bug#76955: 30.1; php-ts-mode-php-executable default path may not match remote path

From: Vincenzo Pupillo <[email-masked]>
Date: Fri, 14 Mar 2025 21:29:20 +0100

Ciao Eli, the patch is attached.

Thanks

Vincenzo

In data giovedì 13 marzo 2025 20:28:14 Ora standard dell’Europa centrale, Eli 
Zaretskii ha scritto:
> > From: Morgan Willcock <[email-masked]>
> > Cc: [email-masked],  [email-masked]
> > Date: Thu, 13 Mar 2025 17:43:11 +0000
> > 
> > Eli Zaretskii <[email-masked]> writes:
> > >> From: Morgan Willcock <[email-masked]>
> > >> Cc: Eli Zaretskii <[email-masked]>,  [email-masked]
> > >> Date: Thu, 13 Mar 2025 16:45:04 +0000
> > >> 
> > >> Vincenzo Pupillo <[email-masked]> writes:
> > >> > In data giovedì 13 marzo 2025 15:25:57 Ora standard dell’Europa
> > >> > centrale, Eli> >> > 
> > >> > Zaretskii ha scritto:
> > >> >> > From: Vincenzo Pupillo <[email-masked]>
> > >> >> > Cc: [email-masked]
> > >> >> > Date: Thu, 13 Mar 2025 11:17:11 +0100
> > >> >> > 
> > >> >> > Ciao,
> > >> >> > 
> > >> >> > 'php-ts-mode-php-executable' it's used for
> > >> >> > 'php-ts-mode-flymake-php',
> > >> >> > 'run-php' and 'php-ts-mode-run-php-webserver'.
> > >> >> 
> > >> >> Then please consider the solution proposed below.
> > >> >> 
> > >> >> > @Morgan: Will setting the executable path to "php" work in your
> > >> >> > scenario?
> > >> >> > Of the functions listed above, which one do you usually use?
> > >> >> 
> > >> >> Customizing the value is an okay solution, but we are discussing how
> > >> >> to solve this for users that don't customize.
> > >> >> 
> > >> >> How about the following solution:
> > >> >>  . we replace references to php-ts-mode-php-executable with a call
> > >> >>  to
> > >> >>  
> > >> >>    a function
> > >> >>  
> > >> >>  . that function will do something like
> > >> >>  
> > >> >>    (let ((php-prog (if (file-remote-p default-directory)
> > >> >>    
> > >> >>                        (executable-find "php" t)
> > >> >> 		     
> > >> >> 		     php-ts-mode-php-executable)))
> > >> >>      
> > >> >>      php-prog)
> > >> >> 
> > >> >> WDYT?
> > >> > 
> > >> > Yes, that's fine. Maybe we should also rename
> > >> > 'php-ts-mode-php-executable',
> > >> > something like 'php-ts-mode-php-default-executable'. It seems to me
> > >> > that it
> > >> > might not be clear that this value would not be used if the file was
> > >> > remote.> >> 
> > >> Wouldn't this approach make it impossible to override the value for the
> > >> remote system if the wrong PHP binary is found by executable-find?
> > > 
> > > If executable-find fails to find the PHP binary on the remote host,
> > > how can using "php" which you suggested do any better?
> > 
> > Because in that case I can modify either search path or the value of the
> > variable to match where the (correct) PHP binary is.
> > 
> > I think that using the value "php" would work the in majority of cases
> > for the majority of people, and working around issues is already covered
> > by existing Emacs functionality.
> > 
> > > But if we want to allow customization of remote PHP executable, we
> > > could introduce another defcustom.
> > 
> > This will have the same problems if connecting to two remote system
> > which are configured differently.
> 
> So I conclude that expecting "php" to be on PATH on remote systems is
> a requirement, since nothing else will work reliably enough, and let's
> close this discussion at that.

>From 3f5b7c7667021784a20d6090c52dedfffa1c12d0 Mon Sep 17 00:00:00 2001
From: Vincenzo Pupillo <[email-masked]>
Date: Fri, 14 Mar 2025 21:11:22 +0100
Subject: [PATCH] PHP has to be in the PATH (bug#76242)

* lisp/progmodes/php-ts-mode.el (php-ts-mode-php-executable): Now the
value is the executable name.
---
 lisp/progmodes/php-ts-mode.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/php-ts-mode.el b/lisp/progmodes/php-ts-mode.el
index 56c15dad36f..eb53df21b97 100644
--- a/lisp/progmodes/php-ts-mode.el
+++ b/lisp/progmodes/php-ts-mode.el
@@ -134,8 +134,8 @@ php-ts-mode-css-fontify-colors
   :type 'boolean
   :safe 'booleanp)
 
-(defcustom php-ts-mode-php-executable (or (executable-find "php") "/usr/bin/php")
-  "The location of PHP executable."
+(defcustom php-ts-mode-php-executable "php"
+  "The PHP executable."
   :tag "PHP Executable"
   :version "30.1"
   :type 'file)
-- 
2.48.1