blob: 7a4c15d2eea73cb8d6341b94878370635b1eb2da (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
/**
*
* An example file to show the working of using a C++ class in PHP.
*/
#include <string>
#include <iostream>
#include <phpcpp.h>
// Test includes
#include "include/testValueIterator.h"
#include "include/MyCustomClass.h"
// Symbols are exported according to the "C" language
extern "C"
{
// export the "get_module" function that will be called by the Zend engine
PHPCPP_EXPORT void *get_module()
{
// create extension
static Php::Extension extension("extention_for_tests","0.1");
// build an interface
//Php::Interface interface("MyInterface");
// add methods to the interface
//interface.method("method1");
//interface.method("method2");
// add the interface to the extension
//extension.add(interface);
// we are going to define a class
Php::Class<TestBaseClass::MyCustomClass> customClass("TestBaseClass\\MyClass");
// add methods to it
customClass.method("myMethod", &TestBaseClass::MyCustomClass::myMethod, Php::Final, {});
customClass.property("property1", "prop1");
customClass.property("property2", "prop2", Php::Protected);
// add the class to the extension
extension.add(customClass);
// add function to extension
//extension.add("TestValueIterator\\loopValue", TestValueIterator::loopValue/*, {
extension.add("TestValueIterator\\loopValue", TestValueIterator::loopValue);
// return the extension module
return extension;
}
}
|