Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Convert Phalcon-based PHP application into C-extension using Zephir?

Hi, I've built a PHP application based on Phalcon, but I'm wondering if it would be possible to convert most of it into a C-extension by re-writing it with Zephir (at least the controllers and models if not the views). Is that possible? The reason is to better protect my source code because my deployment locations are not too secure.

Thanks!



1.6k

I personally think it is possible, and it gives you some advantages like speed and less resources used. Some could give you a better answer than me but i've recently made a class in php/phalcon and the same class in Zephir - both extending the same existing core Phalcon class. PHP available classess and functions are exposed in Zephir. So if this was possible form me - i am really not an experienced Zephir developer - it will be possible for you.

Example of the class i've mentioned in Zephir: https://forum.phalconphp.com/discussion/7863/zephir-sqlite-createtable-droptable-implementation-for-phalcon

The same class in PHP (in two 2 topics the class actually - sorry for that): https://forum.phalconphp.com/discussion/7835/sqlite-dropcolumn-implementation-+-remembering-createtable

It took me 4-5 hours about to translate having not that much knowledge.



973
Accepted
answer

Thanks @OpenEx. Sorry for coming back to this after such a long time. Happy to confirm that it is indeed possible to create your own PHP extension using Zephir, and then using its classes and methods just like you would use Phalcon's classes and methods from PHP code. In addition, you can also use Phalcon's classes and methods from within your Zephir code as well.