int main(int argc, char **argv){
	zend_op_array *op_array;
	zend_file_handle file_handle;

	if(argc != 2) {
		printf("usage:  op_dumper <php script>\n");
		return 1;
	}
	PHP_EMBED_START_BLOCK(argc, argv);
	printf("Script: %s\n", argv[1]);
	file_handle.filename = argv[1];
	file_handle.free_filename = 0;
	file_handle.type = ZEND_HANDLE_FILENAME;
	file_handle.opened_path = NULL;
	op_array =  zend_compile_file(&file_handle, ZEND_INCLUDE TSRMLS_CC);
	if(!op_array) {
		printf("Error parsing script: %s\n", file_handle.filename);
		return 1;
	}
	dump_op_array(op_array);
    destroy_op_array(op_array TSRMLS_CC);
    efree(op_array);
	PHP_EMBED_END_BLOCK();
	return 0;
}
Exemple #2
0
int main() {
  printf("Running tests...\n");

  PHP_EMBED_START_BLOCK(0, 0);

  test_mongo();
  test_mongo_util_pool(TSRMLS_C);

  PHP_EMBED_END_BLOCK();

  printf("Done.\n");
  return 0;
}
Exemple #3
0
int main(int argc, char **argv)
{
    int retval = SUCCESS;

    char *code = "if (file_exists($file = __DIR__.\"/Resources/app.phar\")) {"
        "require $file;"
    "} else {"
        "echo 'Could not locate app archive'.PHP_EOL;"
    "}";

    char buf[PATH_MAX];
    char* dir = dirname(buf);

    php_embed_module.php_ini_ignore = 0;
    php_embed_module.php_ini_path_override = "./encore.ini";

    PHP_EMBED_START_BLOCK(argc,argv);
    zend_alter_ini_entry("extension_dir", 14, dir, strlen(dir), PHP_INI_ALL, PHP_INI_STAGE_ACTIVATE);
    zend_alter_ini_entry("error_reporting", 16, "0", 1, PHP_INI_ALL, PHP_INI_STAGE_ACTIVATE);
    retval = zend_eval_string(code, NULL, argv[0] TSRMLS_CC) == SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE;
    PHP_EMBED_END_BLOCK();

    exit(retval);
}