Skip to content

Commit 9d70842

Browse files
committed
update, fix embed bugs
1 parent 334059a commit 9d70842

File tree

11 files changed

+70
-677
lines changed

11 files changed

+70
-677
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,4 @@ bin/phpx
5050
/build/
5151
\.settings/
5252
/Debug/
53+
/examples/embed/bin/embed

examples/embed/project.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"project": {
3+
"name": "embed",
4+
"type": "bin"
5+
},
6+
"build": {
7+
"ldflags": "-L/home/htf/workspace/phpx/lib",
8+
"cxxflags": "-I/home/htf/workspace/phpx/include",
9+
"cflags": "",
10+
"c_std": "",
11+
"cxx_std": ""
12+
},
13+
"install": {
14+
"target": ""
15+
}
16+
}

examples/embed/embed.cc renamed to examples/embed/src/embed.cc

+17-32
Original file line numberDiff line numberDiff line change
@@ -22,44 +22,38 @@
2222
using namespace php;
2323
using namespace std;
2424

25-
void test()
26-
{
25+
void test() {
2726
cout << "hello world" << endl;
2827
}
2928

30-
void md5test()
31-
{
29+
void md5test() {
3230
echo("[0]hash=%s\n", md5("hello world").c_str());
33-
echo("[0]hash_hmac=%s\n", hash_hmac("ripemd160", "The quick brown fox jumped over the lazy dog.", "secret").c_str());
31+
echo("[0]hash_hmac=%s\n",
32+
hash_hmac("ripemd160", "The quick brown fox jumped over the lazy dog.", "secret").c_str());
3433

3534
Variant a("hello world");
3635
echo("[1]hash=%s\n", php::exec("md5", a).toCString());
3736
echo("[1]hash=%s\n", php::exec("md5", "hello world").toCString());
3837

3938
echo("[1]hash_hmac=%s\n",
40-
php::exec("hash_hmac", "ripemd160", "The quick brown fox jumped over the lazy dog.", "secret").toCString());
39+
php::exec("hash_hmac", "ripemd160", "The quick brown fox jumped over the lazy dog.", "secret").toCString());
4140
}
4241

43-
void testRedis()
44-
{
42+
void testRedis() {
4543
cout << "=====================Test Redis==================\n";
4644
Object redis = php::newObject("redis");
4745
var_dump(redis);
4846
auto ret1 = redis.exec("connect", "127.0.0.1", 6379);
49-
//connect success
50-
if (ret1.toBool())
51-
{
47+
// connect success
48+
if (ret1.toBool()) {
5249
auto ret2 = redis.exec("get", "key");
5350
printf("value=%s\n", ret2.toCString());
54-
}
55-
else
56-
{
51+
} else {
5752
cout << "connect to redis server failed." << endl;
5853
}
5954
}
6055

61-
void jsontest()
62-
{
56+
void jsontest() {
6357
Array arr;
6458
arr.append(1234);
6559
arr.append(1234.02);
@@ -74,33 +68,28 @@ void jsontest()
7468
var_dump(arr2);
7569
}
7670

77-
int main(int argc, char * argv[])
78-
{
71+
int main(int argc, char *argv[]) {
7972
php::VM vm(argc, argv);
8073
String value = ini_get("output_buffering");
8174
cout << "ENV:" << value.toInt() << endl;
8275

8376
Variant a = 1;
8477
Variant b = 2;
8578

86-
8779
auto c = a;
8880

89-
9081
testRedis();
9182

9283
include("index.php");
9384
auto o = newObject("test");
94-
9585
var_dump(o);
96-
return 0;
9786

9887
Array url_params;
9988
url_params.set("name", "rango");
10089
url_params.set("value", 1234);
10190

10291
Array _arg_list;
103-
Object redis = php::newObject("redis");
92+
Object redis = newObject("redis");
10493
_arg_list.append(redis);
10594

10695
Variant func = "var_dump";
@@ -109,18 +98,16 @@ int main(int argc, char * argv[])
10998
auto url_query = http_build_query(url_params);
11099
var_dump(url_query);
111100

112-
113-
// jsontest();
101+
jsontest();
114102
md5test();
115-
return 0;
116103

117104
vm.eval("echo 'Hello World!';");
118-
vm.include("embed.php");
105+
include("embed.php");
119106

120-
auto a = constant("SWOOLE_BASE");
121-
cout << "SWOOLE_BASE = " << a.toInt() << endl;
107+
auto c1 = constant("SWOOLE_BASE");
108+
cout << "SWOOLE_BASE = " << c1.toInt() << endl;
122109

123-
auto obj = php::newObject("Test");
110+
auto obj = newObject("Test");
124111
auto ret = obj.exec("getName");
125112

126113
cout << ret.toString() << endl;
@@ -145,7 +132,5 @@ int main(int argc, char * argv[])
145132
String s2 = s1.substr(0, 5);
146133
cout << "s2=" << s2.c_str() << endl;
147134

148-
// swoole_add_function("test", (void*) test);
149-
150135
return 0;
151136
}

examples/queue/README.md

+5-13
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
## Require
22

3-
`SWOOLE`
4-
`PHP-X`
5-
`PHP >= 7.0`
3+
* `PHP-X`
4+
* `PHP >= 7.2`
65

76
## 安装使用
87

98
```bash
10-
mkdir build
11-
cd build
12-
cmake ..
13-
make && make install
14-
```
15-
or
9+
phpx build -v
10+
phpx install
1611

17-
```bash
18-
make && make install
12+
php -dextension=queue.so tests/main.php
1913
```
20-
21-
`php.ini`添加`extension=queue.so`

0 commit comments

Comments
 (0)