client = new swoole_client(SWOOLE_SOCK_TCP);
}
public function connect() {
if( !$this->client->connect("127.0.0.1", 9501 , 1) ) {
echo "Error: {$fp->errMsg}[{$fp->errCode}]\n";
}
$message = $this->client->recv();
echo "Get Message From Server:{$message}\n";
fwrite(STDOUT, "请输入消息:");
$msg = trim(fgets(STDIN));
$this->client->send( $msg );
}
public function test() {
$this->client = new swoole_client(SWOOLE_SOCK_TCP);
}
}
$client = new Client();
$client->connect();
返回:
Fatal error: Class 'swoole_client' not found in /Applications/MAMP/htdocs/swoole_example/01/swoole_simple_client.php on line 8
更新于(2015-08-07)
另一方方面:
php -i|grep swoole
返回
swoole
swoole support => enabled
swoole.aio_thread_num => 2 => 2
swoole.display_errors => On => On
swoole.message_queue_key => 0 => 0
swoole.unixsock_buffer_size => 8388608 => 8388608
php -i|more里的
Configuration File (php.ini) Path => /Applications/MAMP/bin/php/php5.5.18/conf
Loaded Configuration File => /Applications/MAMP/bin/php/php5.5.18/conf/php.ini,
phpinfo里的
Configuration File (php.ini) Path=>/Applications/MAMP/bin/php/php5.5.18/conf
Loaded Configuration File=>/Library/Application Support/appsolute/MAMP PRO/conf/php.ini
发现只有Loaded Congiguration File不同,
首先
1./Applications/MAMP/bin/php/php5.5.18/conf/php.ini已经写了extension=swoole.so
2/Library/Application Support/appsolute/MAMP PRO/conf/php.ini里面没有swoole.so
3.重启MAMP已经尝试过了
在MAC下安装swoole,顺着文档安装也成功了,具体的细节是:
我把系统的php切换成MAMP的php,然后安装swoole。最后的php -m命令中也已经有swoole在了,但是phpinfo中却搜索不到swoole的字样
然后使用如下代码测试
client = new swoole_client(SWOOLE_SOCK_TCP);
}
public function connect() {
if( !$this->client->connect("127.0.0.1", 9501 , 1) ) {
echo "Error: {$fp->errMsg}[{$fp->errCode}]\n";
}
$message = $this->client->recv();
echo "Get Message From Server:{$message}\n";
fwrite(STDOUT, "请输入消息:");
$msg = trim(fgets(STDIN));
$this->client->send( $msg );
}
public function test() {
$this->client = new swoole_client(SWOOLE_SOCK_TCP);
}
}
$client = new Client();
$client->connect();
返回:
Fatal error: Class 'swoole_client' not found in /Applications/MAMP/htdocs/swoole_example/01/swoole_simple_client.php on line 8
更新于(2015-08-07)
另一方方面:
php -i|grep swoole
返回
swoole
swoole support => enabled
swoole.aio_thread_num => 2 => 2
swoole.display_errors => On => On
swoole.message_queue_key => 0 => 0
swoole.unixsock_buffer_size => 8388608 => 8388608
php -i|more里的
Configuration File (php.ini) Path => /Applications/MAMP/bin/php/php5.5.18/conf
Loaded Configuration File => /Applications/MAMP/bin/php/php5.5.18/conf/php.ini,
phpinfo里的
Configuration File (php.ini) Path=>/Applications/MAMP/bin/php/php5.5.18/conf
Loaded Configuration File=>/Library/Application Support/appsolute/MAMP PRO/conf/php.ini
发现只有Loaded Congiguration File不同,
首先
1./Applications/MAMP/bin/php/php5.5.18/conf/php.ini已经写了extension=swoole.so
2/Library/Application Support/appsolute/MAMP PRO/conf/php.ini里面没有swoole.so
3.重启MAMP已经尝试过了
phpinfo() 沒 swoole ,說明你可能沒重啟apache. 因為php -m 是實時的.所以看不出來.
建議你 php -i|grep swoole 看下先,如果有.很可能就是apache沒重啟造成的.
mac下還有一種可能性,mac自帶了php. 你swoole安裝到自帶的php上了...
分別看下 php -i|more 里面php的路徑和
phpinfo()路徑,對比下.看是否一致.
这个问题原因是你编译swoole生成swoole.so文件的php版本和你现在使用加载swoole的php版本不一致才导致报错的!
你可以用你当前使用的php重新编译一下swoole,生成swoole.so文件,然后在加载。
配置的时候记得指定 --php-config=你当前使用php的php-config路径!
MAMP的php.ini文件用的是模板,直接在对应版本下的php目录中修改是不会生效的,需要修改模板文件,在MAMP的菜单里面有此项功能,添加扩展之后重启web服务就行