Dart Documentationptwebserver.extHandler.PHPPHP_Handler

PHP_Handler class

class PHP_Handler extends extHandler {
 PHP_Handler() {
   // PHP has been initialized
 }
 
 static RegExp PHP_REGEX = new RegExp(r"/\.php$/i");
 
 String get Name=>"PHP";
 
 static const String phpPath = "php"; 
 static Directory path = Directory.current;
 static String getMyPath() => "${(path.path)}/packages/ptwebserver/resource";
 static bool exists = false;
 
 bool test(String file) {
   return file.toLowerCase().endsWith(".php");
 }
 
 void handle(ptHost host,HttpRequest req,String file) {
   List<String> args = new List<String>();
   args.add("-n");
   args.add("${getMyPath()}/phpExecute.php");
   args.add(file);
   args.add(req.method);
   req.uri.queryParameters.forEach((key,val) {
     args.add("${key}=${val}");
   });
   Process.start(phpPath, args).then((Process proc) {
     proc.stdout.transform(new Utf8Decoder()).listen((data) {
       req.response.write(data);
     }, onDone: () {
       req.response.close();
     });
   });
 }
}

Extends

extHandler > PHP_Handler

Static Properties

bool exists #

static bool exists = false

Directory path #

static Directory path = Directory.current

RegExp PHP_REGEX #

static RegExp PHP_REGEX = new RegExp(r"/\.php$/i")

const String phpPath #

static const String phpPath = "php"

Static Methods

String getMyPath() #

static String getMyPath() => "${(path.path)}/packages/ptwebserver/resource";

Constructors

new PHP_Handler() #

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.

docs inherited from Object
PHP_Handler() {
 // PHP has been initialized
}

Properties

final String Name #

String get Name=>"PHP";

Methods

void handle(ptHost host, HttpRequest req, String file) #

void handle(ptHost host,HttpRequest req,String file) {
 List<String> args = new List<String>();
 args.add("-n");
 args.add("${getMyPath()}/phpExecute.php");
 args.add(file);
 args.add(req.method);
 req.uri.queryParameters.forEach((key,val) {
   args.add("${key}=${val}");
 });
 Process.start(phpPath, args).then((Process proc) {
   proc.stdout.transform(new Utf8Decoder()).listen((data) {
     req.response.write(data);
   }, onDone: () {
     req.response.close();
   });
 });
}

bool test(String file) #

bool test(String file) {
 return file.toLowerCase().endsWith(".php");
}