Questions tagged [php-cpp]

PHP-Cpp is a C++ library for developing PHP extensions. It contains a collection of classes used to build and/or extend PHP extensions.

Ten reasons for using PHP-CPP
There are many reasons for using PHP-CPP. Let's name a few.

1. It's fast
Code written in C++ is fast - much faster than code written in PHP. When you start using C++, you bring down your CPU and memory load, and your web pages instantly become more responsive. You can bring down the hardware costs, because you simply need less servers to handle the same number of page views.

2. It is shockingly simple
C and C++ have a reputation of being difficult and complex. But just take a look at the examples in our documentation and surprise yourself. The simple reality is that algorithms written in C++ look almost identical to algorithms written in PHP. If you know how to program in PHP, you can easily learn how to do the same in C++.

In fact, the syntax of PHP and most PHP function names are directly derived from the C and C++ syntax. Moving from PHP to C++ is like coming home. We have missed you, you have been away for too long.

3. No Zend engine knowledge required
Let's face the truth: the internals of the Zend engine are way too complex, and the code of the Zend engine is a mess, and mostly undocumented. You do not want to deal with that on a day to day basis. This has always been a good reason to stay far away from writing your own native extensions.

But the PHP-CPP library has encapsulated all these complicated structures in very easy to use C++ classes and objects. You can write amazingly fast algorithms using C++ without ever having to do a direct call to the Zend engine, and without even having to look at the Zend engine source. With PHP-CPP you can write native code, without having to deal with the internals of PHP.

4. Full documentation and annotated source
Many programmers find it a matter of honor to make code that can only be understood by themselves. We do not agree. The PHP-CPP library is fully documented (the documentation can be found on www.php-cpp.com/documentation), and the source code is full with comments and explanations.

If you ever need more information, or want to have a look at the source code, you can easily find your way (although the internal parts that deal with the Zend engine can sometimes be confusing, but that's because the Zend engine is so complicated).

5. Support for all the important PHP features
With PHP-CPP you can work with variables, arrays, functions, objects, classes, interfaces, exceptions and namespaces just as easily as you can with normal PHP scripts. Besides that, you can use all features of C++, including threads, lambdas and asynchronous programming.

6. You can't go faster than native
There are many different technologies under development that all try to speed up PHP. But nothing is ever going to beat native code. C/C++ is the fastest of all languages. Why would you choose for any of the other emerging technologies - if you can use the fastest of all languages too, which is is just as simple (if not simpler) as its alternatives?

7. Proven technology
C++ is a proven language with a more than 40 year long history. C++ has an official open standard and is controlled by a C++ standards committee with members that have proven track records. Compilers have been developed by companies like Microsoft, IBM, Intel, Apple and there are several open source compilers available (GNU, CLANG), so you can always switch to a faster or more stable alternative. The compiler vendors are constantly motivated to be better than their competitors and bring out new versions of their compilers all the time.

All this has lead to an extremely stable, powerful, clever and high quality programming language. The number of books and training courses about C++ is overwhelming, and this great C++ language can now also be used for building PHP extensions.

Alternative technologies to speed up PHP are not based on open standards, are controlled by single companies, do not have competing implementations, miss the long C++ heritage, and often only make your software more complex.

8. Access to an incredible amount of libraries
C/C++ is the most important language in the world, with the largest number of libraries. The moment you start writing code in C/C++ you immediately get access to this enormous amount of libraries. No other language can even come close to the number of libraries that are available in C/C++.

9. Working with C++ is fun
C++ is a great language that allows you to write brilliant object oriented code - but gives you at the same time the power to ruin everything. Working with C++ is like driving a very powerful sportscar: in the right hands it is the best car in the world, but also a dangerous weapon in the wrong hands. As a driver - you want such a car. As a programmer - you want C++.

10. IT IS FREE!
PHP-CPP is an open source technology and free for you to use. You would be crazy not to try it.

Documentation :

https://www.php-cpp.com/documentation/introduction

32 questions
0
votes
1 answer

Linking phpcpp fails when building PHP extension

Environment: I am trying to develop a PHP-CPP extension and have downloaded the the empty extension file from https://www.php-cpp.com/documentation/your-first-extension to start. I have also modified the makefile's INI_DIR variable to point to the…
gearDev
  • 29
  • 1
  • 8
0
votes
2 answers

PHP-CPP returning a string results in the strlen instead of plain string

So i wrote a little extension with the help of php-cpp. In this function, i just simply calculate the pow, which works perfectly fine. After calculating the result, i return the string from the function. When i call this extensions function in php,…
Tyralcori
  • 1,079
  • 13
  • 33
0
votes
0 answers

how to install and configure phpcpp legacy module with phpv5.3.3 over centos 6.9

Getting the error after installation and compiling phpcpp legacy version module with phpv5.3.3 php -v PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/libphpcpp.so' - /usr/lib64/php/modules/libphpcpp.so:…
ghilman
  • 1
  • 1
0
votes
1 answer

Linking PHP-CPP library to a Linux project in Visual Studio 2017

I have a small C++ test project which should result in a .so-library on Windows Subsystem for Linux (WSL, more or less = Ubuntu 14.x). In order to get a PHP extension the current version of the PHP-CPP library is linked to the project. The compiler…
Robert
  • 97
  • 6
0
votes
0 answers

use php-cpp error: undefined symbol: executor_globals in Unknown on line 0

I successfully compiled the EmptyExtension and got salamander_php.so(my extension name). Then I copied it to the php extension_dir and added the row to the php.ini extension=salamander_php.so when I input php -v I got the warning PHP Warning: PHP…
pigLoveRabbit520
  • 513
  • 7
  • 19
0
votes
1 answer

how to add an static array in php class with php-cpp

I want to add a static member like below class BaseYii{ public static $map = [1,2,3]//sutff } this is my c++ code , class BaseYii : public Php::Base { public: Php::Array hehe; BaseYii() = default; /** * c++ destructor */ virtual…
Big Pig
  • 1
  • 1
0
votes
1 answer

How to convert C++ map> to Php::Value in PHPCPP library?

I'm am creating PHP extension using PHP library, and I am having difficulties converting C++ map variable to PHPCPP Php::Value returned by a function. The reason I'm doing this is to get multidimensional associative array result from a function…
anonymous007
  • 319
  • 1
  • 3
  • 12
0
votes
1 answer

How to pass Array of Objects using PHPCPP, loop through each object and return associative array

I have recently started learning PHPCPP - A C++ library for developing PHP extensions and trying to understand: how to pass an Array of objects from php to C++ through PHPCPP library as examples give only info about arrays and objects separately,…
anonymous007
  • 319
  • 1
  • 3
  • 12
0
votes
1 answer

no matching function for call to ‘Php::Extension::add()

I am using PHP-CPP for creating PHP extension to call c++ function. I have resolved many error after integrating my cpp to example code of cpp by PHP-CPP. But I am stuck at following error, CapPicture.cpp: In function ‘void*…
Amit
  • 49
  • 6
0
votes
0 answers

How can i compiking sn extension with phpcpp using mac osx yosemite

I am creating my first extension but i have found this error compiling "ld library not found for -lphpcpp" how can i solve it? I am using mac osx yosemite
0
votes
2 answers

How can i compile program in static library?

I used php-cpp and create program and worked fine in shared library and Makefile is Here but i want compile with static library So i used this command: /opt/rh/devtool/opt/rh/devtoolset-3/root/usr/bin/g++ -c -std=c++11 md5.cpp -o…
0
votes
0 answers

PHP-CPP : How to stop current request without using exit(0)

I am creating a simple PHP module with PHP-CPP library. I make this to limit process per IP address per php script file. I have found a solution for everything I needed, except 1 thing : I cant stop the script cleanly. If you look in the script it…
user1270589
0
votes
1 answer

PHP-CPP C++ Extension Can't Find Regex

I'm writing a C++ extension for PHP and I'm using regex in my code. Here is a snippet #include #include #include #include #include #include #include #include using…
Daniel Wardin
  • 1,840
  • 26
  • 48
0
votes
1 answer

PHP-CPP new extension works on cli 'php' command but not in browser

I am using PHP-CPP to create a php extension which contains a function that will parse a table from mysql. extension.cpp #include #include #include Php::Value ss_parse_table(Php::Parameters ¶ms) { MYSQL…
shanks
  • 75
  • 8
0
votes
2 answers

How can I make my PHP extension programmed in C++ remember global variables?

I am using the PHP-CPP library to develop PHP extensions. When I try the following in C++: #include static int number=0; Php::Value get_num() { number++; return number; } And the following in PHP:
LogicalException
  • 566
  • 2
  • 7
  • 16