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.

What is the process of debugging and making changes to phalcon?

I want to play with zephir and phalcon.

So I installed zephir. Got the phalcon source:

git clone https://github.com/phalcon/cphalcon -b 2.0.x --single-branch 

And then, as I have very little experience with compiled languages, I got stuck. For example in C/C++, etc. I can set breakpoints and then debug my application. What my strategy should be with zephir?

Say, I have a variable in the code, and I want to know the value of it. Is it possible to somehow get that value after phalcon source is compiled and I run my php? Or, may be, there is some way to avoid such compilation?

And going even further what the development routine of people who fix phalcon bugs and making changes to the source? How they test the code? It is hard to imagine they have to recompile all the source code all the time during the development. This is really time consuming.

In the zephir helper I see:

builddev            Generate/Compile/Install a Zephir extension in development mode

But is there a good tutorial on how to use this?

Thank you in advance.



114.4k
Accepted
answer

Well, only way is to var_dump(variable); die();. You test code just by writing proper test in php. Just check phalcon repository and tests folder https://github.com/phalcon/cphalcon/tree/2.1.x/tests

Beacause of how phalcon works - it's need to compiled and executed by php as extenstion there is no other way to debug/test it. Just edit proper .zep file and write zephir build and restart your apache/php-fpm.

Compiling is not really such a compilcated process though. Each namespace(or class? i don't know exactly) is compiled into one .lo file, then all of them are builded into phalcon.so file. So pretty much if we changing something we only need to recompile this .lo file which contatins changes. It's not so slow how you think. It's just like a few seconds.



1.0k

I can write this in zephir var_dump(variable); die();? Maybe there is an easy way to log that variable instead of stoping the whole thing with die()?

Well, only way is to var_dump(variable); die();. You test code just by writing proper test in php. Just check phalcon repository and tests folder https://github.com/phalcon/cphalcon/tree/2.1.x/tests

Beacause of how phalcon works - it's need to compiled and executed by php as extenstion there is no other way to debug/test it. Just edit proper .zep file and write zephir build and restart your apache/php-fpm.

Compiling is not really such a compilcated process though. Each namespace(or class? i don't know exactly) is compiled into one .lo file, then all of them are builded into phalcon.so file. So pretty much if we changing something we only need to recompile this .lo file which contatins changes. It's not so slow how you think. It's just like a few seconds.

If there is one - then i don't know about it. Well - you can create logger in your di in php and access it in zephir code and log it there always.