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
6
votes
1 answer

cc1plus: error: unrecognized command line option "-std=c++11"

i am trying install php-cpp on centos 6,5. when i run command make, i am getting error: make: Warning: File `Makefile' has modification time 5.1e+05 s in the future mkdir -p shared/common mkdir -p shared/zend mkdir -p shared/hhvm g++ -Wall -c -g…
Mr Jerry
  • 1,686
  • 3
  • 14
  • 22
5
votes
1 answer

Retrieve class name from a Php::Value at PHP-CPP

Working on a small extension for PHP using PHP-CPP, I receive at C++ side, an array with objects and I need retrieve the class name of it. The object Php::Value didn't looks like have any method for it. Similar as i do at HNI in this…
mcuadros
  • 4,098
  • 3
  • 37
  • 44
3
votes
2 answers

Simple Hello World PHP extension could not be executed

I am trying to run simple Hello World PHP extension, but after make & install extension and when I want to run test script I am experiencing following issue: P Warning: PHP Startup: Unable to load dynamic library…
Tom11
  • 2,419
  • 8
  • 30
  • 56
3
votes
2 answers

php-cpp zend/php.h not found

I wanted to test the php-cpp possibilities but while using "make" it throughs "php.h" missing at me: g++ -Wall -c -g -std=c++11 -fpic `php-config --includes` -o zend/base.o zend/base.cpp In file included from zend/base.cpp:8: zend/includes.h:35:10:…
Adrian Z.
  • 904
  • 1
  • 12
  • 29
2
votes
1 answer

why phpcpp extension function written in C++ is slower then function written in php

I have recently created a php extension with PHPCPP - C++ library for developing PHP extensions and was expecting a performance boost, however instead of seeing a boost i m only seeing degradation in performance. I believe i'm doing something…
anonymous007
  • 319
  • 1
  • 3
  • 12
2
votes
2 answers

How to compile PHP-CPP on Windows?

I'm compiling PHP-CPP source but i getting error in Windows 7.But, in Linux (for .so extension) it works fine. The error given by the compiler is: collect2.exe [Error] ld returned 1 exit status Note: I'm using PHP-CPP not PHP source code…
user3156099
1
vote
2 answers

Having extreme difficulty with determining the correct value type for std::map

Addendum: Let me simplify my question, to try this one step at a time, because I feel I've created too much confusion about what I'm trying to achieve. Mind you, I'm using C++11 and I think I'm bound to using this when using the PHP-CPP library.…
Decent Dabbler
  • 22,532
  • 8
  • 74
  • 106
1
vote
0 answers

How to call my extension method to detect written annotation?

Hi i'm tring to write an extension for php in zephir or php-cpp to call my customMethod from my extention when comment block like code below added to php file any suggestion note will be appreciate
phpniki
  • 758
  • 4
  • 13
1
vote
0 answers

Tracking PHP function calls using php-cpp

I am writing a PHP extension using php-cpp to help me profile my code. Is there any way in php-cpp to track all calls to a specific function without modifying my php? e.g. track all calls to json_encode() and get the arguments being passed to…
1
vote
1 answer

Type attributes ignored or undefined reference to phpExtension errors while compiling php-cpp main.cpp file

I'm using php-cpp to create an extension for my php codes and when I try to compile just the simple structure of main.cpp file, I get some weird errors. this is the compile errors: g++ -std=gnu++11 main.cpp In file included from…
Amir
  • 523
  • 1
  • 5
  • 24
1
vote
1 answer

Error while compiling php-cpp main.cpp file

I'm using php-cpp to create an extension for my php codes and when I try to compile just the simple structure of main.cpp file, I get this error.this is the compile errors: main.cpp:15:5: error: ‘PHPCPP_EXPORT’ does not name a type PHPCPP_EXPORT…
mojtaba.sln
  • 51
  • 1
  • 7
1
vote
2 answers

Compile PHP-CPP on Windows Machine

I`m trying develop a extension to PHP with PHP-CPP on Windows. I build the .a and .so of PHP-CPP with MingW, but, when i go build the extension the compiler not found the phpcpp.h. My file Makefile: NAME = Teste INI_DIR …
Pedro Soares
  • 164
  • 1
  • 9
1
vote
1 answer

create a extension for php with php-cpp

i want create a extension for php and i want install php-cpp http://www.php-cpp.com/documentation/install show error: ................ zend/constantimpl.h:185:38: error: ‘zend_constant’ has no member named ‘name_len’ zend/constantimpl.h:185:38:…
1
vote
1 answer

Convert a Php::Object back to a C++ object in PHP-CPP?

I was trying to make a Bencode extension for PHP by PHP-CPP, so there were several classes like: class BItem : public Php::Base { public: virtual std::string getType() const { return "BItem"; } }; class BDict : public BItem…
Frederick Zhang
  • 3,593
  • 4
  • 32
  • 54
1
vote
0 answers

php-cpp extension class arrayaccess return self reference

I have trouble with a custom extension in php. I am extening Php::ArrayAccess for a self made object and I am able to use my object in PHP juste like a native array. BUT I can not chain the operators [] even though I am returning a reference to my…
jav974
  • 1,022
  • 10
  • 22
1
2 3