Library to build PHP extensions with C++

Related tags

Scripting PHP-CPP
Overview

PHP-CPP

Build Status

The PHP-CPP library is a C++ library for developing PHP extensions. It offers a collection of well documented and easy-to-use classes that can be used and extended to build native extensions for PHP. The full documentation can be found on http://www.php-cpp.com.

Watch out: PHP 7 only! This library has been updated to work with PHP versions 7.0 and up. If you wish to create extensions for older PHP versions, use the PHP-CPP-LEGACY library instead. The PHP-CPP and PHP-CPP-LEGACY library have (almost) identical API's, so you can easily port extensions for PHP 5.* to PHP 7 and the other way around.

ABOUT

PHP-CPP is created and maintained by Copernica (www.copernica.com). We write our code mostly in PHP and C++ and needed an effective way to combine these two languages. That's where PHP-CPP comes in. Do you appreciate our work and are you looking for other high quality solutions?

Then check out our other solutions:

The power of PHP-CPP

Unlike regular PHP extensions - which are really hard to implement and require a deep knowledge of the Zend engine and pointer manipulation - extensions built with PHP-CPP are not difficult to develop at all. In fact, the only thing you need to do is write a function in C++, and the PHP-CPP library uses all the power offered by C++11 to convert the parameters and return values from your functions to/and from PHP:

Php::Value hello_world()
{
    return "hello world!";
}

The function above is a native C++ function. With PHP-CPP you can export this function to PHP with only one single C++ method call:

extension.add("hello_world", hello_world);

Working with parameters and return values is just as easy:

Php::Value my_plus(Php::Parameters &params)
{
    return params[0] + params[1];
}

The method call to export the above C++ function:

extension.add<my_plus>("my_plus", {
    Php::ByVal("a", Php::numericType),
    Php::ByVal("b", Php::numericType)
});

The PHP-CPP library ensures that the variables from PHP (which internally are complicated C structures), are automatically converted into integers, passed to your function, and that the return value of your "my_plus" function is also converted back into a PHP variable.

Type conversion between native C/C++ types and PHP variables is handled by PHP-CPP, using features from the C++11 language. It does not matter if your functions accept strings, integers, booleans or other native parameters: PHP-CPP takes care of the conversion. The return value of your function is also transformed by PHP-CPP into PHP.

More complicated structures can be handled by PHP-CPP as well. If you would like to return a nested associative array from your function, you can do so too:

Php::Value get_complex_array()
{
    Php::Value r;
    r["a"] = 123;
    r["b"] = 456;
    r["c"][0] = "nested value";
    r["c"][1] = "example";
    return r;
}

The C++ function above is equivalent to the following function in PHP:

function get_complex_array()
{
    return array(
        "a" => 123,
        "b" => 456,
        "c" => array("nested_value","example")
    );
}

More information and more examples are available on the official website: http://www.php-cpp.com.

Comments
  • Windows build

    Windows build

    Hi,

    As part of making php-cpp builds using config file, I began to port it to windows (using vc13 and later vc11 to match upstream windows binary).

    1st result:

    https://gist.github.com/pierrejoye/593d8bf8ba3c5a81987c

    Looks like some cpp features used need some tweeks.

    besides:

    1st config.w32 (pretty much the same then for config.m4):

    // vim:ft=javascript // $Id$

    ARG_ENABLE('php-cpp', 'Enable php-cpp library', 'no');

    if (PHP_PHP_CPP != "no") { ADD_SOURCES("sapi/php-cpp/src", "argument.cpp base.cpp callable.cpp classbase.cpp exception.cpp global.cpp globals.cpp
    hashmember.cpp iterator.cpp members.cpp modifiers.cpp namespace.cpp object.cpp origexception.cpp
    parameters.cpp streambuf.cpp streams.cpp super.cpp value.cpp valueiterator.cpp", "phpcpp"); SAPI('phpcpp', 'src/extension.cpp', 'php' + PHP_VERSION + 'phpcpp.lib'); // PHP_INSTALL_HEADERS("sapi/phpcpp", "src/*.h"); }

    it will allow to build php-cpp as part of php as a "sapi", which makes allows some optimizations later. Once it works I will try to provide another one to rely only on phpize, so php-cpp can be distributed easily.

    opened by pierrejoye 54
  • Install PHP-CPP and write first extension

    Install PHP-CPP and write first extension

    Hi, i am trying install php-cpp on centos 6.5. when i run make command, it return success. and when i run make test, i got some test which is not passed yet.

    Number of tests :   44                44
    Tests skipped   :    0 (  0.0%) --------
    Tests warned    :    0 (  0.0%) (  0.0%)
    Tests failed    :    8 ( 18.2%) ( 18.2%)
    Expected fail   :    0 (  0.0%) (  0.0%)
    Tests passed    :   36 ( 81.8%) ( 81.8%)
    ---------------------------------------------------------------------
    Time taken      :    5 seconds
    =====================================================================
    
    =====================================================================
    FAILED TEST SUMMARY
    ---------------------------------------------------------------------
    Test Php::Value object #2 [php/phpt/variables/010-value-object2.phpt]
    Test Php::Value casting operators (64bit OS only) [php/phpt/variables/011-value-casting-operators.phpt]
    Test Php::Value casting operators (double) [php/phpt/variables/012-value-casting-operators-double.phpt]
    calling-php-functions from userspace [php/phpt/variables/013-calling-php-functions.phpt]
    calling-php-Callback-functions [php/phpt/variables/014-calling-php-functions.phpt]
    calling-php-Callback-functions (lambda) [php/phpt/variables/015-calling-php-functions.phpt]
    calling-php-Callback-functions (__invoke) [php/phpt/variables/016-calling-php-functions.phpt]
    calling-php-Callback-functions (method of class) [php/phpt/variables/017-calling-php-functions.phpt]
    =====================================================================
    

    this is my server info

    PHP 5.6.2 (cli) (built: Nov  6 2014 21:20:44)
    Linux localhost.localdomain 2.6.32-504.1.3.el6.x86_64 #1 SMP Tue Nov 11 17:57:25 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
    gcc (GCC) 4.7.2 20121015 (Red Hat 4.7.2-5)
    

    When i created a hello extenstion flow http://www.sitepoint.com/getting-started-php-extension-development-via-php-cpp/ and i build success, when i test function, i get a warning:

    [Mon Dec 08 16:34:57 2014] [error] [client 192.168.1.5] PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20131226/skeleton.so' - libphpcpp.so: cannot open shared object file: No such file or directory in Unknown on line 0
    

    how i can fixed it. /usr/lib/php/extensions/no-debug-non-zts-20131226/skeleton.so is exist.

    main.cpp

    #include <phpcpp.h>
    #include <iostream>
    
    void helloWorld (Php::Parameters &params)
    {
        std::string name=params[0];
        std::cout<<"Hello "<<name<<"!"<<std::endl;
    
    }
    
    extern "C" {
    
        PHPCPP_EXPORT void *get_module() 
        {
            static Php::Extension extension("skeleton", "1.0");
            extension.add("helloWorld", helloWorld);
    
            return extension;
        }
    } 
    

    Makefile

    NAME                =   skeleton
    INI_DIR             =   /etc/httpd/php.d/default
    EXTENSION_DIR       =   $(shell php-config --extension-dir)
    EXTENSION           =   ${NAME}.so
    INI                 =   ${NAME}.ini
    COMPILER            =   g++
    LINKER              =   g++
    COMPILER_FLAGS      =   -Wall -c -O2 -std=c++11 -fpic -o
    LINKER_FLAGS        =   -shared
    LINKER_DEPENDENCIES =   -lphpcpp
    RM                  =   rm -f
    CP                  =   cp -f
    MKDIR               =   mkdir -p
    SOURCES             =   $(wildcard *.cpp)
    OBJECTS             =   $(SOURCES:%.cpp=%.o)
    
    all:                    ${OBJECTS} ${EXTENSION}
    
    ${EXTENSION}:           ${OBJECTS}
                            ${LINKER} ${LINKER_FLAGS} -o $@ ${OBJECTS} ${LINKER_DEPENDENCIES}
    
    ${OBJECTS}:
                            ${COMPILER} ${COMPILER_FLAGS} $@ ${@:%.o=%.cpp}
    
    install:        
                            ${CP} ${EXTENSION} ${EXTENSION_DIR}
                            ${CP} ${INI} ${INI_DIR}
    
    clean:
                            ${RM} ${EXTENSION} ${OBJECTS}
    

    skeleton.ini

    extension=skeleton.so
    

    Thanks

    opened by hugdx 28
  • Native iterate through arrays and objects of type Value

    Native iterate through arrays and objects of type Value

    Iterate over arrays and objects of type Value

    I propose to consider the iteration of arrays and objects without the use of additional containers.

    A few examples:

        void loopValue(Php::Parameters &params)
        {
            std::cout << "\nArray/Object contains " << params[0].size() << " items" << std::endl;
    
            // Preferred variant
            // Value::iterator& Value::end() is called only once
            for(auto &i: params[0]) {
                std::cout << "\n["<< i.ind() << "]:["<< i.key() << "]=" << i.value() << "\t | \t" << i.typestr();
            }
    
    
            // Possible variant
            // Value::iterator& Value::end() is called with each iteration
            for (auto it=params[0].begin(); it!=params[0].end(); it++) {
                std::cout << "\n["<< it->ind() << "]:["<< it->key() << "]=" << it->value() << "\t | \t" << it->typestr();
            }
    
    
            // Recursive iterations
            Php::Value v;
            for(auto &i: params[0]) {
                v = i.value();
                std::cout << std::endl << "["<< i.ind() << "]:["<< i.key() << "]=" << v << "\t | \t" << i.typestr();
                for(auto &j: v) {
                    std::cout << std::endl << "\t["<< j.ind() << "]:["<< j.key() << "]="<< j.value();
                }
            }
            std::cout << std::endl;
        }
    

    Iteration method

            for(auto &i: params[0]) {...}
    

    is more convenient and less expensive, but if someone can conveniently otherwise, he can iterate and in this way:

            for (auto it=params[0].begin(); it!=params[0].end(); it++) { {...}
    

    or this:

            for (Value::iterator it=params[0].begin(); it!=params[0].end(); ++it) { {...}
    

    A few words about using. Value::iterator supports the following methods:

    Value::iterator it;
    
    /**
    *  Retrieve a string key of element of the array
    *  the same as (*it).key();
    * 
    *  @return std::string
    */
    it->key(); 
    
    /**
    *  Retrieve a integer key (index) of element of the array
    *  the same as (*it).ind();
    * 
    *  @return unsigned long
    */
    it->ind(); 
    
    /**
    *  key type is string?
    *  true ‒ string, false ‒ integer
    *  the same as (*it).isstr();
    * 
    *  @return bool
    */
    it->isstr(); 
    
    /**
    *  debug function
    *  the same as (*it).typestr();
    *  if key type is string, return "str", else return "num"
    * 
    *  @return const char *
    */
    it->typestry(); 
    

    Now this new feature allows just iterate through in one direction. If necessary, it possible deepen and enhance functionality. At this point, this iterator is not a iterator is compatible with STL C++11 and does not support the corresponding algorithms.

    Why iteration in a way better than iterating through Value::mapValue():

    1. Firstly preserved the original order of elements in the array.
    2. This method is faster, as the passage is provided once, while using Value::mapValue(), we first fill std::map<std::string,Php::Value> result, and then iterate through the filled container. In addition, there is an economy to initialize the container std::map and operations over them.
    3. It is very convenient.
    opened by valmat 22
  • Compiling errors with phpbrew's version

    Compiling errors with phpbrew's version

    I'm trying to compile using a phpbrew version of PHP, and I'm getting this errors:

    make                                                                                               drgomesp@MacBook-Pro-de-Daniel
    g++ -Wall -c -I. -I/Users/drgomesp/.phpbrew/php/php-5.5.1/include/php -I/Users/drgomesp/.phpbrew/php/php-5.5.1/include/php/main -I/Users/drgomesp/.phpbrew/php/php-5.5.1/include/php/ext -I/Users/drgomesp/.phpbrew/php/php-5.5.1/include/php/Zend -I/Users/drgomesp/.phpbrew/php/php-5.5.1/include/php/TSRM -g -std=c++11 -fpic -o src/value.o src/value.cpp
    src/value.cpp:690:62: error: call to member function 'operator=' is ambiguous
    Value &Value::operator%=(const Value &value)        { return operator=(numericValue() % value.numericValue()); }
                                                                 ^~~~~~~~~
    src/value.cpp:469:15: note: candidate function
    Value &Value::operator=(int16_t value)
                  ^
    src/value.cpp:489:15: note: candidate function
    Value &Value::operator=(int32_t value)
                  ^
    src/value.cpp:509:15: note: candidate function
    Value &Value::operator=(int64_t value)
                  ^
    src/value.cpp:529:15: note: candidate function
    Value &Value::operator=(bool value)
                  ^
    src/value.cpp:549:15: note: candidate function
    Value &Value::operator=(char value)
                  ^
    src/value.cpp:609:15: note: candidate function
    Value &Value::operator=(double value)
                  ^
    src/value.cpp:332:15: note: candidate function
    Value &Value::operator=(Value &&value)
                  ^
    src/value.cpp:402:15: note: candidate function
    Value &Value::operator=(const Value &value)
                  ^
    src/value.cpp:449:15: note: candidate function not viable: no known conversion from 'long' to 'std::nullptr_t' (aka 'nullptr_t') for 1st argument
    Value &Value::operator=(std::nullptr_t value)
                  ^
    src/value.cpp:569:15: note: candidate function not viable: no known conversion from 'long' to 'const std::string' (aka 'const basic_string<char, char_traits<char>,
          allocator<char> >') for 1st argument
    Value &Value::operator=(const std::string &value)
                  ^
    src/value.cpp:589:15: note: candidate function not viable: no known conversion from 'long' to 'const char *' for 1st argument
    Value &Value::operator=(const char *value)
                  ^
    src/value.cpp:691:62: error: call to member function 'operator=' is ambiguous
    Value &Value::operator%=(int16_t value)             { return operator=(numericValue() % value); }
                                                                 ^~~~~~~~~
    src/value.cpp:469:15: note: candidate function
    Value &Value::operator=(int16_t value)
                  ^
    src/value.cpp:489:15: note: candidate function
    Value &Value::operator=(int32_t value)
                  ^
    src/value.cpp:509:15: note: candidate function
    Value &Value::operator=(int64_t value)
                  ^
    src/value.cpp:529:15: note: candidate function
    Value &Value::operator=(bool value)
                  ^
    src/value.cpp:549:15: note: candidate function
    Value &Value::operator=(char value)
                  ^
    src/value.cpp:609:15: note: candidate function
    Value &Value::operator=(double value)
                  ^
    src/value.cpp:332:15: note: candidate function
    Value &Value::operator=(Value &&value)
                  ^
    src/value.cpp:402:15: note: candidate function
    Value &Value::operator=(const Value &value)
                  ^
    src/value.cpp:449:15: note: candidate function not viable: no known conversion from 'long' to 'std::nullptr_t' (aka 'nullptr_t') for 1st argument
    Value &Value::operator=(std::nullptr_t value)
                  ^
    src/value.cpp:569:15: note: candidate function not viable: no known conversion from 'long' to 'const std::string' (aka 'const basic_string<char, char_traits<char>,
          allocator<char> >') for 1st argument
    Value &Value::operator=(const std::string &value)
                  ^
    src/value.cpp:589:15: note: candidate function not viable: no known conversion from 'long' to 'const char *' for 1st argument
    Value &Value::operator=(const char *value)
                  ^
    src/value.cpp:692:62: error: call to member function 'operator=' is ambiguous
    Value &Value::operator%=(int32_t value)             { return operator=(numericValue() % value); }
                                                                 ^~~~~~~~~
    src/value.cpp:469:15: note: candidate function
    Value &Value::operator=(int16_t value)
                  ^
    src/value.cpp:489:15: note: candidate function
    Value &Value::operator=(int32_t value)
                  ^
    src/value.cpp:509:15: note: candidate function
    Value &Value::operator=(int64_t value)
                  ^
    src/value.cpp:529:15: note: candidate function
    Value &Value::operator=(bool value)
                  ^
    src/value.cpp:549:15: note: candidate function
    Value &Value::operator=(char value)
                  ^
    src/value.cpp:609:15: note: candidate function
    Value &Value::operator=(double value)
                  ^
    src/value.cpp:332:15: note: candidate function
    Value &Value::operator=(Value &&value)
                  ^
    src/value.cpp:402:15: note: candidate function
    Value &Value::operator=(const Value &value)
                  ^
    src/value.cpp:449:15: note: candidate function not viable: no known conversion from 'long' to 'std::nullptr_t' (aka 'nullptr_t') for 1st argument
    Value &Value::operator=(std::nullptr_t value)
                  ^
    src/value.cpp:569:15: note: candidate function not viable: no known conversion from 'long' to 'const std::string' (aka 'const basic_string<char, char_traits<char>,
          allocator<char> >') for 1st argument
    Value &Value::operator=(const std::string &value)
                  ^
    src/value.cpp:589:15: note: candidate function not viable: no known conversion from 'long' to 'const char *' for 1st argument
    Value &Value::operator=(const char *value)
                  ^
    src/value.cpp:694:62: error: call to member function 'operator=' is ambiguous
    Value &Value::operator%=(bool value)                { return operator=(numericValue() % value); }
                                                                 ^~~~~~~~~
    src/value.cpp:469:15: note: candidate function
    Value &Value::operator=(int16_t value)
                  ^
    src/value.cpp:489:15: note: candidate function
    Value &Value::operator=(int32_t value)
                  ^
    src/value.cpp:509:15: note: candidate function
    Value &Value::operator=(int64_t value)
                  ^
    src/value.cpp:529:15: note: candidate function
    Value &Value::operator=(bool value)
                  ^
    src/value.cpp:549:15: note: candidate function
    Value &Value::operator=(char value)
                  ^
    src/value.cpp:609:15: note: candidate function
    Value &Value::operator=(double value)
                  ^
    src/value.cpp:332:15: note: candidate function
    Value &Value::operator=(Value &&value)
                  ^
    src/value.cpp:402:15: note: candidate function
    Value &Value::operator=(const Value &value)
                  ^
    src/value.cpp:449:15: note: candidate function not viable: no known conversion from 'long' to 'std::nullptr_t' (aka 'nullptr_t') for 1st argument
    Value &Value::operator=(std::nullptr_t value)
                  ^
    src/value.cpp:569:15: note: candidate function not viable: no known conversion from 'long' to 'const std::string' (aka 'const basic_string<char, char_traits<char>,
          allocator<char> >') for 1st argument
    Value &Value::operator=(const std::string &value)
                  ^
    src/value.cpp:589:15: note: candidate function not viable: no known conversion from 'long' to 'const char *' for 1st argument
    Value &Value::operator=(const char *value)
                  ^
    src/value.cpp:695:62: error: call to member function 'operator=' is ambiguous
    Value &Value::operator%=(char value)                { return operator=(numericValue() % value); }
                                                                 ^~~~~~~~~
    src/value.cpp:469:15: note: candidate function
    Value &Value::operator=(int16_t value)
                  ^
    src/value.cpp:489:15: note: candidate function
    Value &Value::operator=(int32_t value)
                  ^
    src/value.cpp:509:15: note: candidate function
    Value &Value::operator=(int64_t value)
                  ^
    src/value.cpp:529:15: note: candidate function
    Value &Value::operator=(bool value)
                  ^
    src/value.cpp:549:15: note: candidate function
    Value &Value::operator=(char value)
                  ^
    src/value.cpp:609:15: note: candidate function
    Value &Value::operator=(double value)
                  ^
    src/value.cpp:332:15: note: candidate function
    Value &Value::operator=(Value &&value)
                  ^
    src/value.cpp:402:15: note: candidate function
    Value &Value::operator=(const Value &value)
                  ^
    src/value.cpp:449:15: note: candidate function not viable: no known conversion from 'long' to 'std::nullptr_t' (aka 'nullptr_t') for 1st argument
    Value &Value::operator=(std::nullptr_t value)
                  ^
    src/value.cpp:569:15: note: candidate function not viable: no known conversion from 'long' to 'const std::string' (aka 'const basic_string<char, char_traits<char>,
          allocator<char> >') for 1st argument
    Value &Value::operator=(const std::string &value)
                  ^
    src/value.cpp:589:15: note: candidate function not viable: no known conversion from 'long' to 'const char *' for 1st argument
    Value &Value::operator=(const char *value)
                  ^
    src/value.cpp:696:62: error: call to member function 'operator=' is ambiguous
    Value &Value::operator%=(const std::string &value)  { return operator=(numericValue() % atoi(value.c_str())); }
                                                                 ^~~~~~~~~
    src/value.cpp:469:15: note: candidate function
    Value &Value::operator=(int16_t value)
                  ^
    src/value.cpp:489:15: note: candidate function
    Value &Value::operator=(int32_t value)
                  ^
    src/value.cpp:509:15: note: candidate function
    Value &Value::operator=(int64_t value)
                  ^
    src/value.cpp:529:15: note: candidate function
    Value &Value::operator=(bool value)
                  ^
    src/value.cpp:549:15: note: candidate function
    Value &Value::operator=(char value)
                  ^
    src/value.cpp:609:15: note: candidate function
    Value &Value::operator=(double value)
                  ^
    src/value.cpp:332:15: note: candidate function
    Value &Value::operator=(Value &&value)
                  ^
    src/value.cpp:402:15: note: candidate function
    Value &Value::operator=(const Value &value)
                  ^
    src/value.cpp:449:15: note: candidate function not viable: no known conversion from 'long' to 'std::nullptr_t' (aka 'nullptr_t') for 1st argument
    Value &Value::operator=(std::nullptr_t value)
                  ^
    src/value.cpp:569:15: note: candidate function not viable: no known conversion from 'long' to 'const std::string' (aka 'const basic_string<char, char_traits<char>,
          allocator<char> >') for 1st argument
    Value &Value::operator=(const std::string &value)
                  ^
    src/value.cpp:589:15: note: candidate function not viable: no known conversion from 'long' to 'const char *' for 1st argument
    Value &Value::operator=(const char *value)
                  ^
    src/value.cpp:697:62: error: call to member function 'operator=' is ambiguous
    Value &Value::operator%=(const char *value)         { return operator=(numericValue() % atoi(value)); }
                                                                 ^~~~~~~~~
    src/value.cpp:469:15: note: candidate function
    Value &Value::operator=(int16_t value)
                  ^
    src/value.cpp:489:15: note: candidate function
    Value &Value::operator=(int32_t value)
                  ^
    src/value.cpp:509:15: note: candidate function
    Value &Value::operator=(int64_t value)
                  ^
    src/value.cpp:529:15: note: candidate function
    Value &Value::operator=(bool value)
                  ^
    src/value.cpp:549:15: note: candidate function
    Value &Value::operator=(char value)
                  ^
    src/value.cpp:609:15: note: candidate function
    Value &Value::operator=(double value)
                  ^
    src/value.cpp:332:15: note: candidate function
    Value &Value::operator=(Value &&value)
                  ^
    src/value.cpp:402:15: note: candidate function
    Value &Value::operator=(const Value &value)
                  ^
    src/value.cpp:449:15: note: candidate function not viable: no known conversion from 'long' to 'std::nullptr_t' (aka 'nullptr_t') for 1st argument
    Value &Value::operator=(std::nullptr_t value)
                  ^
    src/value.cpp:569:15: note: candidate function not viable: no known conversion from 'long' to 'const std::string' (aka 'const basic_string<char, char_traits<char>,
          allocator<char> >') for 1st argument
    Value &Value::operator=(const std::string &value)
                  ^
    src/value.cpp:589:15: note: candidate function not viable: no known conversion from 'long' to 'const char *' for 1st argument
    Value &Value::operator=(const char *value)
                  ^
    src/value.cpp:698:62: error: call to member function 'operator=' is ambiguous
    Value &Value::operator%=(double value)              { return operator=(numericValue() % (int)value); }
                                                                 ^~~~~~~~~
    src/value.cpp:469:15: note: candidate function
    Value &Value::operator=(int16_t value)
                  ^
    src/value.cpp:489:15: note: candidate function
    Value &Value::operator=(int32_t value)
                  ^
    src/value.cpp:509:15: note: candidate function
    Value &Value::operator=(int64_t value)
                  ^
    src/value.cpp:529:15: note: candidate function
    Value &Value::operator=(bool value)
                  ^
    src/value.cpp:549:15: note: candidate function
    Value &Value::operator=(char value)
                  ^
    src/value.cpp:609:15: note: candidate function
    Value &Value::operator=(double value)
                  ^
    src/value.cpp:332:15: note: candidate function
    Value &Value::operator=(Value &&value)
                  ^
    src/value.cpp:402:15: note: candidate function
    Value &Value::operator=(const Value &value)
                  ^
    src/value.cpp:449:15: note: candidate function not viable: no known conversion from 'long' to 'std::nullptr_t' (aka 'nullptr_t') for 1st argument
    Value &Value::operator=(std::nullptr_t value)
                  ^
    src/value.cpp:569:15: note: candidate function not viable: no known conversion from 'long' to 'const std::string' (aka 'const basic_string<char, char_traits<char>,
          allocator<char> >') for 1st argument
    Value &Value::operator=(const std::string &value)
                  ^
    src/value.cpp:589:15: note: candidate function not viable: no known conversion from 'long' to 'const char *' for 1st argument
    Value &Value::operator=(const char *value)
                  ^
    src/value.cpp:765:62: error: ambiguous conversion for functional-style cast from 'long' to 'Php::Value'
    Value Value::operator%(const Value &value)          { return Value(numericValue() % value.numericValue()); }
                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/value.cpp:58:8: note: candidate constructor
    Value::Value(int16_t value)
           ^
    src/value.cpp:69:8: note: candidate constructor
    Value::Value(int32_t value)
           ^
    src/value.cpp:80:8: note: candidate constructor
    Value::Value(int64_t value)
           ^
    src/value.cpp:91:8: note: candidate constructor
    Value::Value(bool value)
           ^
    src/value.cpp:102:8: note: candidate constructor
    Value::Value(char value)
           ^
    src/value.cpp:136:8: note: candidate constructor
    Value::Value(double value)
           ^
    src/value.cpp:208:8: note: candidate constructor
    Value::Value(const Value &that)
           ^
    src/value.cpp:265:8: note: candidate constructor
    Value::Value(Value &&that)
           ^
    src/value.cpp:766:62: error: ambiguous conversion for functional-style cast from 'long' to 'Php::Value'
    Value Value::operator%(int16_t value)               { return Value(numericValue() % value); }
                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/value.cpp:58:8: note: candidate constructor
    Value::Value(int16_t value)
           ^
    src/value.cpp:69:8: note: candidate constructor
    Value::Value(int32_t value)
           ^
    src/value.cpp:80:8: note: candidate constructor
    Value::Value(int64_t value)
           ^
    src/value.cpp:91:8: note: candidate constructor
    Value::Value(bool value)
           ^
    src/value.cpp:102:8: note: candidate constructor
    Value::Value(char value)
           ^
    src/value.cpp:136:8: note: candidate constructor
    Value::Value(double value)
           ^
    src/value.cpp:208:8: note: candidate constructor
    Value::Value(const Value &that)
           ^
    src/value.cpp:265:8: note: candidate constructor
    Value::Value(Value &&that)
           ^
    src/value.cpp:767:62: error: ambiguous conversion for functional-style cast from 'long' to 'Php::Value'
    Value Value::operator%(int32_t value)               { return Value(numericValue() % value); }
                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/value.cpp:58:8: note: candidate constructor
    Value::Value(int16_t value)
           ^
    src/value.cpp:69:8: note: candidate constructor
    Value::Value(int32_t value)
           ^
    src/value.cpp:80:8: note: candidate constructor
    Value::Value(int64_t value)
           ^
    src/value.cpp:91:8: note: candidate constructor
    Value::Value(bool value)
           ^
    src/value.cpp:102:8: note: candidate constructor
    Value::Value(char value)
           ^
    src/value.cpp:136:8: note: candidate constructor
    Value::Value(double value)
           ^
    src/value.cpp:208:8: note: candidate constructor
    Value::Value(const Value &that)
           ^
    src/value.cpp:265:8: note: candidate constructor
    Value::Value(Value &&that)
           ^
    src/value.cpp:769:62: error: ambiguous conversion for functional-style cast from 'long' to 'Php::Value'
    Value Value::operator%(bool value)                  { return Value(numericValue() % value); }
                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/value.cpp:58:8: note: candidate constructor
    Value::Value(int16_t value)
           ^
    src/value.cpp:69:8: note: candidate constructor
    Value::Value(int32_t value)
           ^
    src/value.cpp:80:8: note: candidate constructor
    Value::Value(int64_t value)
           ^
    src/value.cpp:91:8: note: candidate constructor
    Value::Value(bool value)
           ^
    src/value.cpp:102:8: note: candidate constructor
    Value::Value(char value)
           ^
    src/value.cpp:136:8: note: candidate constructor
    Value::Value(double value)
           ^
    src/value.cpp:208:8: note: candidate constructor
    Value::Value(const Value &that)
           ^
    src/value.cpp:265:8: note: candidate constructor
    Value::Value(Value &&that)
           ^
    src/value.cpp:770:62: error: ambiguous conversion for functional-style cast from 'long' to 'Php::Value'
    Value Value::operator%(char value)                  { return Value(numericValue() % value); }
                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/value.cpp:58:8: note: candidate constructor
    Value::Value(int16_t value)
           ^
    src/value.cpp:69:8: note: candidate constructor
    Value::Value(int32_t value)
           ^
    src/value.cpp:80:8: note: candidate constructor
    Value::Value(int64_t value)
           ^
    src/value.cpp:91:8: note: candidate constructor
    Value::Value(bool value)
           ^
    src/value.cpp:102:8: note: candidate constructor
    Value::Value(char value)
           ^
    src/value.cpp:136:8: note: candidate constructor
    Value::Value(double value)
           ^
    src/value.cpp:208:8: note: candidate constructor
    Value::Value(const Value &that)
           ^
    src/value.cpp:265:8: note: candidate constructor
    Value::Value(Value &&that)
           ^
    src/value.cpp:771:62: error: ambiguous conversion for functional-style cast from 'long' to 'Php::Value'
    Value Value::operator%(const std::string &value)    { return Value(numericValue() % atoi(value.c_str())); }
                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/value.cpp:58:8: note: candidate constructor
    Value::Value(int16_t value)
           ^
    src/value.cpp:69:8: note: candidate constructor
    Value::Value(int32_t value)
           ^
    src/value.cpp:80:8: note: candidate constructor
    Value::Value(int64_t value)
           ^
    src/value.cpp:91:8: note: candidate constructor
    Value::Value(bool value)
           ^
    src/value.cpp:102:8: note: candidate constructor
    Value::Value(char value)
           ^
    src/value.cpp:136:8: note: candidate constructor
    Value::Value(double value)
           ^
    src/value.cpp:208:8: note: candidate constructor
    Value::Value(const Value &that)
           ^
    src/value.cpp:265:8: note: candidate constructor
    Value::Value(Value &&that)
           ^
    src/value.cpp:772:62: error: ambiguous conversion for functional-style cast from 'long' to 'Php::Value'
    Value Value::operator%(const char *value)           { return Value(numericValue() % atoi(value)); }
                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/value.cpp:58:8: note: candidate constructor
    Value::Value(int16_t value)
           ^
    src/value.cpp:69:8: note: candidate constructor
    Value::Value(int32_t value)
           ^
    src/value.cpp:80:8: note: candidate constructor
    Value::Value(int64_t value)
           ^
    src/value.cpp:91:8: note: candidate constructor
    Value::Value(bool value)
           ^
    src/value.cpp:102:8: note: candidate constructor
    Value::Value(char value)
           ^
    src/value.cpp:136:8: note: candidate constructor
    Value::Value(double value)
           ^
    src/value.cpp:208:8: note: candidate constructor
    Value::Value(const Value &that)
           ^
    src/value.cpp:265:8: note: candidate constructor
    Value::Value(Value &&that)
           ^
    src/value.cpp:773:62: error: ambiguous conversion for functional-style cast from 'long' to 'Php::Value'
    Value Value::operator%(double value)                { return Value(numericValue() % (int)value); }
                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/value.cpp:58:8: note: candidate constructor
    Value::Value(int16_t value)
           ^
    src/value.cpp:69:8: note: candidate constructor
    Value::Value(int32_t value)
           ^
    src/value.cpp:80:8: note: candidate constructor
    Value::Value(int64_t value)
           ^
    src/value.cpp:91:8: note: candidate constructor
    Value::Value(bool value)
           ^
    src/value.cpp:102:8: note: candidate constructor
    Value::Value(char value)
           ^
    src/value.cpp:136:8: note: candidate constructor
    Value::Value(double value)
           ^
    src/value.cpp:208:8: note: candidate constructor
    Value::Value(const Value &that)
           ^
    src/value.cpp:265:8: note: candidate constructor
    Value::Value(Value &&that)
           ^
    In file included from src/value.cpp:27:
    In file included from src/includes.h:89:
    src/arithmetic.h:163:16: error: call to member function 'assign' is ambiguous
            return assign(value.numericValue());
                   ^~~~~~
    src/value.cpp:629:90: note: in instantiation of member function 'Php::Arithmetic<std::plus>::assign' requested here
    Value &Value::operator+=(const Value &value)        { return Arithmetic<std::plus>(this).assign(value); }
                                                                                             ^
    src/arithmetic.h:171:12: note: candidate function
        Value &assign(int16_t value)
               ^
    src/arithmetic.h:185:12: note: candidate function
        Value &assign(int32_t value)
               ^
    src/arithmetic.h:199:12: note: candidate function
        Value &assign(int64_t value)
               ^
    src/arithmetic.h:213:12: note: candidate function
        Value &assign(bool value)
               ^
    src/arithmetic.h:227:12: note: candidate function
        Value &assign(char value)
               ^
    src/arithmetic.h:266:12: note: candidate function
        Value &assign(double value)
               ^
    src/arithmetic.h:157:12: note: candidate function
        Value &assign(const Value &value)
               ^
    src/arithmetic.h:244:12: note: candidate function not viable: no known conversion from 'long' to 'const std::string' (aka 'const basic_string<char, char_traits<char>,
          allocator<char> >') for 1st argument
        Value &assign(const std::string &value)
               ^
    src/arithmetic.h:255:12: note: candidate function not viable: no known conversion from 'long' to 'const char *' for 1st argument
        Value &assign(const char *value)
               ^
    src/arithmetic.h:177:24: error: call to member function 'operator=' is ambiguous
            return _value->operator=(F<long>()(_value->numericValue(), value));
                   ~~~~~~~~^~~~~~~~~
    src/value.cpp:630:90: note: in instantiation of member function 'Php::Arithmetic<std::plus>::assign' requested here
    Value &Value::operator+=(int16_t value)             { return Arithmetic<std::plus>(this).assign(value); }
                                                                                             ^
    src/../include/value.h:151:12: note: candidate function
        Value &operator=(int16_t value);
               ^
    src/../include/value.h:152:12: note: candidate function
        Value &operator=(int32_t value);
               ^
    src/../include/value.h:153:12: note: candidate function
        Value &operator=(int64_t value);
               ^
    src/../include/value.h:154:12: note: candidate function
        Value &operator=(bool value);
               ^
    src/../include/value.h:155:12: note: candidate function
        Value &operator=(char value);
               ^
    src/../include/value.h:158:12: note: candidate function
        Value &operator=(double value);
               ^
    src/../include/value.h:142:12: note: candidate function
        Value &operator=(Value &&value);
               ^
    src/../include/value.h:150:12: note: candidate function
        Value &operator=(const Value &value);
               ^
    src/../include/value.h:149:12: note: candidate function not viable: no known conversion from 'long' to 'std::nullptr_t' (aka 'nullptr_t') for 1st argument
        Value &operator=(std::nullptr_t value);
               ^
    src/../include/value.h:156:12: note: candidate function not viable: no known conversion from 'long' to 'const std::string' (aka 'const basic_string<char, char_traits<char>,
          allocator<char> >') for 1st argument
        Value &operator=(const std::string &value);
               ^
    src/../include/value.h:157:12: note: candidate function not viable: no known conversion from 'long' to 'const char *' for 1st argument
        Value &operator=(const char *value);
               ^
    In file included from src/value.cpp:27:
    In file included from src/includes.h:89:
    src/arithmetic.h:191:24: error: call to member function 'operator=' is ambiguous
            return _value->operator=(F<long>()(_value->numericValue(), value));
                   ~~~~~~~~^~~~~~~~~
    src/value.cpp:631:90: note: in instantiation of member function 'Php::Arithmetic<std::plus>::assign' requested here
    Value &Value::operator+=(int32_t value)             { return Arithmetic<std::plus>(this).assign(value); }
                                                                                             ^
    src/../include/value.h:151:12: note: candidate function
        Value &operator=(int16_t value);
               ^
    src/../include/value.h:152:12: note: candidate function
        Value &operator=(int32_t value);
               ^
    src/../include/value.h:153:12: note: candidate function
        Value &operator=(int64_t value);
               ^
    src/../include/value.h:154:12: note: candidate function
        Value &operator=(bool value);
               ^
    src/../include/value.h:155:12: note: candidate function
        Value &operator=(char value);
               ^
    src/../include/value.h:158:12: note: candidate function
        Value &operator=(double value);
               ^
    src/../include/value.h:142:12: note: candidate function
        Value &operator=(Value &&value);
               ^
    src/../include/value.h:150:12: note: candidate function
        Value &operator=(const Value &value);
               ^
    src/../include/value.h:149:12: note: candidate function not viable: no known conversion from 'long' to 'std::nullptr_t' (aka 'nullptr_t') for 1st argument
        Value &operator=(std::nullptr_t value);
               ^
    src/../include/value.h:156:12: note: candidate function not viable: no known conversion from 'long' to 'const std::string' (aka 'const basic_string<char, char_traits<char>,
          allocator<char> >') for 1st argument
        Value &operator=(const std::string &value);
               ^
    src/../include/value.h:157:12: note: candidate function not viable: no known conversion from 'long' to 'const char *' for 1st argument
        Value &operator=(const char *value);
               ^
    fatal error: too many errors emitted, stopping now [-ferror-limit=]
    20 errors generated.
    make: *** [src/value.o] Error 1
    
    opened by drgomesp 21
  • Segmentation fault (core dumped) when Php::out

    Segmentation fault (core dumped) when Php::out

    I run php code,i got success message with cpp codeSegmentation fault (core dumped)

    [root@lifeng-centos7 extension2]# php a.php example output Segmentation fault (core dumped)

    #include <phpcpp.h>
    #include <iostream>
    #include <stdlib.h>
    using namespace std;
    void myFunction()
    {
        Php::out << "example output" << std::endl;
    }
    
    Php::Value myFunction2(){
    if(rand()%2==0){
    return "string";
    }else{
    return 123;
    }
    }
    
    Php::Value sum_everything(Php::Parameters &parameters){
    int result=0;
    for(auto &param : parameters) result+=param;
    return result;
    }
    extern "C" {
        PHPCPP_EXPORT void *get_module() {
            static Php::Extension extension("myFunctions", "1.0");
            extension.add<myFunction>("myFunction");
            extension.add<myFunction2>("myFunction2");
            extension.add<sum_everything>("sum_everything");
            return extension;
        }
    }
    

    php code

    <?php
    echo myFunction();
    
    

    makefile

    COMPILER_FLAGS      =   -Wall -c -O2 -std=c++11 -fpic -o
    LINKER_FLAGS        =   -shared
    LINKER_DEPENDENCIES =   -lphpcpp
    
    
    RM                  =   rm -f
    CP                  =   cp -f
    MKDIR               =   mkdir -p
    
    SOURCES             =   $(wildcard *.cpp)
    OBJECTS             =   $(SOURCES:%.cpp=%.o)
    
    all:                    ${OBJECTS} ${EXTENSION}
    
    ${EXTENSION}:           ${OBJECTS}
                            ${LINKER} ${LINKER_FLAGS} -o $@ ${OBJECTS} ${LINKER_DEPENDENCIES}
    
    ${OBJECTS}:
                            ${COMPILER} ${COMPILER_FLAGS} $@ ${@:%.o=%.cpp}
    
    install:        
                            ${CP} ${EXTENSION} ${EXTENSION_DIR}
                            ${CP} ${INI} ${INI_DIR}
                    
    clean:
                            ${RM} ${EXTENSION} ${OBJECTS}
    
    
    opened by lifenglsf 18
  • Php::eval not working

    Php::eval not working

    I am having a similar problem to another post, however I noticed it was in a closed ticket so wanted to post an open one here.

    Php::eval(" echo 'test'; "); gives an 500 Internal Server Error

    Help would be greatly appreciated!

    Thanks, Tim

    opened by timlamber 16
  • Problem with make on OSX 10.10.2

    Problem with make on OSX 10.10.2

    Following error is coming:

    mkdir -p shared/common
    mkdir -p shared/zend
    mkdir -p shared/hhvm
    c++ -Wall -c -g -std=c++11 `php-config --includes` -fpic -o shared/zend/base.o zend/base.cpp
    
    In file included from zend/base.cpp:8:
    In file included from zend/includes.h:126:
    zend/constantimpl.h:131:18: error: call to member function 'property' is ambiguous
                clss.property(_name, Z_LVAL(_constant.value), Php::Const);
                ~~~~~^~~~~~~~
    zend/../include/classbase.h:236:10: note: candidate function
        void property(const char *name, int16_t value, int flags = Php::Public);
             ^
    zend/../include/classbase.h:237:10: note: candidate function
        void property(const char *name, int32_t value, int flags = Php::Public);
             ^
    zend/../include/classbase.h:238:10: note: candidate function
        void property(const char *name, int64_t value, int flags = Php::Public);
             ^
    zend/../include/classbase.h:239:10: note: candidate function
        void property(const char *name, bool value, int flags = Php::Public);
             ^
    zend/../include/classbase.h:240:10: note: candidate function
        void property(const char *name, char value, int flags = Php::Public);
             ^
    zend/../include/classbase.h:243:10: note: candidate function
        void property(const char *name, double value, int flags = Php::Public);
             ^
    zend/../include/classbase.h:235:10: note: candidate function not viable: no known conversion from 'const long' to 'std::nullptr_t' (aka 'nullptr_t') for 2nd argument
        void property(const char *name, std::nullptr_t value, int flags = Php::Public);
             ^
    zend/../include/classbase.h:241:10: note: candidate function not viable: no known conversion from 'const long' to 'const std::string' (aka 'const basic_string<char, char_traits<char>, allocator<char> >') for
          2nd argument
        void property(const char *name, const std::string &value, int flags = Php::Public);
             ^
    zend/../include/classbase.h:242:10: note: candidate function not viable: no known conversion from 'const long' to 'const char *' for 2nd argument
        void property(const char *name, const char *value, int flags = Php::Public);
             ^
    zend/../include/classbase.h:253:10: note: candidate function not viable: no known conversion from 'const long' to 'const getter_callback_0' (aka 'Php::Value (Php::Base::*const)()') for 2nd argument
        void property(const char *name, const getter_callback_0 &getter, const setter_callback_0 &setter);
             ^
    zend/../include/classbase.h:254:10: note: candidate function not viable: no known conversion from 'const long' to 'const getter_callback_1' (aka 'Php::Value (Php::Base::*const)() const') for 2nd argument
        void property(const char *name, const getter_callback_1 &getter, const setter_callback_0 &setter);
             ^
    zend/../include/classbase.h:255:10: note: candidate function not viable: no known conversion from 'const long' to 'const getter_callback_0' (aka 'Php::Value (Php::Base::*const)()') for 2nd argument
        void property(const char *name, const getter_callback_0 &getter, const setter_callback_1 &setter);
             ^
    zend/../include/classbase.h:256:10: note: candidate function not viable: no known conversion from 'const long' to 'const getter_callback_1' (aka 'Php::Value (Php::Base::*const)() const') for 2nd argument
        void property(const char *name, const getter_callback_1 &getter, const setter_callback_1 &setter);
             ^
    zend/../include/classbase.h:251:10: note: candidate function not viable: requires 2 arguments, but 3 were provided
        void property(const char *name, const getter_callback_0 &getter);
             ^
    zend/../include/classbase.h:252:10: note: candidate function not viable: requires 2 arguments, but 3 were provided
        void property(const char *name, const getter_callback_1 &getter);
             ^
    1 error generated.
    make: *** [shared/zend/base.o] Error 1
    
    opened by vikash 16
  • Can't compile for php7

    Can't compile for php7

    $ make mkdir -p shared/common mkdir -p shared/zend g++ -Wall -c -std=c++11 -fvisibility=hidden -DBUILDING_PHPCPP -Wno-write-strings -g php-config --includes -fpic -o shared/zend/inivalue.o zend/inivalue.cpp In file included from zend/includes.h:130:0, from zend/inivalue.cpp:8: zend/constantimpl.h:85:53: error: macro "ZVAL_STRINGL" passed 4 arguments, but takes just 3 ZVAL_STRINGL(&constant.value, value, len, 0); ^ zend/constantimpl.h:96:65: error: macro "ZVAL_STRINGL" passed 4 arguments, but takes just 3 ZVAL_STRINGL(&constant.value, value, ::strlen(value), 0); ^ zend/constantimpl.h:107:70: error: macro "ZVAL_STRINGL" passed 4 arguments, but takes just 3 ZVAL_STRINGL(&constant.value, value.c_str(), value.size(), 0); ^ In file included from zend/includes.h:104:0, from zend/inivalue.cpp:8: zend/callable.h: In member function ‘void Php::Callable::fill(zend_arg_info, const Php::Argument&) const’: zend/callable.h:146:20: error: cannot convert ‘const char’ to ‘zend_string* {aka zend_string}’ in assignment info->name = arg.name(); ^ zend/callable.h:147:15: error: ‘zend_arg_info {aka struct zend_arg_info}’ has no member named ‘name_len’ info->name_len = ::strlen(arg.name()); ^ zend/callable.h:179:26: error: cannot convert ‘const char’ to ‘zend_string* {aka zend_string}’ in assignment info->class_name = arg.type() == Type::Object ? arg.classname() : nullptr; ^ zend/callable.h:180:15: error: ‘zend_arg_info {aka struct zend_arg_info}’ has no member named ‘class_name_len’ info->class_name_len = arg.type() == Type::Object && arg.classname() ? ::strlen(arg.classname()) : 0; ^ In file included from zend/includes.h:118:0, from zend/inivalue.cpp:8: zend/hashiterator.h: In constructor ‘Php::HashIterator::HashIterator(HashTable, bool, bool)’: zend/hashiterator.h:38:67: error: cannot convert ‘Bucket** {aka Bucket**}’ to ‘HashPosition* {aka unsigned int}’ for argument ‘2’ to ‘void zend_hash_internal_pointer_reset_ex(HashTable, HashPosition*)’ zend_hash_internal_pointer_reset_ex(_table, &position); ^ zend/hashiterator.h: In member function ‘virtual bool Php::HashIterator::increment()’: zend/hashiterator.h:91:57: error: cannot convert ‘Bucket** {aka Bucket**}’ to ‘HashPosition* {aka unsigned int}’ for argument ‘2’ to ‘int zend_hash_move_forward_ex(HashTable, HashPosition*)’ if (zend_hash_move_forward_ex(table, &position) == SUCCESS) ^ zend/hashiterator.h: In member function ‘virtual bool Php::HashIterator::decrement()’: zend/hashiterator.h:119:65: error: cannot convert ‘Bucket** {aka Bucket**}’ to ‘HashPosition* {aka unsigned int}’ for argument ‘2’ to ‘void zend_hash_internal_pointer_end_ex(HashTable, HashPosition*)’ zend_hash_internal_pointer_end_ex(table, &position); ^ zend/hashiterator.h:121:64: error: cannot convert ‘Bucket** {aka Bucket**}’ to ‘HashPosition* {aka unsigned int}’ for argument ‘2’ to ‘int zend_hash_move_backwards_ex(HashTable, HashPosition*)’ else if (zend_hash_move_backwards_ex(table, &position) == FAILURE) ^ zend/hashiterator.h: In member function ‘bool Php::HashIterator::read()’: zend/hashiterator.h:194:71: error: cannot convert ‘Bucket** {aka Bucket**}’ to ‘HashPosition* {aka unsigned int}’ for argument ‘3’ to ‘void zend_hash_get_current_key_zval_ex(const HashTable, zval, HashPosition)’ zend_hash_get_current_key_zval_ex(table, key.val, &position); ^ zend/hashiterator.h:225:75: error: cannot convert ‘void**’ to ‘HashPosition* {aka unsigned int}’ for argument ‘2’ to ‘zval zend_hash_get_current_data_ex(HashTable, HashPosition)’ zend_hash_get_current_data_ex(_table, (void **) &value, &position); ^ In file included from zend/includes.h:120:0, from zend/inivalue.cpp:8: zend/traverseiterator.h: In constructor ‘Php::TraverseIterator::TraverseIterator(zval, bool)’: zend/traverseiterator.h:35:60: error: ‘zend_get_class_entry’ was not declared in this scope auto *entry = zend_get_class_entry(object TSRMLS_CC); ^ zend/traverseiterator.h: In member function ‘bool Php::TraverseIterator::read()’: zend/traverseiterator.h:231:62: error: too many arguments to function _iter->funcs->get_current_data(iter, &zval TSRMLS_CC); ^ In file included from zend/includes.h:121:0, from zend/inivalue.cpp:8: zend/iteratorimpl.h: In constructor ‘Php::IteratorImpl::IteratorImpl(Php::Iterator)’: zend/iteratorimpl.h:167:20: error: no match for ‘operator=’ (operand types are ‘zval {aka zval_struct}’ and ‘Php::IteratorImpl’) _impl.data = this; ^ In file included from /usr/include/php/20151012/Zend/zend.h:31:0, from /usr/include/php/20151012/main/php.h:36, from zend/includes.h:36, from zend/inivalue.cpp:8: /usr/include/php/20151012/Zend/zend_types.h:121:8: note: candidate: _zval_struct& _zval_struct::operator=(const zval_struct&) struct zval_struct { ^ /usr/include/php/20151012/Zend/zend_types.h:121:8: note: no known conversion for argument 1 from ‘Php::IteratorImpl’ to ‘const zval_struct&’ /usr/include/php/20151012/Zend/zend_types.h:121:8: note: candidate: zval_struct& zval_struct::operator=(zval_struct&&) /usr/include/php/20151012/Zend/zend_types.h:121:8: note: no known conversion for argument 1 from ‘Php::IteratorImpl’ to ‘zval_struct&&’ In file included from zend/includes.h:122:0, from zend/inivalue.cpp:8: zend/classimpl.h: At global scope: zend/classimpl.h:179:12: error: ‘zend_object_value’ does not name a type static zend_object_value createObject(zend_class_entry *entry TSRMLS_DC); ^ zend/classimpl.h:180:12: error: ‘zend_object_value’ does not name a type static zend_object_value cloneObject(zval *val TSRMLS_DC); ^ In file included from zend/includes.h:122:0, from zend/inivalue.cpp:8: zend/classimpl.h:254:73: error: ‘zend_literal’ does not name a type static zval *readProperty(zval *object, zval *name, int type, const zend_literal *key TSRMLS_DC); ^ zend/classimpl.h:269:76: error: ‘zend_literal’ does not name a type static void writeProperty(zval *object, zval *name, zval *value, const zend_literal *key TSRMLS_DC); ^ zend/classimpl.h:283:80: error: ‘zend_literal’ does not name a type static int hasProperty(zval *object, zval *name, int has_set_exists, const zend_literal *key TSRMLS_DC); ^ zend/classimpl.h:295:65: error: ‘zend_literal’ does not name a type static void unsetProperty(zval *object, zval *member, const zend_literal key TSRMLS_DC); ^ zend/classimpl.h:310:92: error: ‘zend_literal’ does not name a type static zend_function getMethod(zval object_ptr, char method, int method_len, const zend_literal *key TSRMLS_DC); ^ In file included from zend/includes.h:123:0, from zend/inivalue.cpp:8: zend/objectimpl.h: In constructor ‘Php::ObjectImpl::ObjectImpl(zend_class_entry, Php::Base, int)’: zend/objectimpl.h:119:50: error: ‘zend_objects_store_dtor_t’ was not declared in this scope handle = zend_objects_store_put(php(), (zend_objects_store_dtor_t)destructMethod, (zend_objects_free_object_storage_t)freeMethod, NULL ^ zend/objectimpl.h:119:93: error: ‘zend_objects_free_object_storage_t’ was not declared in this scope handle = zend_objects_store_put(php(), (zend_objects_store_dtor_t)destructMethod, (zend_objects_free_object_storage_t)freeMethod, NULL ^ zend/objectimpl.h:122:70: error: request for member ‘bucket’ in ‘(executor_globals.zend_executor_globals::objects_store.zend_objects_store::object_buckets + ((sizetype)(((long unsigned int)((Php::ObjectImpl)this)->Php::ObjectImpl::handle) * 8ul)))’, which is of pointer type ‘zend_object {aka zend_object}’ (maybe you meant to use ‘->’ ?) if (refcount != 1) EG(objects_store).object_buckets[handle].bucket.obj.refcount = refcount; ^ zend/objectimpl.h: In member function ‘void Php::ObjectImpl::destruct()’: zend/objectimpl.h:144:57: error: ‘zend_objects_free_object_storage’ was not declared in this scope zend_objects_free_object_storage(php() TSRMLS_CC); ^ zend/objectimpl.h: In static member function ‘static Php::ObjectImpl Php::ObjectImpl::find(zval)’: zend/objectimpl.h:159:88: error: ‘zend_object_store_get_object’ was not declared in this scope MixedObject *object = (MixedObject *)zend_object_store_get_object(val TSRMLS_CC); ^ In file included from zend/includes.h:124:0, from zend/inivalue.cpp:8: zend/parametersimpl.h: In constructor ‘Php::ParametersImpl::ParametersImpl(zval, int)’: zend/parametersimpl.h:36:63: error: ‘zend_vm_stack_top’ was not declared in this scope zval arg = (zval *) (zend_vm_stack_top(TSRMLS_C) - 1 - (argc-i)); ^ In file included from zend/includes.h:126:0, from zend/inivalue.cpp:8: zend/compileroptions.h: At global scope: zend/compileroptions.h:27:5: error: ‘zend_uint’ does not name a type zend_uint _original; ^ zend/compileroptions.h:42:31: error: expected ‘)’ before ‘options’ CompilerOptions(zend_uint options TSRMLS_DC) ^ zend/compileroptions.h: In destructor ‘virtual Php::CompilerOptions::~CompilerOptions()’: zend/compileroptions.h:62:32: error: ‘_original’ was not declared in this scope CG(compiler_options) = _original; ^ In file included from /usr/include/php/20151012/Zend/zend_globals.h:28:0, from /usr/include/php/20151012/Zend/zend_compile.h:657, from /usr/include/php/20151012/Zend/zend_modules.h:26, from /usr/include/php/20151012/Zend/zend_API.h:27, from /usr/include/php/20151012/main/php.h:40, from zend/includes.h:36, from zend/inivalue.cpp:8: zend/executestate.h: In constructor ‘Php::ExecuteState::ExecuteState(int)’: zend/executestate.h:63:28: error: ‘zend_executor_globals {aka struct _zend_executor_globals}’ has no member named ‘active_op_array’ _active_op_array = EG(active_op_array); ^ zend/executestate.h:64:33: error: ‘zend_executor_globals {aka struct _zend_executor_globals}’ has no member named ‘return_value_ptr_ptr’ _return_value_ptr_ptr = EG(return_value_ptr_ptr); ^ zend/executestate.h:65:23: error: ‘zend_executor_globals {aka struct _zend_executor_globals}’ has no member named ‘opline_ptr’ _opline_ptr = EG(opline_ptr); ^ zend/executestate.h:66:24: error: ‘struct _zend_compiler_globals’ has no member named ‘interactive’ _interactive = CG(interactive); ^ zend/executestate.h: In destructor ‘virtual Php::ExecuteState::~ExecuteState()’: zend/executestate.h:81:9: error: ‘struct _zend_compiler_globals’ has no member named ‘interactive’ CG(interactive) = _interactive; ^ zend/executestate.h:83:9: error: ‘zend_executor_globals {aka struct _zend_executor_globals}’ has no member named ‘opline_ptr’ EG(opline_ptr) = _opline_ptr; ^ zend/executestate.h:84:9: error: ‘zend_executor_globals {aka struct _zend_executor_globals}’ has no member named ‘active_op_array’ EG(active_op_array) = active_op_array; ^ zend/executestate.h:85:9: error: ‘zend_executor_globals {aka struct zend_executor_globals}’ has no member named ‘return_value_ptr_ptr’ EG(return_value_ptr_ptr) = return_value_ptr_ptr; ^ zend/opcodes.h: In member function ‘Php::Value Php::Opcodes::execute() const’: zend/opcodes.h:81:9: error: ‘zend_executor_globals {aka struct zend_executor_globals}’ has no member named ‘return_value_ptr_ptr’ EG(return_value_ptr_ptr) = &retval_ptr; ^ zend/opcodes.h:82:9: error: ‘zend_executor_globals {aka struct zend_executor_globals}’ has no member named ‘active_op_array’ EG(active_op_array) = opcodes; ^ zend/opcodes.h:84:14: error: ‘zend_executor_globals {aka struct zend_executor_globals}’ has no member named ‘active_symbol_table’ if (!EG(active_symbol_table)) zend_rebuild_symbol_table(TSRMLS_C); ^ zend/opcodes.h:85:9: error: ‘struct zend_compiler_globals’ has no member named ‘interactive’ CG(interactive) = 0; ^ zend/opcodes.h:88:30: error: cannot convert ‘zend_object* {aka zend_object}’ to ‘zval {aka zval_struct}’ in initialization zval oldException = EG(exception); ^ In file included from zend/includes.h:128:0, from zend/inivalue.cpp:8: zend/opcodes.h:91:40: error: too few arguments to function ‘void zend_execute(zend_op_array, zval)’ zend_execute(opcodes TSRMLS_CC); ^ In file included from /usr/include/php/20151012/Zend/zend_API.h:31:0, from /usr/include/php/20151012/main/php.h:40, from zend/includes.h:36, from zend/inivalue.cpp:8: /usr/include/php/20151012/Zend/zend_execute.h:41:15: note: declared here ZEND_API void zend_execute(zend_op_array op_array, zval *return_value); ^ In file included from /usr/include/php/20151012/Zend/zend_globals.h:28:0, from /usr/include/php/20151012/Zend/zend_compile.h:657, from /usr/include/php/20151012/Zend/zend_modules.h:26, from /usr/include/php/20151012/Zend/zend_API.h:27, from /usr/include/php/20151012/main/php.h:40, from zend/includes.h:36, from zend/inivalue.cpp:8: zend/opcodes.h:95:29: error: comparison between distinct pointer types ‘zval {aka zval_struct}’ and ‘zend_object {aka zend_object}’ lacks a cast if (oldException != EG(exception) && EG(exception)) throw OrigException(EG(exception) TSRMLS_CC); ^ In file included from zend/includes.h:128:0, from zend/inivalue.cpp:8: zend/opcodes.h:95:104: error: no matching function for call to ‘Php::OrigException::OrigException(zend_object&)’ if (oldException != EG(exception) && EG(exception)) throw OrigException(EG(exception) TSRMLS_CC); ^ In file included from zend/includes.h:114:0, from zend/inivalue.cpp:8: zend/origexception.h:73:5: note: candidate: Php::OrigException::OrigException(Php::OrigException&&) OrigException(OrigException &&exception) : ^ zend/origexception.h:73:5: note: no known conversion for argument 1 from ‘zend_object* {aka zend_object}’ to ‘Php::OrigException&&’ zend/origexception.h:60:5: note: candidate: Php::OrigException::OrigException(const Php::OrigException&) OrigException(const OrigException &exception) : ^ zend/origexception.h:60:5: note: no known conversion for argument 1 from ‘zend_object {aka zend_object}’ to ‘const Php::OrigException&’ zend/origexception.h:47:5: note: candidate: Php::OrigException::OrigException(zval) OrigException(zval val TSRMLS_DC) : ^ zend/origexception.h:47:5: note: no known conversion for argument 1 from ‘zend_object {aka zend_object}’ to ‘zval {aka _zval_struct}’ In file included from /usr/include/php/20151012/Zend/zend.h:39:0, from /usr/include/php/20151012/main/php.h:36, from zend/includes.h:36, from zend/inivalue.cpp:8: zend/opcodes.h:105:9: error: cannot convert ‘zval {aka _zval_struct}’ to ‘zval {aka zval_struct}’ for argument ‘1’ to ‘void zval_ptr_dtor(zval)’ zval_ptr_dtor(&retval_ptr); ^ In file included from zend/includes.h:130:0, from zend/inivalue.cpp:8: zend/constantimpl.h: In constructor ‘Php::ConstantImpl::ConstantImpl(const char, const char, size_t)’: zend/constantimpl.h:85:9: error: ‘ZVAL_STRINGL’ was not declared in this scope ZVAL_STRINGL(&constant.value, value, len, 0); ^ zend/constantimpl.h: In constructor ‘Php::ConstantImpl::ConstantImpl(const char, const char)’: zend/constantimpl.h:96:9: error: ‘ZVAL_STRINGL’ was not declared in this scope ZVAL_STRINGL(&constant.value, value, ::strlen(value), 0); ^ zend/constantimpl.h: In constructor ‘Php::ConstantImpl::ConstantImpl(const char, const string&)’: zend/constantimpl.h:107:9: error: ‘ZVAL_STRINGL’ was not declared in this scope ZVAL_STRINGL(&_constant.value, value.c_str(), value.size(), 0); ^ zend/constantimpl.h: In member function ‘void Php::ConstantImpl::addTo(Php::ClassBase&) const’: zend/constantimpl.h:140:14: error: ‘IS_BOOL’ was not declared in this scope case IS_BOOL: ^ zend/constantimpl.h:142:56: error: ‘Z_BVAL’ was not declared in this scope clss.property(_name, Z_BVAL(_constant.value), Php::Const); ^ zend/constantimpl.h: In member function ‘void Php::ConstantImpl::initialize(const string&, int)’: zend/constantimpl.h:184:23: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name_len = prefix.size() + 1 + namelen + 1; ^ In file included from /usr/include/php/20151012/Zend/zend.h:33:0, from /usr/include/php/20151012/main/php.h:36, from zend/includes.h:36, from zend/inivalue.cpp:8: zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = (char *)emalloc(_constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ constant.name = (char *)emalloc(constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct zend_constant}’ has no member named ‘name_len’ constant.name = (char *)emalloc(constant.name_len); ^ zend/constantimpl.h:185:38: error: ‘zend_constant {aka struct zend_constant}’ has no member named ‘name_len’ constant.name = (char *)emalloc(constant.name_len); ^ In file included from zend/includes.h:130:0, from zend/inivalue.cpp:8: zend/constantimpl.h:188:68: error: cannot convert ‘zend_string {aka zend_string}’ to ‘char’ for argument ‘1’ to ‘char* strncpy(char, const char, size_t)’ ::strncpy(constant.name, prefix.c_str(), prefix.size()); ^ zend/constantimpl.h:189:62: error: cannot convert ‘zend_string* {aka zend_string}’ to ‘char’ for argument ‘1’ to ‘char* strncpy(char, const char, size_t)’ ::strncpy(constant.name + prefix.size(), "", 1); ^ zend/constantimpl.h:190:77: error: cannot convert ‘zend_string* {aka zend_string}’ to ‘char’ for argument ‘1’ to ‘char* strncpy(char, const char, size_t)’ ::strncpy(_constant.name + prefix.size() + 1, _name, namelen + 1); ^ zend/constantimpl.h:195:23: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name_len = ::strlen(_name) + 1; ^ zend/constantimpl.h:196:60: error: ‘zend_constant {aka struct _zend_constant}’ has no member named ‘name_len’ _constant.name = zend_strndup(_name, _constant.name_len - 1); ^ Makefile:197: recipe for target 'shared/zend/inivalue.o' failed make: *** [shared/zend/inivalue.o] Error 1

    opened by zecho 14
  • Failed to run example from documentation

    Failed to run example from documentation

    Hello,

    I am trying to build the example from documentation here http://www.php-cpp.com/documentation/functions.

    For phpcpp library "make" and "make install" worked without any problems. Also I was able to compile an example function from documentation into .so file. But when I tried to execute myFunction() from php it throws me error:

    $php test.php

    PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525/my_extension.so' - /usr/lib/libphpcpp.so: undefined symbol: zend_next_free_module in Unknown on line 0 PHP Fatal error: Call to undefined function myFunction() in /var/PHP-CPP/test.php on line 3

    test.php file looks like this: <?php myFunction();

    I would appreciate any help, because I really love the idea of php-cpp extension and want to contribute several performance improvements for php frameworks.

    opened by spleshka 13
  • Return a C++ object pointer back to PHP

    Return a C++ object pointer back to PHP

    Further to my https://github.com/CopernicaMarketingSoftware/PHP-CPP/issues/150 and https://github.com/CopernicaMarketingSoftware/PHP-CPP/issues/151 (and thanks for the quick closing), I am now to write some codes inside my Complex class. One member function is conjugate and I wrote like this:

        Php::Value conjugate()
        {
            Complex *t=new Complex();
    
            t->r=r;
            t->i=-i;
    
            return *t;
        }
    

    Unlike other member functions add, sub, this one I want to make it to return a newly constructed object instead of a this.

    This won't compile in PHP-CPP and the prompts says:

    main.cpp: In member function ‘Php::Value Complex::conjugate()’:
    main.cpp:95:17: error: could not convert ‘* t’ from ‘Complex’ to ‘Php::Value’
             return *t;
    

    Am I doing something naive here? Thanks for your help.

    opened by taylorren 12
  • libphpcpp.so unable to load error while running any PHP CPP program

    libphpcpp.so unable to load error while running any PHP CPP program

    Error:

    [root@localhost CopernicaMarketingSoftware-PHP-CPP-9502a73]# php /var/www/html/bsort.php PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/bubblesort.so' - libphpcpp.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'libphpcpp.so' in Unknown on line 0 PHP Fatal error: Call to undefined function native_bubblesort() in /var/www/html/bsort.php on line 10 [root@localhost CopernicaMarketingSoftware-PHP-CPP-9502a73]#

    Above bsort.php is containing same code given in PHP-CPP.com website for bubble sort.

    Unable to understand why libphpcpp.so was not successfully loaded even after successful make/build

    opened by darshitvp 12
  • Add PHP 8.2 Support

    Add PHP 8.2 Support

    Based on the PR for 8.0 and 8.1 support and the original code from https://github.com/baronbiosys/PHP-CPP/pull/1/commits/58c1d78c62b431acc6caea845ff00a8efeb22746 this adds conditional support for PHP 8.2

    opened by gnat42 0
  • Cannot build for windows

    Cannot build for windows

    I triedbuilding the project using Cmake but am getting this error

    "Error in configuration process, project files may be invalid"
    Selecting Windows SDK version 10.0.19041.0 to target Windows 6.3.9600.
    Compile PHPCPP with dynamic runtime
    CMake Error at CMakeLists.txt:46 (IF):
      if given arguments:
    
        "STREQUAL" "x86_64"
    
      Unknown arguments specified
    

    Please what do i do?

    opened by mitmelon 2
  • phpcpp compiled for windows

    phpcpp compiled for windows

    Hello Everyone,

    i compiled phpcpp with php 7.4 in .o files on ubuntu. Now i want to get it as .lib file... for windows...

    ive done the following:

    sudo g++ -shared -o zend.dll zval.o zendcallable.o valueiterator.o value.o throwable.o super.o streams.o streambuf.o stream.o script.o sapi.o object.o namespace.o module.o members.o base.o callable.o eval.o classbase.o classimpl.o constant.o constantfuncs.o error.o exception.o exception_handler.o exists.o extension.o extensionimpl.o file.o function.o functor.o global.o globals.o hashmember.o ini.o inivalue.o iteratorimpl.o -Wl,--out-implib,zend.lib

    and it works ... but if i try to compile the results "zend.lib" with visual studio i cant compile - could you tell me please - why?

    thanks a lot!

    Greets Robert

    opened by subabrain 1
Releases(v2.3.5)
  • v2.3.5(Jun 29, 2022)

    • Classes that extend from Php::Serializable no longer have to explicitly register the serialize() and unserialize() methods (they are not implicitly added)
    Source code(tar.gz)
    Source code(zip)
  • v2.3.4(Jun 14, 2022)

  • v2.3.3(Jun 14, 2022)

  • v2.3.2(Jun 10, 2022)

  • v2.3.1(Jun 10, 2022)

  • v2.3.0(Oct 19, 2021)

    • Support for PHP 7.4
    • C++ classes that derive from Php::Traversable now automatically also implement "Traversable" in PHP space ("instanceof" operator now works)
    • C++ classes that derive from Php::Serializable now automatically also implement "Serializable" in PHP space ("instanceof" operator now works)
    • Performance optimization for destructing objects
    • Some small improvements and fixes to the building procedures with cmake
    • Fixed some mistakes in example code
    Source code(tar.gz)
    Source code(zip)
  • v2.2.0(Apr 5, 2019)

    WARNING: Breaking changes to the ABI and API regarding the Error class

    Warning: commit dfe4a94 breaks build on PHP7.0 and PHP7.1. Needs fix before proper release

    • Renamed exception to throwable
    • Enumeration Php::Error has been renamed to Php::ErrorType to make room for the new Php::Error class
    • Added new class Php::Error that can be used for throwing errors (PHP7 normally throws errors instead of reporting fatal errors, which is what PHP5 did)
    • Php::Exception is now only used for exceptions and no longer for errors (so extensions can be written to only catch exceptions, and not the errors)
    • Removed support for Exception::file() and Exception::line()
    • A couple of functions that used to report fatal errors, now throw an Php::Error object instead
    • fixed exception handling for class methods and functions (uncaught Error objects caused a full crash, now they cause a fatal error)
    • when calling an invalid function we no longer throw an exception, but an error
    • renamed ErrorType to Message
    • closures now get an empty string as name because exception handling functions sometimes need access to the name
    • fixed issue when dealing with optional object parameters
    Source code(tar.gz)
    Source code(zip)
  • v2.1.4(Mar 5, 2019)

  • v2.1.3(Feb 28, 2019)

    • improved makefile
    • fixed some valgrind complaints about uninitialized memory
    • fixed the __invoke() and __call() methods: the return value of the C++ function was not passed to php space
    Source code(tar.gz)
    Source code(zip)
  • v2.1.2(Aug 31, 2018)

    • Fix where info->type was not correctly assigned, resulting in garbage being dereferenced (php7.2). fix compilation error for php7.3 regarding the way constants are implemented in zend.
    • info->type is >php7.2 only
    • Always dereference our value, if it is not a reference we get the original back again
    • Constants were not right after all, and the iterator structure is slightly different for 7.3.
    • iterator_funcs is now of pointer type
    • Fix build on OSX (#391)
    • Added PHP7.3 support
    Source code(tar.gz)
    Source code(zip)
  • v2.1.1(Aug 29, 2018)

    • Add automatic builds for g++-4.8 up to g++-8 and clang++-4.0 to clang++-6.0. Also resolves #357 by moving the -shared flag further down on the command line parameters, after the point PHP had the chance to taint them by including the -pie flag.
    • If our zend value is a reference, pass through the reference to retrieve the object class entry
    Source code(tar.gz)
    Source code(zip)
  • v2.1.0(Jun 19, 2018)

    • Support for PHP 7.2
    • ini entries were not always correctly registered when a extension was reloaded
    • Added cmake file to be able to compile PHP-CPP under Windows (#343)
    • Removed hard dependency on sudo (#332)
    • Refactored exception code slightly
    • Made the makeReference function non-static, renamed some variables for clarity, reworked parenthesis for consistency and added some missing override statements
    • Fix #301 - Invalid read when Php::defined() is true
    • Fix wrong assumption
    • Make inlines static and unexport them (fix #178)
    • Bug fix for #234 - Setting a PHP::GLOBALS value makes a segfault
    • Fix 7.1 build
    • debugZval() should be public
    • Rework assignments
    • Fix #293 - Php::Value::numericValue() does not play well with references
    • Fix #269 - Process termination when attempting to access object
    • Remove #pragma GCC system_header from zend/includes.h
    • Fix -Wsign-compare compiler warning
    • Increase refcount of zval, not zend_object
    • Use EG(scope) to access properties
    • Fix #261 - Byref
    • Use information from PHP exception
    • Fix compiler warnings
    • Fix #281 -Memory Leak in CallPhpFunctions
    • Do not increment reference count more than necessary
    • Use zend_object_std_dtor()
    • Fix TSRM usage for PHP 7
    • Make the code compile under ZTS
    • Fix zval being free()ed too early when retrieving a propery
    • arrayaccess.h: Add missing virtual destructor for interface
    Source code(tar.gz)
    Source code(zip)
  • v2.0.0(Oct 14, 2016)

  • v1.5.3(Feb 25, 2016)

  • v1.5.2(Oct 28, 2015)

    This is a bugfix release

    • Properly handle a Php::Exception when thrown from a serialize method.
    • Handle exceptions thrown from unserialize similar to normal php.
    • Fix issue with derived classes. closes #211
    • Fix logic error that caused segfaults for extension-created classes extended from userland using a doc-block
    Source code(tar.gz)
    Source code(zip)
  • v1.5.1(Oct 7, 2015)

    This release only adds some error related functions

    • The php error_reporting function is exposed without any slow Php::call() calls
    • The php set_error_handler function is exposed without any slow Php::call() calls
    • Exposed all of the E_* properties as an enum
    Source code(tar.gz)
    Source code(zip)
  • v1.5(Jul 29, 2015)

    PHP-CPP version 1.5 is mainly a bugfix release, and it has a small number of new features:

    • PHP interfaces defined in C++ can now also have static methods
    • Fixed segmentation fault crash when casting objects
    • Fixed crash when calling chained C++ methods from a PHP script
    • Allowed "Php::Value x = y["whatever"]" syntax in C++ code
    • Fixed memory leak when calling function stored in a Php::Value object
    • Fixed memory leak when a Php::Iterator object was being used
    Source code(tar.gz)
    Source code(zip)
  • v1.4(May 19, 2015)

    New release with several bugfixes and some new features

    • Added a function to load other extensions by path
    • Fixed some symbols that were not being exported
    • Value::rawValue() will now return nullptr in case the Value is not a string
    • Value::get(int) and Value::contains(int) now also work on Objects implementing ArrayAccess
    • Makefile will now add the version using sonames
    Source code(tar.gz)
    Source code(zip)
  • v1.3.2(Apr 3, 2015)

    This release is mainly a bugfix release

    • Implemented a simple sapi_name() method which will return the current sapi.
    • On Windows with mingw EOF was not defined.
    • Added access checks to Php::Value::contains.
    • Fixed the Value::contains method and added the isCallable(name) function to see if the object has an accessible member function
    • Changed default visibility for symbols in the PHP-CPP library to hidden and explicitly exported all symbols available from the public API.
    • Fix compile issue with PHP 5.3
    • Added article about dynamic loading
    • Added DlUnrestricted example extension
    • Fixed a crash when dynamicly loaded extensions were unloaded
    Source code(tar.gz)
    Source code(zip)
  • v1.3.1(Mar 12, 2015)

    This release is mainly a bugfix release

    • Added a couple of extra checks to ensure that PHP-CPP also compilers on these olders compilers
    • Fixed compile issue for 32bit systems (issue 167)
    • Fixed segmentation fault when an exception was thrown from out of an __invoke() or __call() method
    • Refactored the initialization and shutdown of extension objects
    • Fixed initialization of the PhpCpp::Functor class
    • Fixed memory leak in classimpl
    • Fixed compile issue on multithread setups
    • Dlsym() call has been replaced with DL_FETCH_SYMBOL(), and default move constructor has been removed
    • Fixed ambiguous call (MSVC compiler) - Re-factored operator[] access to the get() function.
    • Added missing static cast of void* to DL_HANDLE
    • Added missing return statement
    • Fix test (fixes issue 167)
    • Merge pull request #169 from ovr/patch-1 (Fix indent )
    • Merge pull request #173 from atvise/fix_win_ambigious_call - Fixed ambiguous call (MSVC compiler)
    • Merge pull request #175 from atvise/fix_win_missing_static_cast Added missing static cast of void* to DL_HANDLE
    • Merge pull request #176 from atvise/fix_missing_returns Added missing return statement
    • Removed unused code
    Source code(tar.gz)
    Source code(zip)
  • v1.3(Jan 27, 2015)

    A new release of PHP-CPP with bug fixes and new features. The highlights are:

    • Value::unset() method has been fixed to make it possible to remove array/object members
    • Reduced amount of code by using variadic templates
    • All move and assignment operators are marked as 'noexcept'
    • Fixed chaining methods, it now is possible to "return this"
    • FIxed memory leaks
    • Added Php::Script and Php::File classes that can evaluate PHP scripts
    • Added methods Php::include(), Php::include_once(), Php::require() and Php::require_once()
    • Fixed return value of Php::eval() function (this could break existing applications that rely on old behavior)
    • It now is possible to iterate over super-globals like Php::POST, Php::SERVER, etcetera
    • Added Php::Function class that allows one to capture C++ lambdas and pass them over to PHP user space
    • Added support for constants using the Php::Constant class
    • Added functions Php::define(), Php::defined() and Php::constant()
    • Added version check to ensure that a compiled extension is compatible with the installed version of PHP-CPP
    Source code(tar.gz)
    Source code(zip)
  • v1.2.2(Nov 25, 2014)

    This release is mainly a bugfix version

    • Fixed a memory leak with Php::Value objects not being freed correctly when returned
    • Php::Object("MyClass") no longer crashes when there is no __construct() function
    • It is now slightly easier to cross compile
    Source code(tar.gz)
    Source code(zip)
  • v1.2.1(Oct 23, 2014)

    Minor release which adds a few minor things.

    • Php::Value can now be casted to a std::set
    • Php::ByVal and Php::ByRef will now be type-less if no type provided
    • Makefile will now respect the specified php-config binary
    • Makefile will now build a static library as well
    Source code(tar.gz)
    Source code(zip)
  • v1.2(Aug 26, 2014)

    This is mainly a bugfix version + some new features and change in behavior of some functions.

    • New feature: Php::Value objects can now also be compared with other Php::Value objects using C++ comparison operators like ==, <, >, etcetera.
    • Fix: magic methods were not working for objects created with Php::Object("MyClass", new MyClass())
    • Fix: moving nullptr to a Php::Value object caused a crash
    • Fix: infinite loop when compariting value objects with each other using operator ==
    • New feature: A C++ class does no longer have to have a default constructor to be usable from PHP
    • Changed behavior: PHP-CPP used to throw PHP exceptions to user space when an error occured, while the Zend engine would trigger a fatal error in similar situations and stop further execution. This was a difference between PHP-CPP and the Zend engine. This has been changed: now PHP-CPP also triggers fatal errors when the programmer makes a mistake (instead of throwing exceptions).
    • Fix: methods and properties from base classes were not available in derived classes
    • New feature: Php::eval() function
    • New feature: Php::class_exists() function
    • New feature: Php::is_a() and Php::is_subclass_of() functions
    • New feature: Methods Php::Value::instanceOf() and Php::Value::derivedFrom()
    • Fix: creating a Php::Value based on a std::map would not result in an array variable being created
    • Fix: for objects created using Php::Object() constructor, the __construct() method was not called
    • Fix: traversing through array properties was not always working when property names started with a null byte
    • Fix: casting a Php::value holding an array to a map with string keys, will now turn the keys into numeric string keys ("1", "2", etcetera)
    • Fix: "apachectl reload" caused a crash on PHP 5.3 environments
    • Changed behavior: setting or retrieving properties of a Php::Value that start with a null byte (to rely on the Zend implementation of private properties) will no longer work (PHP-CPP users should never rely on specific Zend features)
    Source code(tar.gz)
    Source code(zip)
  • v1.1.1(May 13, 2014)

    This release fixes a bug that caused apache to crash when the "apache reload" command was given while an extension based on PHP-CPP was installed.

    Source code(tar.gz)
    Source code(zip)
  • v1.1(Apr 28, 2014)

    Release 1.1 of the PHP-CPP library contains a number of small bug fixes, and support for php.ini variables.

    The source code and directory structure of the library has been refactored to prepare for future support of HHVM, so that extensions written with PHP-CPP can be used in combination with Zend, and in combination with HHVM. This is work in progress: currently PHP-CPP extensions only work with Zend.

    The most important changes in version 1.1 are:

    • Support for php.ini entries.
    • Restructured source code to be engine agnostic.
    Source code(tar.gz)
    Source code(zip)
  • v1.0(Apr 5, 2014)

    This is the first stable release of the PHP-CPP library. Since the previous release various bugs have been fixed and a number of small features have been added. These are the highlights:

    • Support for TRSM (multi-threading PHP installations)
    • Test framework has been added to the source distribution
    • Fixed iterating over arrays
    • Fixed populating multidimensional arrays
    • Allow chaining of class/method/property registration methods.
    • Class and interface inheritance can be specified in the get_module() startup function
    • Fixed super-global Php::SERVER when running as Apache module with just-in-time population
    • Added support for static class properties
    Source code(tar.gz)
    Source code(zip)
  • v0.9.2(Mar 24, 2014)

    This release has mainly bug fixes, and some small new necessary features:

    • A unit test framework has been added
    • Object properties could not have initial negative values
    • C++ iterators were not correct when iterating over PHP classes that implemented Iterator or IteratorAggregate
    • Output streams 'Php::out', 'Php::notice', 'Php::warning' and 'Php::error' and 'Php::deprecated' have been added
    • Setting up multidimensional arrays was not working correctly
    Source code(tar.gz)
    Source code(zip)
  • v0.9.1(Mar 18, 2014)

    In PHP-CPP version 0.9.1 several small memory corruption bugs have been fixed, and some changes have been made that prevented the library from being compiled for different PHP versions or with different compilers than the ones used by us.

    No new features have been introduced. Just like PHP-CPP v0.9 this is a feature-freeze releases that prepares for the upcoming v1.0 version.

    Source code(tar.gz)
    Source code(zip)
  • v0.9(Mar 16, 2014)

    This v0.9 release has all the features that we want to have in v1.0. But it has not been tested so extensively, hence the v0.9 tag: almost v1.0, but not completely stable.

    The most important new features and changes since the previous release (v0.2) are:

    • Php::Serializable class
    • Support for __clone(), __destruct() and __callStatic() methods
    • C++ classes without a copy constructor automatically are unclonable in PHP too
    • Magic methods are no longer virtual, which allows one to use alternative method signatures
    • Introduces "super-globals" Php::GET, Php::POST, Php::COOKIE, etc. just like PHP has.
    • Properties can be implemented with callback methods, enabling read-only properties
    • Fixed issues to compile on OSX
    • Direct access to the string buffer inside a Php::Value object is now allowed

    Because magic methods no longer are virtual, the v0.9 release is not compatible with v0.2. Extensions that were developed using PHP-CPP v0.2 have to be recompiled, and possible be slightly modified too to match the new magic method signature.

    Source code(tar.gz)
    Source code(zip)
Owner
Copernica
Email Marketing Software
Copernica
A lightweight, dependency-free library for binding Lua to C++

LuaBridge 2.6 LuaBridge is a lightweight and dependency-free library for mapping data, functions, and classes back and forth between C++ and Lua (a po

Vinnie Falco 1.4k Jan 8, 2023
:sparkles: Magical headers that make your C++ library accessible from JavaScript :rocket:

Quick start | Requirements | Features | User guide | Contributing | License nbind is a set of headers that make your C++11 library accessible from Jav

charto 1.9k Dec 26, 2022
Structy is an irresponsibly dumb and simple struct serialization/deserialization library for C, Python, and vanilla JavaScript.

Structy Structy is an irresponsibly dumb and simple struct serialization/deserialization library for C, Python, and vanilla JavaScript. You can think

Stargirl Flowers 53 Dec 29, 2022
Library to build PHP extensions with C++

PHP-CPP The PHP-CPP library is a C++ library for developing PHP extensions. It offers a collection of well documented and easy-to-use classes that can

Copernica 1.3k Dec 24, 2022
🥑 ArangoDB is a native multi-model database with flexible data models for documents, graphs, and key-values. Build high performance applications using a convenient SQL-like query language or JavaScript extensions.

?? ArangoDB is a native multi-model database with flexible data models for documents, graphs, and key-values. Build high performance applications using a convenient SQL-like query language or JavaScript extensions.

ArangoDB 12.8k Jan 9, 2023
Improved build system generator for CPython C, C++, Cython and Fortran extensions

scikit-build Improved build system generator for CPython C/C++/Fortran/Cython extensions. Better support is available for additional compilers, build

null 376 Dec 29, 2022
ANSI C library for NURBS, B-Splines, and Bézier curves with interfaces for C++, C#, D, Go, Java, Lua, Octave, PHP, Python, R, and Ruby.

TinySpline TinySpline is a small, yet powerful library for interpolating, transforming, and querying arbitrary NURBS, B-Splines, and Bézier curves. Th

Marcel Steinbeck 895 Dec 28, 2022
🚀 Coroutine-based concurrency library for PHP

English | 中文 Swoole is an event-driven asynchronous & coroutine-based concurrency networking communication engine with high performance written in C++

Swoole Project 17.7k Dec 30, 2022
C++11/14/17 std::expected with functional-style extensions

expected Single header implementation of std::expected with functional-style extensions. Clang + GCC: MSVC: Available on Vcpkg and Conan. std::expecte

Sy Brand 946 Jan 1, 2023
C++11/14/17 std::optional with functional-style extensions and reference support

optional Single header implementation of std::optional with functional-style extensions and support for references. Clang + GCC: MSVC: std::optional i

Sy Brand 699 Dec 23, 2022
First-up chord-send and tap-and-hold chord repeat extensions to QMK.

Quantum Mechanical Keyboard Firmware This is a keyboard firmware based on the tmk_keyboard firmware with some useful features for Atmel AVR and ARM co

Joshua Grams 8 Dec 14, 2022
Microsoft RDP Client Extensions

Microsoft RDP Extensions (msrdpex) The official Microsoft RDP client is the only one with an exhaustive implementation of the entire feature set. Whil

Marc-André Moreau 69 Nov 25, 2022
C Extensions i made for DragonRuby!

drext C Extensions i made for DragonRuby NOTE: DragonRuby Pro required for C Extensions. List Name Description Platforms drbat Battery information lib

Rabia Alhaffar 5 Dec 5, 2022
Some extensions for windows explorer, tested on windows 10+

WindowsExplorerExtension Extensions for windows explorer, tested on windows 10 & windows 11. New Folder Extension What's This A Gnome nautilus inspire

anpho 4 Jan 13, 2022
Examples of C extensions in Ruby gems

Ruby C Extensions, Explained Background How To Use This Repository Strategies Strategy 0, "isolated" Strategy 1, "system" Strategy 2a, "packaged_sourc

Mike Dalessio 62 Dec 30, 2022
C++17 & C++ 20 error-handling and utility extensions.

C++ 17 & C++ 20 error-handling and utility extensions. Overview STX is a collection of libraries and utilities designed to make working with C++ easie

Basit Ayantunde 469 Dec 31, 2022
An extension manager for browsing and installing GNOME Shell Extensions.

Extension Manager A native tool for browsing, installing, and managing GNOME Shell Extensions. Written with GTK 4 and libadwaita. Features The tool su

Matt Jakeman 579 Jan 1, 2023
This is a list of hardware which is supports Intel SGX - Software Guard Extensions.

SGX-hardware list This is a list of hardware which supports Intel SGX - Software Guard Extensions. Desktop The CPU and the motherboard BIOS must suppo

Lars Lühr 513 Dec 16, 2022
Useful UE4 Visual Studio extensions.

UE4 Smarter Macro Indenting This extension was designed to fix the unnecessary and annoying "smart" indenting that Visual Studio likes to do around va

Chris Pawlukowsky 250 Dec 16, 2022
Unity OnGUI(IMGUI) extensions for Rapid prototyping/development

RapidGUI Unity IMGUI extensions for Rapid prototyping/development. Installation Install via OpenUPM The package is available on the openupm registry.

null 262 Dec 25, 2022