VSCode-Browser-Sync
VSCode-Browser-Sync copied to clipboard
Not reloading in php
Hello, (first sorry about my english)
Im having a error with your wonderfull extension, when in use it on a php proyect the browser stop reloading, if the php file don't have any php call (plain html only) the extension works, but when i add a php call (for example, echo 'hi';) then stop working.
Im using a xampp server with the proxy mode in browser in local.
Regards!
Do you embed the php call inside HTML body?
Same here with a docker apache: webdevops/php-apache on Windows. But I also get no refresh with plain html if there is no html backbone. I think there are many cases where you need it to work without a complete html backbone.
Reproduce
File index.html with content
Hello World!
- Open file with "Browser sync: Proxy mode at side panel"
- Enter IP and Port of Webserver (files resides in document root)
- File opens in side Panel but does not reload on change and save
- "Browser sync: Refresh side panel" works as expected
When index.html looks like
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Titel</title>
</head>
<body>
Hello World!
</body>
</html>
all works as expected.
Thanks timmornYE, that fixed it for me.
Thank you @timmornYE ! It also fixed it for me. I am running apache2/PHP 7.3 on osx and could not get auto refresh.
Once I added the HTML backbone, the extension works as expected.
In fact only the beginning of <!DOCTYPE html>
up until the opening <body>
tag is necessary.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
For PHP development, my workaround is to include a header on every page rendered by apache.
To finish, thank you @Jasonlhy for this great extension !!
edit : I am using "Browser sync: Proxy mode in browser" with open folder
Thank you @timmornYE. Your answer in this older thread just solved the problem for me. I did some further testing. It looks like the only necessary tags iare the HTML and body tags.
<HTML>
<body>
<?php
echo "Hello World"
?>
</body>
</html>