ptPHP
class
class ptPHP {
static Directory path = Directory.current;
static String getMyPath() => "${path.path}/packages/ptwebserver/resource/";
ptPHP(this.enable,this.phpPath,{this.phpINI,this.working_dir});
bool enable;
String phpPath;
String phpINI;
String working_dir;
void Run(HttpRequest req, String phpFile,{List<String> arg}) {
if(arg==null) {
arg = new List<String>();
}
/*
* To add or remove the INI in
*/
if(phpINI!=null && phpINI.length > 0) {
arg.add("-c ${phpINI}");
} else {
arg.add("-n");
}
arg.add("${getMyPath()}phpExecute.php");
arg.add("${phpFile}");
arg.add(req.method);
req.uri.queryParameters.forEach((key,val) {
arg.add("${key}=${val}");
});
//print("php ${arg.toString()}");
Process.start(phpPath, arg).then((Process proc) {
proc.stdout.transform(new Utf8Decoder()).listen((data) {
req.response.write(data);
}, onDone: () {
req.response.close();
});
}).whenComplete(() {
//req.response.close();
});
}
}
Static Properties
static Directory path = Directory.current
Static Methods
String getMyPath() #
static String getMyPath() => "${path.path}/packages/ptwebserver/resource/";
Constructors
new ptPHP(bool enable, String phpPath, {String phpINI, String working_dir}) #
Creates a new Object instance.
Object instances have no meaningful state, and are only useful
through their identity. An Object instance is equal to itself
only.
ptPHP(this.enable,this.phpPath,{this.phpINI,this.working_dir});
Methods
void Run(HttpRequest req, String phpFile,{List<String> arg}) {
if(arg==null) {
arg = new List<String>();
}
/*
* To add or remove the INI in
*/
if(phpINI!=null && phpINI.length > 0) {
arg.add("-c ${phpINI}");
} else {
arg.add("-n");
}
arg.add("${getMyPath()}phpExecute.php");
arg.add("${phpFile}");
arg.add(req.method);
req.uri.queryParameters.forEach((key,val) {
arg.add("${key}=${val}");
});
//print("php ${arg.toString()}");
Process.start(phpPath, arg).then((Process proc) {
proc.stdout.transform(new Utf8Decoder()).listen((data) {
req.response.write(data);
}, onDone: () {
req.response.close();
});
}).whenComplete(() {
//req.response.close();
});
}