blob: 3a852ace03ded8908ce9a5727a063fe5092e81c5 (
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
/**
* Extension.h
*
* The extension class is the starting point of your PHP extension. This class
* is instantiated the moment the PHP engine starts - for example when the
* apache process starts - and will be used for all subsequent requests that
* are handled by Apache.
*
* For some environments (for example CLI scripts and FastCGI calls) only one
* request is handled by an extension instance, but for others (when PHP runs
* as module in a webserver) many requests are handled by the same extension
* instance.
*/
/**
* Forward declarations
*/
struct _zend_module_entry;
/**
* Set up namespace
*/
namespace PhpCpp {
/**
* Class definition
*/
class Extension
{
public:
/**
* Constructor
* @param name Extension name
* @param version EXtension version
*/
Extension(const char *name, const char *version);
/**
* Destructor
*/
virtual ~Extension();
/**
* Initialize the extension.
*
* This method is called after the extension has been loaded, constructed
* and after the compatibility has been checked, but before the requests
* are handled. You can override this method to add your own initialization.
*
* The method should return true on success, and false on failure (in which
* case the extension will not be used)
*
* @return bool
*/
virtual bool initialize()
{
return true;
}
/**
* Finalize the extension
*
* This method gets called after all requests were handled, and right before
* the Apache module or CLI script will exit. You can override it to add
* your own cleanup code.
*
* @return bool
*/
virtual bool finalize()
{
return true;
}
/**
* Internal method to get access to the entry
* @return zend_module_entry
*/
_zend_module_entry *entry();
private:
/**
* Extension name
* @var char*
*/
const char *_name;
/**
* Extension version
* @var char*
*/
const char *_version;
/**
* The information that is passed to the Zend engine
* @var zend_module_entry
*/
_zend_module_entry *_entry;
};
/**
* End of namespace
*/
}
|