MAC下安装swoole,在MAMP这块遇到问题
在MAC下安装swoole,顺着文档安装也成功了,具体的细节是:
我把系统的php切换成MAMP的php,然后安装swoole。最后的php -m命令中也已经有swoole在了,但是phpinfo中却搜索不到swoole的字样
然后使用如下代码测试
<?php
class Client
{
private $client;
public function __construct() {
$this->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
暮瞳D迪昇※
9 years, 6 months ago