MAC下安装swoole,在MAMP这块遇到问题
在MAC下安装swoole,顺着文档安装也成功了,具体的细节是:
我把系统的php切换成MAMP的php,然后安装swoole。最后的php -m命令中也已经有swoole在了,但是phpinfo中却搜索不到swoole的字样
然后使用如下代码测试
<code><?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(); </code>
返回:
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
返回
<code>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 </code>
php -i|more里的
<code>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, </code>
phpinfo里的
<code>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 </code>
发现只有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的字样
然后使用如下代码测试
<code><?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(); </code>
返回:
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
返回
<code>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 </code>
php -i|more里的
<code>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, </code>
phpinfo里的
<code>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 </code>
发现只有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服务就行

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.
