0

I'm new to Gulp so please be kind. In my gulpfile.js I'm using this configuration for BrowserSync and gulp-connect-php server:

    phpConnect.server({}, function (){
        browserSync.init({
            server:{ 
                proxy: "localhost:3000",
                baseDir:"./build/",
                index: "index.php",
                //directory: true
            }
        }); 
    });

Every time I start my tasks with gulp dev, which is my default task, everything works except that when I open the browser to localhost:3000 a download is prompted for

application/x-httpd-php (2,5 kB)

I've tried to read the other answers here on Stackoverflow and on Github. I've no idea what to do to fix this. I'm working on a MacBookAir 2017, Catalina updated regularly. I'm using Homebrew for Apache, Firefox and php7.

EDIT

After the first answer I think the problem is actually with mime.types. I've added them to my configuration file but still no luck.

WasabiMonster
  • 63
  • 2
  • 9

2 Answers2

1

It turns out I really am a noob when it comes to Gulp and BrowserSync. The correct configuration is:

    gulp.task('browserSync', function() {
    phpConnect.server({
        base:'./build/',
        hostname:'127.0.0.1'
    }, function (){
        browserSync.init({
            proxy: "127.0.0.1:8000"
        }); 
    });
});

because I'm trying to use the PHP Development Server on port 8000 and BrowserSync as PROXY not as a SERVER. Dumb me. I hope this will save some time to someone in the same situation.

WasabiMonster
  • 63
  • 2
  • 9
0

I think you should checkk in

/etc/httpd/conf/httpd.conf

file:

AddType  application/x-httpd-php         .php
AddType  application/x-httpd-php-source  .phps

Or something similar and: (for PHP 7 example)

LoadModule php7_module modules/libphp7.so

Apache is downloading php files instead of displaying them

Hope it helps you

UnpassableWizard
  • 1,237
  • 11
  • 20
  • Thank you for your answer. My configuration file for apache is actually located in /etc/apache2/httpd.conf because I'm using MacOS and Homebrew. I tried following the instructions in the link you provided and still no luck. But at least as far as I understand now this is a problem with mime types not working as they should. – WasabiMonster May 26 '20 at 07:45
  • Ah I see, too bad it did not work. Hope you can figure it out – UnpassableWizard May 26 '20 at 09:39