# Sync PHP
this is a webpack plugin that you can use to reload php files on changes.
add plugin to the
webapck.dev.config.js
array
const syncPhp = require('sync-php');
plugins: [
new syncPhp({
port: 1337, // required
watch: path.resolve('build/') // required
})
]
there are two options
port
-
use the port seprate from all the other ports
watch
-
directory you want to wath changes
add loader
to your main.js
file at the end
require('sync-php/client.js')(1337)
// this is the same port mentioned above
both ports should be same
run wepack server in watch mode
or run dev server
open your php file into browser
for php server use following command
php -S localhost:9000