Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
LiveReload.php
Go to the documentation of this file.
1<?php
2namespace Ubiquity\debug;
3
4
6
22 public static function start(int $port=35729):string{
23 if(!URequest::isAjax()) {
24 $nonce=self::getNonce();
25 return '<script'.$nonce.'>document.write(\'<script'.$nonce.' src="http://\' + (location.host || \'localhost\').split(\':\')[0] +
26 \':' . $port . '/livereload.js?snipver=1"></\' + \'script>\')</script>';
27 }
28 return '';
29 }
34 public static function hasLiveReload():bool{
35 $exitCode=0;
36 \exec('livereload --version', $_, $exitCode);
37 return $exitCode == 1;
38 }
39
40 private static function getNonce($name='jsUtils'){
41 if(\class_exists('\\Ubiquity\\security\\csp\\ContentSecurityManager')){
42 if (\Ubiquity\security\csp\ContentSecurityManager::hasNonce($name)){
43 $nonce=\Ubiquity\security\csp\ContentSecurityManager::getNonce($name);
44 return " nonce=\"$nonce\" ";
45 }
46 }
47 return '';
48 }
49
50}
Class for livereload in dev mode.
static hasLiveReload()
Check if Livereload js intallation.
static start(int $port=35729)
Add livereload webSocket.
static getNonce($name='jsUtils')
Http Request utilities, wrapper for accessing to $_GET, $_POST and php://input.
Definition URequest.php:18
Class Configuration \config.