Skip to content

Instantly share code, notes, and snippets.

@niceboy120
Last active August 29, 2015 14:14
Show Gist options
  • Save niceboy120/8a5df824eebbe6012abe to your computer and use it in GitHub Desktop.
Save niceboy120/8a5df824eebbe6012abe to your computer and use it in GitHub Desktop.
grunt task php livereload
var grunt = require('grunt');
grunt.initConfig({
watch: {
php: {
files: ['src/**/*php', 'src/**/*js'],
tasks: ['default'],
options: {
nospawn: true, //Without this option specified express won't be reloaded
livereload: true
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['watch']);
<html>
<head>
<title>LiveReload inline script</title>
<script type="text/javascript" src="http://127.0.0.1:35729/livereload.js"></script>
<script type="text/javascript" src="test.js"></script>
</head>
<body>
<?php
echo "Last reload: ". date('d/m/Y H:i:s');
?>
<ul>
<li>Start webserver and grunt task</li>
<li>Edit & Save any PHP/JS to automatically reload this page</li>
<li>Testing 123</li>
</ul>
</body>
</html>
{
"name": "phpLive",
"version": "1.0.0",
"description": "This project intends to show a quick and easy way to use LiveReload and GruntJS to monitor PHP and JS files and reload content close to realtime on every file save.",
"main": "Gruntfile.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-watch": "^0.6.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment