我使用吞咽-连接-php尝试在本地使用BrowserSync运行php服务器。这是我的gulp配置文件:
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' ] )当我在我的app目录中有一个index.html文件时,上面的代码可以工作,但是当我用一个index.php文件替换它时,我会得到以下消息:
得不到/得不到
不太确定我在这里做错了什么?
发布于 2017-03-21 04:17:42
我从您的问题中了解到,php不识别.php文件。有两种方法可以完成这项工作。
Apache (httpd.conf),搜索DirectoryIndex并用它替换行(只有在启用dir_module时才能工作,但大多数安装都是默认的)或添加index.php
DirectoryIndex index.php index.phtml index.html index.htm或者在web根目录中创建一个.htaccess文件。再加上一行..。
DirectoryIndex index.php希望这能有所帮助!
发布于 2017-03-21 20:12:21
您需要将索引文件名、添加和index对象声明到server。
...
browserSync({
server: {
baseDir: "app",
index: "/index.php"
},
});
...您还可以将browserSync入门页面设置为/index.php,而不是/编辑--我无法让startPath工作,所以使用index,如上面的示例所示。
...
browserSync({
server: {
baseDir: "app"
},
startPath: "/index.php"
});
...@pramod我不认为Apache的方向会有帮助,因为browserSync不使用Apache为PHP服务。
https://stackoverflow.com/questions/42718694
复制相似问题