We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Use Phalcon from Zephir module

Hello!

I decided to rewrite my Phalcon project to Zephir. It is necessary to improve performance and hide of the source code of the site.

To do this, I needed to call the Phalcon classes from my Zephir module. This is done by well-known instructions here:

https://github.com/phalcon/zephir/issues/304#issuecomment-61341940

What confuses me? My project is a minimum of possibilities but the compiled extension weighs more than 100 KB! Before I turned on usage of Phalcon classes - my project weighed a couple of tens of kilobytes.

Prompt, it's okay, I have to worry about it? Why so much weight, after all Phalcon is also connected to php, and it turns out that it is included also in my module? And as it can degrade the performance if I correctly understood?

Thank you!

Don't worry about it. Also what php version ? Is it debug version perhaps ? Write php -v and post result. Also this is more like zephi problem so go for zephir forum :)



1.4k

My php -v out:

PHP 5.6.27-1+deb.sury.org~xenial+1 (cli) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

Still, there is doubts over the size of the extension?

On php 5.6 there always will be larger extension size i think.



1.4k

Migrate to php 7?

edited Oct '16

No, 100kb is nothing. C code will be much bigger than php code.



1.4k

I understand, but before I begun to use the Phalcon classes - the size was much smaller. It seems that these classes are embedded in my Zephir module. But why, when the Phalcon is already installed in php? I am afraid that this will lead to decrease performance. And if in php disable Phalcon extension - my Zephir module does not work.

edited Oct '16

No, it won't, extension is loaded ONLY on loading php. This doesn't affect performance anyhow. When you started using phalcon classes in your zephir module it needed to add header files to your extension so when compiling C it don't complain about non-existing things.

This doesn't affect performance any way. Even if would be 5mb then only time it would affect perfromance is when loading extension on php startup, otherwise it doesn't performance when application is already working and requests are being made.



1.4k

Thank you very much, now I will no longer worry about extension size and will continue to rewrite my project to Zephir! ;)



1.4k
edited Oct '16

Strange... I am now opened the compiled extension in a text editor and see what there is available a lot of text data from my source code... How can this be? :(((

It looks like I did a meaningless job, overwriting the project to Zephir for protect my source code...

Well text data will be kept as text data obviously :)



1.4k

Well, what kind text data can be freely read after compilation?