To get the most recent version, you can fork the PHP-CPP library on GitHub. If you need or prefer a stable version you can download one of the available releases. When downloading one of the below releases make sure to come back in the future to upgrade to a newer (and improved) version.
v2.4.7 released
- Fixed compile issue on PHP 7
Zip file Tar filev2.4.6 released
- Fixed the Php::include_once() function (it caused memory corruption on PHP 8)
Zip file Tar filev2.4.5 released
- Fixed possible double-free when calling method_exists() or Php::Value::isCallable() on PHP 8
- Fixed version number (forgot to change that in 2.4.4)
v2.4.4 released
- Fixed possible double-free when calling method_exists() or Php::Value::isCallable() on PHP 8
Zip file Tar filev2.4.3 released
- Fixed __get() and related methods for PHP version 8 and up (such methods caused a segfault)
- Fixed Php::Traversable class for PHP version 8 and up (this caused a warning about an abstract class that could not be instantiated)
- All Php::Traversable classes now automatically have a getIterator() method
- Fixed crash when using comparison operators on a non-string Php::Value to compare it with a "const char *"
- Some internal changes to variable-length-arrays compiler to get broader compiler support
- Changes to the build mechanism (we no longer build special object files for shared and static libraries)
v2.4.2 released
- Fixed registering of parameters with an unspecified type for PHP 8 and up (these parameters were incorrectly registered as typed parameters)
Zip file Tar filev2.4.1 released
- No functional changes since 2.4.0
- The "libphpcpp.so" is now a symlink using a relative path, to make it a bit easier to copy around together with the libphpcpp.so.x.y files
v2.4.0 released
- Support for PHP 8.2
- When the "Php::Countable" interface is implemented, the $object->count() method is now implicitly enabled and passed to MyClass::__count().
v2.3.5 released
- Classes that extend from Php::Serializable no longer have to explicitly register the serialize() and unserialize() methods (they are not implicitly added)
Zip file Tar filev2.3.4 released
- Fixed a segmentation fault on extension startup
Zip file Tar filev2.3.3 released
- Fixed PHP 7.4 issue (because of new values for C constants, interfaces were suddenly registered as abstract classes)
Zip file Tar filev2.3.2 released
- Fixed version number (the 2.3.1 release was still creating a 2.3.0 shared object file)
Zip file Tar filev2.3.1 released
- Fixed issue for PHP 7.4 with interfaces that extend from other interfaces
Zip file Tar filev2.3.0 released
- 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
v2.2.0 released
# 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
v2.1.4 released
* added Php::Stream class
Zip file Tar filev2.1.3 released
* 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
v2.1.2 released
* 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
v2.1.1 released
* 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
v2.1.0 released
* 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
v2.0.0 released
Added compatibility with PHP7
v1.5.3 released
- Fix compiler errors when compiling for a multi-threading environment.
- Don't create a std::string with a nullptr
v1.5.2 released
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
v1.5.1 released
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
v1.5 released
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
v1.4 released
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
v1.3.2 released
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
v1.3.1 released
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
v1.3 released
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
v1.2.2 released
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