I have this setup:
A php file /home/my-user/script.php with shebang #!/usr/bin/php and using the \JiraCloud\Issue\IssueService(). Right next to this php file is the .env file. When I am in the folder of the php file and run php script.php on the terminal everything works.
Then I create a symlink /usr/local/bin/jira -> /home/my-user/script.php to be able to call my script from everywhere. Then I go to any path, like /some/path/on/my/system and call jira. The PHP script is executed, but the IssueService() (or rather the ReST API call) fails because the .env file with the connection parameters could not be loaded.
I think there's probably one of these missing: realpath() or __DIR__ or dirname($_SERVER['SCRIPT_FILENAME']), when loading the .env file, as it seems the loader tries to load relative from the current terminal directory and not from the script location.