thekid/rfc — Issue #151: RFC 0151: Runtime class
Author: thekid
Created: 2011-10-09 15:26:13+00:00
State: open

Scope of Change
====
A new class lang.Runtime will provide access to the PHP runtime.

Rationale
====
* Find out PHP runtime executable
* Wrap library loading

Functionality
====

lang.Runtime API
----

```php

```

lang.Process new methods
----

```php

```

Examples
----
Query PHP runtime executable:

```php
getExecutable()->getFileName();
$pid= Runtime::getInstance()->getExecutable()->getProcessId();
?>
```

Clean up temporary files during shutdown:

```php
addShutdownHook(newinstance('lang.Runnable', array($temp), '{
public $target= NULL;

public function __construct(File $target) {
$this->target= $target;
}

public function run() {
$this->target->exists() && $this->target->delete();
}
}'));
?>
```

Load GTK library:

```php
loadLibrary('gtk');
} catch (IllegalAccessException $e) {
// Access denied, e.g. because in multithreaded environment
} catch (ElementNotFoundException $e) {
// Could not find php_gtk.dll / php_gtk.so
} catch (SystemException $e) {
// Errors while loading php_gtk.dll / php_gtk.so
}
?>
```

Security considerations
====
None.

Speed impact
====
None. This class will not be loaded during the bootstrapping process.

Dependencies
====
- Changes to the lang.Process class.

Related documents
====
- http://xp-framework.net/rfc/contrib/rfc0151.diff
Implementing patch

- http://news.xp-framework.net/article/230/2008/01/07/
How to find the PHP binary's filename

- http://de3.php.net/register_shutdown_function
PHP's shutdown function API

- http://de3.php.net/dl
PHP's dynamic library loading functionality

- http://javadoc.xp-framework.net/api/java/lang/Runtime.html
Java's lang.Runtime class

Comments
====
- friebe, Tue Jan 8 14:53:51 2008
Not sure about the libary loading - should this be supported?