Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defining extensions #27

Open
IngwiePhoenix opened this issue Dec 1, 2015 · 1 comment
Open

Defining extensions #27

IngwiePhoenix opened this issue Dec 1, 2015 · 1 comment

Comments

@IngwiePhoenix
Copy link

PHP usually provides extensions; like pcntl, hprose, sockets and alike.

In order to reproduce these within Uniter, this is what I would suggest:

var Extension = require("uniter-extension");

var cURL = new Extension();

cURL.function("curl_init", function(){
    // Implement curl_init
});

function cURLClass(args) {}
    // a cURL class
}
cURL.addClass("cURL", cURLClass);

module.exports = cURL;

Now, we could extend Uniter by an additional function. Currently, we have .install() to install functions, constants and classes into the system. As far as I remember, they all go into global scope. Extensions could be registered similarily:

var rt = require("phpruntime");
rt.registerExtension( "curl", require("./myCurlExt.js") );
rt.loadExtension("curl");

This would also provide the extension_loaded function to Uniter. Also, we might be able to use dl().

To summarize:

  • Add Extension support to Uniter, so that native PHP extensions can be emulated.
  • Let the runtime know about Extensions. The user should be able to add, remove, enable and disable extensions.
  • Uniter PHP scripts should be able to use:
    • extension_loaded($extName)
    • dl($extName)

Implementation is up to you, the above are just pseudo-code examples :) But i bet you get what I meant.

@asmblah
Copy link
Owner

asmblah commented Dec 23, 2015

This is a nice suggestion @IngwiePhoenix, I'll definitely implement this soon 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants