Is there a way to determine, at runtime, if a PHP file is running as part of a phar archive? i.e., a native implementation might look something like this However, this might not work if the user has renamed the phar to have a different file extension, or symlinked the phar to remove the file extension. Answer You could use