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

Help with PHP-CPP #362

Open
Humberto90 opened this issue Dec 22, 2017 · 5 comments
Open

Help with PHP-CPP #362

Humberto90 opened this issue Dec 22, 2017 · 5 comments

Comments

@Humberto90
Copy link

Hello,
I am interested in developing an extension for php using the PHP-CPP library. I need to implement an extension that modifies the .php files before they are sent to the apache server. Is this possible with the PHP-CPP library?
thanks for your help

@Humberto90
Copy link
Author

The extension that I need to develop must identify encrypted files and desencriotar them before being sent to the interpreter.
Can you suggest any ideas to achieve it?
I hope you answer me,
best regards,
Humberto

@sjinks
Copy link
Contributor

sjinks commented Jan 3, 2018

Yes, you set up your own hook for zend_compile_file during module initialization, and then in your zend_compile_file handle / decrypt the encrypted file and, say, pass the result to the original zend_compile_file or zend_compile_string.

PHP's ext/phar can be the source of inspiration.

@Humberto90
Copy link
Author

Thanks for your reply. I have tried what it suggests, I managed to implement an extension using the Zen API and it has worked correctly, but I have some doubts about how to implement it using the PHP-CPP library. For example, to configure my hook for zend_compile_file in my extension, I need access to the data type zend_op_array ,

What header should I include?

I apologize for my lack of experience, but I appreciate your cooperation.

@sjinks
Copy link
Contributor

sjinks commented Jan 5, 2018

#include <Zend/zend_compile.h>

@sjinks
Copy link
Contributor

sjinks commented Jan 5, 2018

When compiling your extension, you will need to pass $(shell php-config --includes) to the compiler

ie:

%.o: %.cpp
	$(CXX) $(CPPFLAGS) $(shell php-config --includes) $(CXXFLAGS) -c "$<" -o "$@"

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

No branches or pull requests

2 participants