I use Laravel Sail by default. But now I have a problem that I want to use a standalone binary file for a service. Currently I have placed the file under app/Services/MyApp/bin/standAloneFile
. the file is called via shell_exec()
. In my Sail docker instance the whole path would be “/var/www/html/app/Services/MyApp/bin/standAloneFile
” but on my server the path is completely different. That’s why you should avoid working with absolute paths. So I wonder how to create a relative path to the app folder. Something like public_path(). The problem is the entry point of shell_exec()
.
public static function run(String $link, String $targetPath)
{
$standAloneFile = '/var/www/html/app/Services/MyApp/bin/standAloneFile';
return shell_exec('cd ../storage/app' . $targetPath . ' && ' .$standAloneFile .' --link '. $link ');
}