#!/usr/bin/env php does not execute script without the file extension [closed]

  command-line, php, symfony

I’m writing a command-line application using the console component of Symfony. When I execute it using the .php file extension from the application directory where the file is contained (./myapp.php), it works as expected, however, if I leave it off (./myapp), the output is no such file or directory: ./myapp. PHP is in my PATH (/usr/local/bin) and in fact I used !#/usr/local/bin php instead of #!/usr/bin/env php, but it didn’t work either. The file is executable.

Some additional info:

I’m in MacOS 10.15.3 running on a zsh shell with PHP 7.4.1 installed via homebrew. My application is in a directory used by Laravel Valet, but I used valet forget in the directory to leave it out of the server. The version of the component is 5.1

Any ideas?

Source: Symfony Questions