Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php livereload? #42

Closed
coocier opened this issue Oct 15, 2014 · 3 comments
Closed

php livereload? #42

coocier opened this issue Oct 15, 2014 · 3 comments

Comments

@coocier
Copy link

coocier commented Oct 15, 2014

can the *.php files refresh in the browser automatically just like the function 'livereload' run in 'grunt-contrib-connect' when you change some code?

@brodkin
Copy link
Contributor

brodkin commented Oct 16, 2014

You'd use grunt-contrib-watch for that functionality. Just register a task that runs this plugin and then runs the watch command:

grunt.registerTask('phpwatch', ['php:watch', 'watch']);

You'll have to read the documentation for the watch plugin to learn how to monitor php files, but it's not too hard--promise!

@coocier
Copy link
Author

coocier commented Oct 16, 2014

@brodkin Ths,I know what you mean,but look at the following code,the 'grunt-contrib-connect' plugin has 'livereload' attribute in options,and this port is same with the watch livereload port so it can trigger a live reloading action in browser.


watch: {
livereload: {
options: {
// this port must be same with the connect livereload port
livereload: '<%= connect.options.livereload %>'
},
files: [ 'src/*.html']
}
},
connect: {
options: {
port: 9000,
hostname: 'localhost',
//this port is used by watch task to trigger a live reloading action.
livereload: 35729
},
all: {
options: {
open: true,
base: ['src']
}
}
}
grunt.registerTask('live', ['connect:all','watch']);


and now look at these code


watch: {
livereload: {
options: {
livereload: true
},
files: [
'src/*.php'
]
}
},
php: {
server: {
options: {
hostname: '127.0.0.1',
port: '8000',
base: 'src',
open: true
}
}
}
grunt.registerTask('phpwatch', ['php:server', 'watch']);


I read the documentation and found that 'grunt-php' plugin has no 'livereload' attribute in the options,it has no livereload port and can not trigger a live reloading action in browser.So it can only watch files changes but not refresh automatically
Am I right?

@brodkin
Copy link
Contributor

brodkin commented Oct 16, 2014

Not quite... Up to this point grunt-contrib-connect has been injecting javascript into your page that causes it to reload automatically. That is not necessary, per se. Instead you can ditch grunt-contrib-connect and install a browser extension that does the same thing by connecting to grunt-contrib-watch.

You can read up on LiveReload integration options here:
http://feedback.livereload.com/knowledgebase/articles/87979-how-do-i-choose-the-best-integration-method-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants