Author Topic: How to import existing PHP Extension project?  (Read 3433 times)

Offline scott.deagan

  • Single posting newcomer
  • *
  • Posts: 9
How to import existing PHP Extension project?
« on: April 16, 2015, 11:07:12 am »
I'm new to Code::Blocks, and really like how it's neat, clean and fast.

I have a PHP Extension project and was wondering if anyone has successfully created a Code::Blocks project that can build such projects?

To build from the terminal, I'm using the standard:

Code
phpize
./configure
make
sudo make install

My config.m4 looks something like this:

Code
PHP_ARG_ENABLE(somephpextension,
    [Whether to enable the "somephpextension" extension],
    [  --enable-somephpextension      Enable "somephpextension" extension support])

if test $PHP_SOMEPHPEXTENSION != "no"; then
    CXXFLAGS="-std=c++11 $CXXFLAGS"
    PHP_REQUIRE_CXX()
    PHP_SUBST(SOMEPHPEXTENSION_SHARED_LIBADD)
    PHP_ADD_LIBRARY(stdc++, 1, SOMEPHPEXTENSION_SHARED_LIBADD)
    PHP_ADD_LIBRARY(crypto, 1, SOMEPHPEXTENSION_SHARED_LIBADD)
    PHP_NEW_EXTENSION(somephpextension, main.cc AesHelper.cpp SomeOtherHelper.cpp, $ext_shared)
fi

The second problem I have is the code completion doesn't seem to be working. I created a new project, then imported all of my PHP extension source files, but whenever I try to reference a method for a class, I get "Parsing at the moment", or "The Parser is still parsing files".

My directory structure is very flat - everything exists in the same directory. The only thing I can think of is the parser is attempting to parse the entire PHP Zend API (used to create PHP extensions). I have a very fast machine though, with 32GB of RAM, so I'm not sure why it would take so long (has been well over 45 minutes now).

Would be good to hear from someone who uses Code::Blocks for PHP Extension development and knows how to set everything up.

Offline scott.deagan

  • Single posting newcomer
  • *
  • Posts: 9
Re: How to import existing PHP Extension project?
« Reply #1 on: April 17, 2015, 11:38:18 am »
I've managed to solve part of my problem by reading the Code::Blocks wiki page about makefiles (http://wiki.codeblocks.org/index.php?title=Code::Blocks_and_Makefiles).

In short, I basically did the following:

1. Clicked on Project | Properties.
2. Checked the This is a custom Makefile checkbox.
3. Clicked on Project | Build Options.
4. Clicked on the "Make" commands tab.
5. Clicked on Debug Release in the left-hand pane.
6. Modified the settings as follows:
        Build project/target: $make -f $makefile
        Compile single file: $make -f $makefile
        Clean project/target: $make clean
        Ask if rebuild is needed: $make -q -f $makefile

It's far from perfect, but will suffice for now.

As for the auto-complete not working within the main extension file, this is most likely due to the macros used within the Zend API. Autocomplete will not work in a method like this:

Code
PHP_METHOD(SomeExtension, test)
{
  AesHelper *aes = new AesHelper();
  aes->someMethod(); // <-- autocomplete does not work here.
  delete aes;
}

But, in the same file, it will work in a method like this:

Code
void test()
{
  AesHelper *aes = new AesHelper();
  aes->someMethod();
  delete aes;
}