-
Notifications
You must be signed in to change notification settings - Fork 67
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
[Feature] custom SAPI #278
Conversation
pub fn send_header_function(mut self, func: SapiSendHeaderFunc) -> Self { | ||
self.module.send_header = Some(func); | ||
self | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a lot of thing can be defined but ATM this is the only required function for PHP to not segfault (that's why we set a dummy handler if nothing is set latter)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's enough for me, let's make it evolve when users will have more usage
} | ||
|
||
unsafe { | ||
php_module_startup(sapi, module); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here we create our own sapi with our own module so we can add function to php, this avoid the previous hack (zend_register_module) which does not work for a lot of cases (like registering classes)
php_module_startup(sapi, module); | ||
} | ||
|
||
let result = unsafe { php_request_startup() }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we separate module startup / request startup we can imagine having a loop here to handle multiple requests / execution with memory cleaned between them
Goal of this PR is to provide a safe API around creating it's own SAPI for PHP
Actually there is only basic stuff and no wrapper at all and a test to show / confirm how it works.
I'm not sure about which API to provide to make things easier if someone want to create it's own SAPI.
Macro are out of scope for this PR (as i prefer to wait for the new macros to be merged and i think we can do a first version without them)