GithubHelp home page GithubHelp logo

gulp-connect-php's People

Contributors

awhatley avatar br0ken- avatar cesarnicola avatar endel avatar grmartin avatar idanb11 avatar iskrisis avatar marcofugaro avatar micahblu avatar ryan-farmer avatar thomas-lebeau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gulp-connect-php's Issues

Allow more than one string for the base path

One feature of gulp-connect is that it accepts an array of strings for the root path. This is very useful when build process creates files outside root folder of the project (such as in a tmp folder) that should be served. An example would be when stylesheets are in .sass format in root of project, but are converted to .css by build and served from a tmp folder. Example from gulp-connect:

gulp.task('connectDev', function () {
  connect.server({
    name: 'Dev App',
    root: ['app', 'tmp'],
    port: 8000,
    livereload: true
  });
});

Is there a way to automatically add URL extensions?

I am trying to run gulp-connect-php along with browser-sync so that I can locally run some .php files.

Here is the task I'm currently running:

gulp.task('connect', () => {
  return connect.server({ 
    base: config.wpFolder,
    open: true,
    port: 8080
  }, function(){
    browserSync.init({
      proxy: '127.0.0.1:8080',
      files       : [`${config.wpFolder}/*.php`],
      notify      : false,
      ui: {
        port: 8080
      }
    });
  });
});

Now this does work for index as expected; however my issue is when I try and go to a different page. If I'm on localhost:8000 and then click the link to the contact page, the URL will update to localhost:8000/contact; however, it still only loads the index page. If I manually append .php so that the url reads localhost:8000/contact.php, it works.

Is there any way I can automate appending .php so that I don't need to update all of the URL's? For a production release, I would not have .php in the URL so I'd have to remove it for that and would like to keep the build process as DRY as possible.

I'm getting the following error when using gulp-connect-php

Error: Cannot find module 'opn'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (...\node_modules\gulp-connect-php\index.js:4:12)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

Crash calling a batch under Windows

If a batch <php.bat> exists somewhere on the PATH, gulp-connect-php will crash trying to call it.
But set option <bin: 'php.bat'> and it will work!

Thanks to have a look!

closeServer() does not work in Windows environment

the method closeServer() does not work because 'lsof' command does not exist in Windows command.

var connect = require('gulp-connect-php');

// start server
connect.init();

// end server
connect.closeServer(); // error!

Whether this API is going to be supported in Windows, or not ?

Doesn't Work In Gulp 4

I am currently trying to get gulp-connect-php running on a gulp4.0 version. I have tried with my existing gulp file and with a standalone project, Neither to much joy.

[10:07:09] Using gulpfile C:\development\gulp4\gulpfile.js
[10:07:09] Starting 'default'...
[10:07:09] Starting 'connect-sync'...
[10:07:09] The following tasks did not complete: default, connect-sync
[10:07:09] Did you forget to signal async completion?

This tends to be the issue that appears with the following gulpfile.js:

var gulp = require('gulp'),
    connect = require('gulp-connect-php');
    
gulp.task('connect-sync', function() {
  connect.server({});
});

gulp.task('default', gulp.series('connect-sync'));

Is there any possibility of getting this working with the new gulp4.0?

Odd issue with server occasionally stopping completely

So I'm using this to run a wordpress instance. Loading pages is fine but after a while (maybe 20-30 minutes) of refreshing whilst I work on a theme the server will suddenly die, first it'll return nothing, then it'll give connection refused.

Locally I'm running on port 8888 and I can reliably reproduce by hitting this URL http://172.16.1.2:8888/wp-content/themes/wp-theme/js/scripts-0.0.1.min.js

When this happens, there's no log output, running the task in gulp with DEBUG=* gives no log output, there's nothing in the wordpress log, setting the debug option also gives no output.

Do you have any idea what could cause this or how I could go about trying to debug? If not I can probably create an environment that'll hopefully allow you to reproduce this but it may take a little while.

OSX Mojave (but also happens in other OSXes)

/usr/local/bin/php
php -v
PHP 7.2.10 (cli) (built: Sep 14 2018 07:07:08) ( NTS )
gulp -v
[07:10:36] CLI version 3.9.1
[07:10:36] Local version 3.9.1
node -v
v10.11.0

Silent option

I got gulp-connect-php to work in conjunction with browserSync, which works perfectly so far.
I've been using grunt-php before which this plugin seems to be based on and I remember it having a silent flag to suppress the output to the console. I would very much like to have that feature as well since I use the console output for things like JSHint and don't really need a bunch of [200] access codes cluttering my console. I couldn't find a similar option for gulp-connect-php :(
Is there any way this can be implemented or achieved in my gulp setup?
Any help is much appreciated!

Push version 0.0.5 to npm

I don't know if it just takes time but maybe you forgot.

Latest version on npm is still 0.0.3, version which doesnt have the callback when server starts thus breaking the browser-sync examples in docs.

Thanks!

Closing sessions

Hello, I am using gulp-connect-php on a lot of different projects to serve up my PHP pages. Sometimes I would start one server on one project, and then have to switch to a different project. I make sure to close the connection by ending the gulp task. However, when I switch to the different project and run my gulp task, the connection opens the previous site instead.

So far, the only way I can close off the connection completely is to restart my computer. That is not practical in the long run. How can I make it so that previous connection ends completely and loads the appropriate site? Thank you in advance.

Below is an example of my gulp task.

gulp.task('connect', function () {
    connect.server({
        root: 'src',
        livereload: true
    });
});

gulp.task('connectSync', ['connect'], function () {
    connectPhp.server({}, function () {
        browserSync({
            proxy: 'localhost:8000',
            open: {
                browser: 'Google Chrome'
            }
        });
    });
});

Integration with Google Web Starter Kit

Has anyone successfully integrated gulp-connect-php with Google Web Starter Kit? They already use Browsersync but I'm not sure how to integrate this project into their workflow.

multiple base directories and routes

On the documentation, it says that it can be used as a drop-in replacement for gulp-connect.

How to use it in the following situation?

gulp.task('connect', ['styles'], function () {
  var serveStatic = require('serve-static');
  var serveIndex = require('serve-index');
  var app = require('connect')()
    .use(require('connect-livereload')({port: 35729}))
    .use(serveStatic('.tmp'))
    .use(serveStatic('app'))
    .use('/bower_components', serveStatic('bower_components'))
    .use(serveIndex('app'));

  require('http').createServer(app)
    .listen(9000);
});

If I use var app = require('gulp-connect-php')() I get:

TypeError: object is not a function

Prevent Output of HTTP status codes & filenames in console (Working with Gulp and BrowserSync)

Hey @micahblu,
first thank you a lot for this great plugin, really saves a lot of time every day. I was just wondering if it's possible (whether with a php.ini or maybe an extra command line option) to prevent connect-php from spamming my console with all the status-codes and names of every single accessed file. A bonus would be to hide just the ones with a code of [200] :)

My output is looking like this just after a second:

[Tue Jan 26 20:20:12 2016] 127.0.0.1:53828 [200]: /
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53830 [200]: /css/main.min.css
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53831 [200]: /css/lightgallery/lightgallery.min.css
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53832 [200]: /css/lightgallery/lg-theme.min.css
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53833 [404]: /img/[email protected] - No such file or directory
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53834 [404]: /img/[email protected] - No such file or directory
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53836 [200]: /js/tooltips.min.js
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53837 [200]: /js/lightgallery/lightgallery.min.js
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53842 [200]: /js/lightgallery/lg-video.min.js
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53845 [200]: /js/lightgallery/lg-thumbnail.min.js
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53846 [200]: /js/lightgallery-data.min.js
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53847 [404]: /img/[email protected] - No such file or directory
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53848 [404]: /img/icons/[email protected] - No such file or directory
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53849 [404]: /img/icons/[email protected] - No such file or directory
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53856 [404]: /img/icons/[email protected] - No such file or directory
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53857 [404]: /img/icons/[email protected] - No such file or directory
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53858 [404]: /img/icons/[email protected] - No such file or directory
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53859 [404]: /img/icons/[email protected] - No such file or directory
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53860 [404]: /img/icons/[email protected] - No such file or directory
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53861 [404]: /img/icons/icon_link_arrow.svg - No such file or directory
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53864 [404]: /img/icons/icon_link_pictures.svg - No such file or directory
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53865 [404]: /img/background-patterns/linen.jpg - No such file or directory
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53872 [404]: /img/features/new-macbook-stethoskop.png - No such file or directory
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53873 [200]: /img/features/[email protected]
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53874 [200]: /img/features/[email protected]
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53875 [200]: /img/features/[email protected]
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53876 [404]: /img/[email protected] - No such file or directory
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53879 [404]: /img/icons/icon_feature_link.svg - No such file or directory
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53880 [404]: /img/icons/icon_feature_file.svg - No such file or directory
[Tue Jan 26 20:20:12 2016] 127.0.0.1:53881 [404]: /img/icons/icon_feature_check.svg - No such file or directory

Electron | Blank window after build

Hi!
I'm using gulp-connect-php for the first time. During my Electron app dev, everything was perfectly working. But, after running the build, I got a blank white window when opening the app. It seems that the app is not able to load the local url:
mainWindow.loadURL("http://127.0.0.1:8000")
instead of traditional:
mainWindow.loadURL('file://' + __dirname + '/index.html')

Here is my main.js
`const electron = require('electron');
const app = electron.app;
const { Menu, MenuItem } = electron;
const { ipcMain } = require('electron');

connect = require("gulp-connect-php");
var con = connect.server({
port: 8000,
hostname: "127.0.0.1",
base: 'public',
keepalive: false,
open: false,
root: "/",
stdio: "inherit"
});

const BrowserWindow = electron.BrowserWindow;

var mainWindow = null;

app.on('window-all-closed', function() {
if (process.platform != 'darwin') {
app.quit();
}
});

app.on('ready', function() {
mainWindow = new BrowserWindow({
width: 800,
height: 800,
frame: false,
webPreferences: {
plugins: true,
nodeIntegration: true
}
});

mainWindow.maximize();

mainWindow.loadURL("http://127.0.0.1:8000");

mainWindow.on('closed', function() {
mainWindow = null;
});

Menu.setApplicationMenu(null);
});`

It works well, but only when developing the app. I'm using electron-builder.
Maybe that's not an issue. Is there something wrong with this code ?

Thanks

EDIT : I should precise the entry file of my app is /public/index.php

TypeError: Cannot set property 'build' of null

I want to use php in node.js and created a new project:

  • npm init -y
  • npm install --save-dev gulp gulp-connect-php

I added a gulpfile.js with

var gulp = require('gulp');
var connect = require('gulp-connect-php');

gulp.task('php', function () {
    connect.server();
});

I started my project with gulp php and got

/home/jabaa/Documents/Projects/Web/php/node_modules/semver-truncate/index.js:11
    version.build = '';
                  ^

TypeError: Cannot set property 'build' of null
    at module.exports (/home/jabaa/Documents/Projects/Web/php/node_modules/semver-truncate/index.js:11:16)
    at /home/jabaa/Documents/Projects/Web/php/node_modules/bin-version-check/index.js:20:25
    at /home/jabaa/Documents/Projects/Web/php/node_modules/bin-version/index.js:15:3
    at ChildProcess.exithandler (child_process.js:204:7)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at maybeClose (internal/child_process.js:821:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)

Change binary php directory

Hello,
Thanks for your plugin but i would like to change the path of php binaries ?
Can you help me ?
Sorry for my english i'm french...

htaccess

Is there a way to use .htaccess file for pretty urls. I put the .htaccess file in the directory i'm serving from but it doesn't work. I tested the htaccess file out on a localhost and can confirm that it works properly.

Option to suppress logs

Hello!

Would it be possible to add an option that suppressed logging? I don't really need to see every request on every page load in my terminal window. :)

Adam

Config option to limit logs to errors only

So far it works flawlessly, though the output to the console is very verbose. I, and im sure a few others would like an option to limit this output to errors only.

Great work, thanks!

Directory ../ does not exist.

/project
    /assets
    /sources
        gulpfile.js
        package.json
    index.php

I currently have all of my gulp and npm related files inside a "sources" folder. I am wanting to declare my base directory one layer up

var gulp        = require('gulp'),
    plugins     = require('gulp-load-plugins')(),
    connect     = new plugins.connectPhp(),
    browserSync = require('browser-sync').create();

gulp.task('connect', function() {
    connect.server({ base: '../', port: 8010}, function(){
        browserSync.init({
            proxy: '127.0.0.1:8010',
            notify: false,
            port: 8080
        });
    });
});

I don't receive any errors that kill the process but it does console the following:

Directory ../ does not exist.

I am on Windows 10 and am currently using the following package versions:

"gulp": "*",
"gulp-connect-php": "^1.0.1",

"browser-sync": "^2.18.13"

What's odd is that this same exact setup works perfectly fine on my Mac. I'm not sure why Windows is having problems.

Crash when running version 1.0.0

Hi!

All the examples crash when run.
Installation of version 0.0.8 does not give errors when run using the same examples.

/node_modules/gulp-connect-php/index.js:16
[...arguments].forEach((x) => { this[x] = Symbol(x) });
^^^
SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (/Users/raymond/Google Drive/sites/bolwerkenschede/gulpfile.js:5:13)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)

environment: mac osx sierra

setup to work with foundation 6 browser sync?

Hello,
I am using foundation 6 for sites. I have customized the gulpfile to export php files. That's all good. The only thing I can't figure out is how to install gulp-connect-php to foundation 6 and get it watching with browser sync.

Cache with gulp-connect-php

I cannot figure out if it is my code or if gulp-connect-php just doesn't have any caching capabilities. From what I can tell in running phpinfo();, memcache, memcached, and apc are all running or emulated. However, when I try any of the tests of memcache or memcached, I can't connect to anything. Does gulp-connect-php just not support caching even though it says it does in phpinfo?

Has no method 'reload'

I use the plugin as mentioned in your Readme with the .pipe(connect.reload());command. But I get an error: TypeError: Object #<Object> has no method 'reload'. Also open:true isn't working at all. Here's my code:

var gulp = require('gulp'),
    jade = require('gulp-jade'),
    sass = require('gulp-sass'),
    browserify = require('gulp-browserify'),
    prefixer = require('gulp-autoprefixer'),
    connect = require('gulp-connect-php'),
    uglify = require('gulp-uglify'),
    rename = require('gulp-rename');

gulp.task('connect', connect.server({
    base: ['../../../'],
    open: true
}));

gulp.task('jade', function(){
    return gulp.src('src/templates/**/*.jade')
        .pipe(jade())
        .pipe(gulp.dest('./js'))
        .pipe(connect.reload());
});

gulp.task('css', function(){
    return gulp.src('css/**/*.scss')
        .pipe(sass({style: 'compressed'}))
        .pipe(prefixer({
            browsers: ['last 15 version', 'ie', 'iOS', 'Safari', 'ChromeAndroid', 'ExplorerMobile', 'Chrome', 'Android'],
            cascade:false
        }))
        .pipe(rename('css/**/style.css'))
        .pipe(gulp.dest('./'))
        .pipe(connect.reload());
});

gulp.task('php', function(){
    gulp.src('./**/*.php')
        .pipe(connect.reload());
});

gulp.task('watch', function(){
    gulp.watch('src/templates/**/*.jade', ['jade']);
    gulp.watch('css/**/*.scss', ['css']);
    gulp.watch('./**/*.php', ['php']);
});

gulp.task('default', ['watch', 'connect']);

Opening/Closing a Gulp PHP session in an Electron build

So let me say what my setup is, then I'll try and describe my problem. I am building an app in Electron to open a php web application setup previously built, hence why I am using gulp-php-connect. Basically, Electron just serves to try and make the program an all-in-one experience for when people download it. After trying multiple different ways, I found using y'all's NPM Gulp package worked the best, but I've run into a few issues that I wanted to ask about.
(I am very much so a newb when it comes to Node.js, Electron, and Gulp, so if sound or ask something foolish, it's probably cause it was foolish)

Firstly, how do I open a Gulp process from the main.js file that powers Node.js/Electron? I have mine jerry-rigged to execute a terminal command to run Gulp, which is fine, but I know that isn't how it's supposed to be done.

Secondly, and ultimately more importantly, how do I close that Gulp-php process once the app itself closes? The way I have my Electron app setup now, I have to hit Command-Q (I'm on a Mac, on Windows it's Ctrl-Q) to close the app. This causes an issue where the Gulp process never stops, probably due to me jerry-rigging it through the terminal. I end up having to go in and manually stop the php task in my activity manager. Although technically the Electron app still works when the php server is left running in the background, I'd rather not have ghost processes left over running behind the scenes.
Edit: I have now added the ability for a button click to close the Electron app, but this still leaves the Gulp-PHP server running in the background

I suspect that my two questions are related, but I really want some help on this from the guys who know their package best! I'll include the code from my main.js and my gulpfile.js for y'all to look over:

main.js

const electron = require('electron');

const {
    app,
    BrowserWindow
} = electron;

const exec = require('child_process').exec;
var yourscript = exec('gulp');

let mainWindow;
let settingsWindow;

//Listen for the app to be ready
app.on('ready', function () {
    //Create new window
    mainWindow = new BrowserWindow({
        width: 1920,
        height: 1080,
        frame: false
    })
    //Load the HTML file into the window
    mainWindow.loadURL('http://localhost:12344')
    
    mainWindow.webContents.openDevTools();
    
    mainWindow.on('closed', function(){
        mainWindow = null
    })
});

gulpfile.js

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

let server = new connect();

gulp.task('connect', function() {
	/*server.server({
        port: '12344',
        hostname: 'localhost'
    });*/
    server.server({port: 12344, hostname: 'localhost'}, function() {
    	gulp.on('stop', function _gulp_php_stopper() {
            console.log('Closing PHP Server...')
    		server.closeServer();
    	});
    });
});
gulp.task('disconnect', function() {
	server.closeServer();
});

gulp.task('default', ['connect', 'disconnect']);

Won't start

EDITED

Created dir *C:\Test*

npm install --save-dev gulp-connect-php

Browse to C:\Test\node_modules\gulp-connect-php\

I edited the index.js file to include a console.log("Starting.."); and that now shows ok (so it's doing something),

but when I go to the examples folder and run "node gulpfile", I see starting... and that's it. I browse to the default localhost:8000 and nada. Just in case I try localhost:8000/index.php and nothing (even though it should default to index).

So I edit gulpfile.js and add a "Started" console log msg, and that NEVER shows up. I am using 100% default example, minus the console message!

...Am I doing something wrong?

(Still a node newb, bare with me, but I've followed all the instructions)

Error: Cannot find module 'opn'

Could it be that opn should be moved from devDependancies to dependancies?

After installing gulp-connect-php I get this error when running a gulp task that uses gulp-connect-php:

[17:53:27] Error: Cannot find module 'opn'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (**project-folder**/node_modules/gulp-connect-php/index.js:4:12)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

browsersync don't work with connect-php

// ### Server tasks

// server w/ php
gulp.task('connect', function() {
  connect.server({
    hostname: 'localhost',
    bin: '/usr/bin/php',
    ini: '/etc/php5/cli/php.ini',
    base: './dist',
    keepalive: true,
  }, function (){
    browserSync.init({
      proxy: "localhost:8000",
      open: false
    });
  });
});

// server w/out php
gulp.task('connect-no-php', function() {
  browserSync.init({
    server: "./dist",
    open: false
  });
});

without connect-php browserSync.reload() and browserSync.stream() works fine. when i run connect task, it just don't want to refresh browser or inject styles, until i refresh page manually.
and...it happens only when i run linux. on windows there is no problem.

what it can be?

Add functionality to pass command line args to PHP

It'd be great if the package supported setting custom command line arguments to PHP. Currently I need to add some extra stuff to enable a profiler and I do it by setting it in the router property, but it'd be great if it could be officially supported. Thanks!

closeServer errors with custom port

If I use port 8000, the server starts and stops correctly, but if I use e.g. port 8080, the server starts fine but trying to stop it causes an error.

exec error: Error: Command failed: 

/home/.../node_modules/gulp-connect-php/index.js:64
            var pid = stdout.match(/php\s+?([0-9]+)/)[1];
                                                     ^
TypeError: Cannot read property '1' of null
    at /home/.../node_modules/gulp-connect-php/index.js:64:48
    at ChildProcess.exithandler (child_process.js:651:7)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:755:16)
    at Process.ChildProcess._handle.onexit (child_process.js:822:5)

Limiting logs to errors only

Setting option.stdio to [ 'ignore', 'ignore', process.stderr ] still seems to log all errors. Is there any way to limit logging to errors only? Thanks

BrowserSync with gulp-connect-php

The contents of my gulp task (serve) are below. All of the tasks are performing as expected, in the terminal I get the message [BS] Reloading browsers... as expected. But the browser doesn't reload. If I manually refresh, I see the changes that I'd made in either PHP, JS or CSS.

Any help here would be greatly appreciated.

Versions of Browsersync, node and npm I'm running

  • Browsersync [ 3.5.3 ]
  • Node [ 5.5.0 ]
  • Npm [ 3.5.3 ]

Affected platforms

  • OS X

Browsersync use-case

  • Gulp

How I'm using gulp-connect-php with BrowserSync

'use strict';
const browserSync = require('browser-sync');
const connect = require('gulp-connect-php');
const gulp = require('gulp');

// Function to properly reload your browser
function reload(done) {
  browserSync.reload();
  done();
}

gulp.task('serve', function(done) {
  connect.server({
    base: './.tmp/app',
    hostname: 'localhost',
    port: 3000
  }, function (){
    browserSync.init({
      proxy: 'localhost:8000'
    });
    done();
  });

  gulp.watch('src/app/assets/javascript/**/*.js', gulp.series('scripts', reload));
  gulp.watch('src/app/assets/scss/**/*.scss', gulp.series('styles'));
  gulp.watch('src/**/*.php', gulp.series('phplint', 'copy:php', reload));

});


gulp.task('watch', function)

closeServer does not work with non-8000 port

For some reason, even though the code is updating the workingPort variable as you would expect, the previous value or workingPort is what is getting used during the closeServer method (8000).

You can see the issue if you run server with port 9000 and then try and run closeServer. If you log out the workingPort value it will be 8000 instead of the expected 9000.

Can't run server from custom bin directory

Hi

I have a custom PHP installation setup in /usr/local/php5/bin/php. I am trying to get a PHP server running from this bin directory but I am having some problems, my gulpfile includes the following:

connect.server( { base: '../../../', port: 8010, keepalive: true, debug: true, stdio: 'ignore', bin: '/usr/local/php5/bin/php' });

However, when i run the server I get the following message:

Invoking Spawn with: /usr/local/php5/bin/php [ '-S', '127.0.0.1:8010', '-t', '../../../' ] { cwd: '.', stdio: 'ignore' } PHP server not started. Retrying...

However if I run the following command myself in terminal from the same folder it runs absolutely fine:

/usr/local/php5/bin/php -S 127.0.0.1:8010 -t ../../../

I have tried debugging through the JS and I can confirm that the checkPath call is saying that the bin file exists. If i log out the error that is returning when it is logging 'PHP server not started', i get the following:

{ Error: connect ECONNREFUSED 127.0.0.1:8010 at Object._errnoException (util.js:1041:11) at _exceptionWithHostPort (util.js:1064:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1153:14) code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 8010 }

Any help to get this working would be greatly appreciated!!

Many thanks
David

Not working with Grav CMS admin

Hello
I'm building a site with Grav CMS, gulp-connect-php is working fine for rendering php pages.
But when i want to connect to the admin, i get a server error 500 :

The Admin Plugin cannot run on the PHP built-in webserver. It needs Apache, Nginx or another full-featured web server.

Is there a workaround please ?

thx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.