@@ -36,6 +36,8 @@ using node_php_embed::node_php_jsobject_call_method;
3636
3737static void node_php_embed_ensure_init (void );
3838
39+ static char *node_php_embed_startup_file;
40+
3941ZEND_DECLARE_MODULE_GLOBALS (node_php_embed);
4042
4143/* PHP extension metadata */
@@ -219,12 +221,23 @@ static void node_php_embed_register_server_variables(
219221
220222NAN_METHOD (setIniPath) {
221223 TRACE (" >" );
222- REQUIRE_ARGUMENT_STRING (0 , iniPath );
224+ REQUIRE_ARGUMENT_STRING (0 , ini_path );
223225 if (php_embed_module.php_ini_path_override ) {
224226 free (php_embed_module.php_ini_path_override );
225227 }
226228 php_embed_module.php_ini_path_override =
227- (*iniPath) ? strdup (*iniPath) : nullptr ;
229+ (*ini_path) ? strdup (*ini_path) : nullptr ;
230+ TRACE (" <" );
231+ }
232+
233+ NAN_METHOD (setStartupFile) {
234+ TRACE (" >" );
235+ REQUIRE_ARGUMENT_STRING (0 , file_name);
236+ if (node_php_embed_startup_file) {
237+ free (node_php_embed_startup_file);
238+ }
239+ node_php_embed_startup_file =
240+ (*file_name) ? strdup (*file_name) : nullptr ;
228241 TRACE (" <" );
229242}
230243
@@ -256,7 +269,8 @@ NAN_METHOD(request) {
256269
257270 node_php_embed_ensure_init ();
258271 Nan::AsyncQueueWorker (new PhpRequestWorker (callback, source, stream,
259- args, server_vars, init_func));
272+ args, server_vars, init_func,
273+ node_php_embed_startup_file));
260274 TRACE (" <" );
261275}
262276
@@ -330,6 +344,7 @@ static void node_php_embed_ensure_init(void) {
330344
331345NAN_MODULE_INIT (ModuleInit) {
332346 TRACE (" >" );
347+ node_php_embed_startup_file = NULL ;
333348 php_embed_module.php_ini_path_override = nullptr ;
334349 php_embed_module.php_ini_ignore = true ;
335350 php_embed_module.php_ini_ignore_cwd = true ;
@@ -351,6 +366,7 @@ NAN_MODULE_INIT(ModuleInit) {
351366
352367 // Export functions
353368 NAN_EXPORT (target, setIniPath);
369+ NAN_EXPORT (target, setStartupFile);
354370 NAN_EXPORT (target, request);
355371 TRACE (" <" );
356372}
@@ -364,6 +380,11 @@ void ModuleShutdown(void *arg) {
364380 php_embed_shutdown (TSRMLS_C);
365381 if (php_embed_module.php_ini_path_override ) {
366382 free (php_embed_module.php_ini_path_override );
383+ php_embed_module.php_ini_path_override = NULL ;
384+ }
385+ if (node_php_embed_startup_file) {
386+ free (node_php_embed_startup_file);
387+ node_php_embed_startup_file = NULL ;
367388 }
368389 TRACE (" <" );
369390}
0 commit comments