Attribute Macro ext_php_rs::php_startup

source ·
#[php_startup]
Expand description

Annotates a function that will be called by PHP when the module starts up. Generally used to register classes and constants.

As well as annotating the function, any classes and constants that had been declared using the php_class, php_const and php_impl attributes will be registered inside this function.

This function must be declared before the php_module function, as this function needs to be declared when building the module.

This function will automatically be generated if not already declared with this macro if you have registered any classes or constants when using the php_module macro.

The attribute accepts one optional flag – #[php_startup(before)] – which forces the annotated function to be called before the other classes and constants are registered. By default the annotated function is called after these classes and constants are registered.

§Example

#[php_startup]
pub fn startup_function() {
    // do whatever you need to do...
}