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

[Feature] custom SAPI #278

Merged
merged 10 commits into from
Nov 24, 2023
Merged

[Feature] custom SAPI #278

merged 10 commits into from
Nov 24, 2023

Conversation

joelwurtz
Copy link
Contributor

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)

pub fn send_header_function(mut self, func: SapiSendHeaderFunc) -> Self {
self.module.send_header = Some(func);
self
}
Copy link
Contributor Author

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)

Copy link
Collaborator

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

src/zend/try_catch.rs Outdated Show resolved Hide resolved
}

unsafe {
php_module_startup(sapi, module);
Copy link
Contributor Author

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() };
Copy link
Contributor Author

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

@danog danog merged commit b876077 into davidcole1340:master Nov 24, 2023
26 checks passed
@joelwurtz joelwurtz deleted the feat/sapi branch February 20, 2024 13:10
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

Successfully merging this pull request may close these issues.

3 participants