shenzhe / zphp Goto Github PK
View Code? Open in Web Editor NEWZPHP是一个极轻的的,定位于后置SOA服务的开发框架.提供高并发,高性能实时通信方案。
Home Page: http://zchat.45117.com
License: Apache License 2.0
ZPHP是一个极轻的的,定位于后置SOA服务的开发框架.提供高并发,高性能实时通信方案。
Home Page: http://zchat.45117.com
License: Apache License 2.0
问题出现场景:SwooleHttp+php5.6
1.当POST方式调用getByUrl()后,再GET方式调用getByUrl(),95%以上概率会以POST方式发送请求,只有5%以GET方式发送,如果只GET方式调用则正确,没有任何问题。
解决办法:
1.尝试过直接调用ZPHP\Client\Sync\Http::close() 每次再ZPHP\Client\Sync\Http::init(),这个没有解决
2.我查看了下源码,在GET方式请求时,给curl添加curl CURLOPT_HTTPGET 参数即可,
3.添加了reset()方法,其实通过重置curl参数的方法也可以解决。修改的代码见:caojiabin2012@ecca1f1
希望帮忙解答:
1.curl默认是GET方式请求,虽然源码里没有加CURLOPT_HTTPGET参数,$ch都是以静态变量定义的,当调用了POST后在调用GET有一定概率是以GET方式请求的,这个是怎么回事呢?
我看到在protocl里面的Zpack.php这个,有个对客户端发上来的数据进行组包的过程,然后swoole 1.7.3不是有了open_length_check 这个特性了吗,可以依赖这个特性来进行数据的收发,不用使用PHP自己去实现组包
如题
Warning: require(): Permission denied in /git/zphp/ZPHP/View/Adapter/String.php on line 15
Fatal error: Cannot use 'String' as class name as it is reserved in /git/zphp/ZPHP/View/Adapter/String.php on line 15
string(24) "ZPHP\View\Adapter\String"
Warning: Unknown: Permission denied in Unknown on line 0
Fatal error: Uncaught Exception: no class ZPHP\View\Adapter\String in /git/zphp/ZPHP/Core/Factory.php:23 Stack trace: #0 /git/zphp/ZPHP/View/Factory.php(20): ZPHP\Core\Factory::getInstance('ZPHP\\View\\Adapt...') #1 /git/zphp/ZPHP/Protocol/Response.php(44): ZPHP\View\Factory::getInstance('String') #2 /git/zphp/ZPHP/ZPHP.php(117): ZPHP\Protocol\Response::display(Array) #3 [internal function]: ZPHP\ZPHP::fatalHandler() #4 {main} thrown in /git/zphp/ZPHP/Core/Factory.php on line 23
Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0
2.zphp中require目录有直接权限不允许;我已经设置ZPHP chmod -R 777
3.PHP7 ; MAC OSX
Common/Debug.php 中44行 end方法,Log::info();一行,最后差了一个 " ) " ?
display函数的参数,有可能是字符串,当为字符串的时候,unset函数报错?
运行demo的时候出现的
Fatal error: Cannot unset string offsets in /home/wwwroot/lib/ZPHP/Protocol/Adapter/Http.php on line 78
ZPHP/Protocol/Adapter/Http.php
35行:
$_SERVER['PATH_INFO'] 这儿应该是 swoole_http_request->$server
Socket\Callback\HttpServer
1,YAC保存临时数据有64M限制 ,
2,数据全部临时保存在内存不恰当
public function onReceive()
{
$params = func_get_args();
$_data = $params[3];
$serv = $params[0];
$fd = $params[1];
$parser = new HttpParser();
$buffer = $this->cache->getBuff($fd);
$nparsed = (int) $this->cache->getBuff($fd, 'nparsed');
$buffer .= $_data;
$nparsed = $parser->execute($buffer, $nparsed);
if($parser->hasError()) {
$serv->close($fd, $params[2]);
$this->_clearBuff($fd);
} elseif ($parser->isFinished()) {
$this->_clearBuff($fd);
$this->onSend($fd, $this->_getData($parser->getEnvironment()));
} else {
$buffer = $this->cache->setBuff($fd, $buffer);
$nparsed = (int) $this->cache->setBuff($fd, $nparsed, 'nparsed');
}
}
哪里有ZPHP的api文档?
ZPHP\Protocol\Adapter\Json
23行判断$data 应该为 $_data
ZPHP\Log\Adapter\File
log方法也有点儿问题;$params未定义;参数$message, array $context = array()却没用上
Fatal error: Uncaught Error: Call to undefined method swoole_websocket_server::setGlobal() in path/to/zphpdemo/zphp/bin/swoole_http_server.php:48
对于php7.0如何呢?有什么要注意的吗
arning: swoole_server::__construct(): PHP can not running at multi-threading. Reset mode to SWOOLE_MODE_BASE in /usr/sr
/myapp/vendor/keaixiaou/zphp/ZPHP/Socket/Adapter/Swoole.php on line 43
现在启动服务是:php main.php socket_http
在原来的基础上加个参数,比如加了reload,根据$argv[3]来区分操作,这样就实现了。
希望桶哥个加上,这样我就不用每次都修改ZPHP.php的run方法了,希望采纳。
错误所在文件:
zphp / ZPHP / Protocol / Adapter / Http.php
错误方法 display
源代码:
public function display($model)
{
$viewMode = $this->_view_mode;
if(is_array($model)) {
if(!empty($model['_view_mode'])) {
$viewMode = $model['_view_mode'];
unset($model['_view_mode']);
} else {
if (empty($this->_view_mode)) {
$viewMode = Config::getField('project', 'view_mode', '');
}
}
}
$this->_view_mode = '';
if(empty($viewMode)) {
if (ZUtils::isAjax()) {
$viewMode = 'Json';
} else {
$viewMode = 'Php';
}
}
$view = View\Factory::getInstance($viewMode);
if ('Php' === $viewMode) {
if(is_array($model) && !empty($model['_tpl_file'])) {
$view->setTpl($model['_tpl_file']);
unset($model['_tpl_file']);
} else if(!empty($this->_tpl_file)){
$view->setTpl($this->_tpl_file);
$this->_tpl_file = null;
} else {
throw new \Exception("tpl file empty");
}
}
$view->setModel($model);
return $view->display();
}
如果display方法传入的参数$model不是array类型的话,即使在配置文件里设定了view_mode,也还是会使用php 模板的方式去显示
qq加你啦,想和你交流下~
Call to a member function getParams() on null
zphp_chat/apps/ctrl/main/main.php line32
导致直接退出了
因为Request类是静态全局类,如果再swoole 实现类里面 没有显示的设置 Request:setFd ,会导致在实现类里面调用 Request:getFd() 可能取到 上次请求设置的值 ,建议在 接口类中的 回调方法 onConnect,onClose ,如同 onReceive 显示调用 Request:setFd($fd)
另外根据我的测试,我发现 Request的生命周期是 同work 一致的,此处是否使用 request 对象 更好,不然有可能获取一些莫名的值
低版本Linux内核和Mac OSX不支持进程重命名
PHP Warning: cli_set_process_title(): cli_set_process_title had an error: Not initialized correctly in /data/server/swoole/zphpdemo/demo_composer/vendor/zphp/zphp/ZPHP/Socket/Callback/Swoole.php on line 83
public function writeBinary($b, $len=null)
{
if(null === $len) {
$len = strlen($s);
}
$this->writeInt($len);
$this->data .= $b;
//$this->data .= pack('H*', $b);
}
strlen($s) 那里应该是$b 吧
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.