What are the best practices for ensuring that PHP uses the correct PATH variable on a server?

When running PHP scripts on a server, it's important to ensure that PHP is using the correct PATH variable to locate external executables or binaries. One way to do this is by setting the PATH variable explicitly within the PHP script using the putenv() function. This ensures that PHP can find the necessary executables and binaries required for the script to run successfully.

<?php
putenv('PATH=' . getenv('PATH') . ':/usr/local/bin'); // Add the necessary path to the existing PATH variable
// Your PHP script code here
?>