herd-community
herd-community copied to clipboard
[Bug]: herd_auto_prepend_file works, but herd_auto_append_file doesn't
Platform
Windows
Operating system version
Windows 11 (23H2 22631.3155)
System architecture
Windows
Herd Version
1.19.1
PHP Version
8.3, 8.4
Bug description
I'm using Herd for a vanilla PHP project, and have added the following lines to php.ini to automatically put my opening and closing HTML on each rendered page:
herd_auto_prepend_file = C:/Users/MY_USERNAME/path/to/project/wrapper-open.php
herd_auto_append_file = C:/Users/MY_USERNAME/path/to/project/wrapper-close.php
wrapper-open.php works as expected, but wrapper-close.php is not appended.
I have also tried using auto_append_file without herd_, which doesn't work either.
Any assistance to get this to work would be much appreciated :)
Steps to reproduce
- Create a project with three PHP files:
wrapper-open.php,wrapper-close.php,my-page.php(e.g., in a folder calledsample-project) and add some simple HTML to them (example attached) - Add the project as a Herd site
- Open the
php.inifile for the current global PHP version - Add the following with the paths updated to match your system:
herd_auto_prepend_file = C:/Users/MY_USERNAME/path/to/project/wrapper-open.php
herd_auto_append_file = C:/Users/MY_USERNAME/path/to/project/wrapper-close.php
- Visit https://sample-project.test/my-page.php
- Observe that the content of
wrapper-open.phpandmy-page.phpare shown in the browser, butwrapper-close.phpis not.
Relevant log output
Did you restart PHP after modifying your php.ini files?
This is my output:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div id="browser-test-content">
some datasome closing content
</div>
</body>
</html>
And this is my php.ini file:
herd_auto_prepend_file=/Users/marcelpociot/Code/sample-project/wrapper-open.php
auto_append_file=/Users/marcelpociot/Code/sample-project/wrapper-close.php
Thanks for the quick reply! Yeah, I have tried restarting all services and that didn't make a difference.
Sorry for the late reply. I'm unable to reproduce this issue I'm afraid, maybe this is somehow PHP version related? At least Herd is not making any modifications to those php.ini settings, so if you just use auto_prepend_file and auto_append_file, that's 100% pure PHP with nothing intercepting from Herd. Please see if it works this way, I'm not really sure what else we can do.
Thanks again for your time on this @mpociot. I can now confirm that after updating to PHP 8.4.7, using auto_append_file instead of herd_auto_append_file and restarting PHP, it works now.