VSCode-Browser-Sync icon indicating copy to clipboard operation
VSCode-Browser-Sync copied to clipboard

Not reloading in php

Open victorpetuluku opened this issue 7 years ago • 5 comments

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!

victorpetuluku avatar Dec 14 '17 12:12 victorpetuluku

Do you embed the php call inside HTML body?

Jasonlhy avatar Dec 27 '17 01:12 Jasonlhy

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!
  1. Open file with "Browser sync: Proxy mode at side panel"
  2. Enter IP and Port of Webserver (files resides in document root)
  3. File opens in side Panel but does not reload on change and save
  4. "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.

timmornYE avatar Oct 18 '18 10:10 timmornYE

Thanks timmornYE, that fixed it for me.

StructByLightning avatar May 21 '19 15:05 StructByLightning

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

Holmes-EH avatar Apr 11 '20 08:04 Holmes-EH

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>

JamesLauffer avatar May 29 '21 13:05 JamesLauffer