Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot GET / with gulp-connect-php

I'm using gulp-connect-php to try and run a php server locally with BrowserSync. Here's my gulp config file:

var gulp = require('gulp'),
    connect = require('gulp-connect-php'),
    browserSync = require('browser-sync');

gulp.task('connect-sync', function() {
  connect.server({}, function (){
    browserSync({
        server: {
            baseDir: "app"
        },
     // proxy: '127.0.0.1:8000'
    });
  });

  gulp.watch('**/*.php').on('change', function () {
    browserSync.reload();
  });
});

gulp.task( 'default', [ 'connect-sync' ] )

The above code works when I have a index.html file in my app directory but when I replace it with an index.php file I get the following message:

Cannot GET /

Not exactly sure what i've done wrong here?

like image 748
red house 87 Avatar asked Mar 10 '17 12:03

red house 87


1 Answers

You need to declare a index filename, add and index object to server.

...
browserSync({
    server: {
        baseDir: "app",
        index: "/index.php"
    },
});
...

You could also set browserSync startpage to /index.php instead of / Edit I couldn't get startPath to work, so use index as in the example above.

...
browserSync({
    server: {
        baseDir: "app"
    },
    startPath: "/index.php"
});
...

@pramod-patil I don't think Apache directions will help here, since browserSync doesn't use Apache for serving PHP.

like image 186
lofihelsinki Avatar answered Sep 22 '22 11:09

lofihelsinki