Giter Site home page Giter Site logo

swoft-cloud / swoft Goto Github PK

View Code? Open in Web Editor NEW
5.6K 231.0 789.0 6.66 MB

🚀 PHP Microservice Full Coroutine Framework

Home Page: https://swoft.org

License: Apache License 2.0

PHP 87.37% Hack 10.90% Dockerfile 1.71% Shell 0.03%
swoole coroutine microservice aop annotation-framework rpc annotations tcp-server websocket-server http-server

swoft's People

Contributors

233cy avatar alignwebs avatar andreybolonin avatar chongmingdu avatar chunpat avatar danielruf avatar daydaygo avatar dependabot-preview[bot] avatar doobas avatar heibor avatar huangzhhui avatar iamvar avatar inhere avatar jjsty1e avatar limingxinleo avatar linearregression avatar minbaby avatar panyongwei avatar sakuraovq avatar samnela avatar stelin avatar successgo avatar szepeviktor avatar twose avatar whiteccinn avatar wujunze avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swoft's Issues

Swoole\Table::Set: unable to allocate memory

Q A
Bug report? yes
Feature request? no
Swoft version 0.2.2
Swoole version 2.0.12
PHP version 7.2.2

运行了大概5个小时以上,发现输出了一堆的warning错误,重启之后,错误消失

image

建议:请正确写单词

首先,对这个框架,我是非常肯定和认可的。确实也是很NB的一个框架。
当我去翻框架的时候发现,好多单词写错了,phpstorm有N多错单词的提示。举例:
current写成了currrent,switch写成了swith.

the pool of user is not exist! 187

1.0代码 demo 跑起来 找不到user pool
都哪些配置项会影响到 ?
rpcController.php

demo

service.php

<?php
return [
	'consul' => [
		'address' => '',
		'port' => 8500,
		'register' => [
			'id' => '',
			'name' => '',
			'tags' => [],
			'enableTagOverride' => false,
			'service' => [
				'address' => 'localhost',
				'port' => '8099',
			],
			'check' => [
				'id' => '',
				'name' => '',
				'tcp' => 'localhost:8099',
				'interval' => 10,
				'timeout' => 1,
			],
		],
		'discovery' => [
			'name' => 'user',
			'dc' => 'dc',
			'near' => '',
			'tag' => '',
			'passing' => true,
		],
	],
];

app.php

<?php
return [
	'version' => '1.0',
	'autoInitBean' => true,
	'bootScan' => [
		'App\Commands',
		'App\Boot',
	],
	'beanScan' => [
		'App\Controllers',
		'App\Tasks',
		'App\Services',
		'App\Exception',
		'App\Listener',
	],
	'env' => 'Base',
	'cache' => require __DIR__ . DS . 'cache.php',
	'service' => require __DIR__ . DS . 'service.php',
	'provider' => require __DIR__ . DS . 'provider.php',
];

Controller想调用Service怎么办?

使用最新1.0的demo代码 想在demoController 直接调用Service

        /**
	 * @Reference("user")
	 *
	 * @var \App\Lib\DemoInterface
	 */
	private $demoService;

报错
[Semantical Error] The annotation "@reference" in property App\Controllers\DemoController::$demoService was never imported. Did you maybe forget to add a "use" statement for this annotation

关于swoft源码的代码风格问题

@stelin Hi, 你好。关于swoft有没有统一的代码风格,比如psr2 or Zend?,如果需要修改部分代码,以统一风格,我可以贡献一点。

psr2的风格怎么样呢?

压力测试数据库连接查询抛出警告

运行代码:

$result1 = Mobiles::query()->select('*')->where('mobile', '1571155')->limit(1)->getDefer();
$result = $this->redis->set('test1', 1);
var_dump($result);
var_dump($result1->getResult());

执行测试:
ab -n 10 -c 10 http://192.168.1.199:8098/mok/test

抛出警告:
PHP Warning: Swoole\Coroutine\MySQL::query(): mysql client has already been bound to another coroutine. in /dir/project/vendor/swoft/framework/src/Db/Mysql/MysqlConnect.php on line 55

README有错别字

在控制器一节中 注入的依赖默认是单列的。 应为 单例

Composer 安装后,启动服务报Cannot use Swoole\Coroutine\Redis as Redis错误

#问题描述

环境:macos
php版本:

    PHP 7.0.0 (cli) (built: Dec  2 2015 13:35:31) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies

swoft版本:1.0
描述:
1.使用composer create-project swoft/swoft swoft dev-master初始化项目
2.使用php swoft start 开始项目会出现报错,不晓得是不是我php版本低的原因,报错信息如下:

`Fatal error: Cannot use Swoole\Coroutine\Redis as Redis because the name is already in use in /Users/fatjiong/Sites/swoft/vendor/swoft/redis/src/RedisConnect.php on line 9`

解决:
经查看是"./vendor/swoft/redis/src/RedisConnect.php"类内的第九行:use Swoole\Coroutine\Redis; 引用命名空间重复了,我做了下修改,修改成以下这种:

line 9:`use Swoole\Coroutine\Redis as newRedis;`
line 37:`$redis  = new newRedis();` 
用as取别名避免命名空间重复,不知道这样子处理是否可行?
PS:跑docker安装的时候没有发现该问题。
重新执行`php swoft start`,框架已经可以正常执行:
`
Information Panel                     
******************************************************************
* http | Host: 0.0.0.0, port: 8888, Model: 3, type: 1, Worker: 1
* tcp  | Enable: 1, host: 0.0.0.0, port: 8099, type: 1, Worker: 1
******************************************************************
`

php7.0运行时 Swoft\Web\Response 报错

嗨, 在我的php7.0环境下试运行,发现请求响应时终端会输出

PHP Fatal error:  Uncaught TypeError: Return value of Swoft\Web\Response::send() must be an instance of Swoft\Web\void, none returned in /home/quzhi/Code/zpjinfu-service/vendor/swoft/framework/src/Web/Response.php:179
Stack trace:
#0 /home/quzhi/Code/zpjinfu-service/vendor/swoft/framework/src/Web/Application.php(69): Swoft\Web\Response->send()
#1 /home/quzhi/Code/zpjinfu-service/vendor/swoft/framework/src/Server/HttpServer.php(66): Swoft\Web\Application->doRequest(Object(swoole_http_request), Object(swoole_http_response))
#2 [internal function]: Swoft\Server\HttpServer->onRequest(Object(swoole_http_request), Object(swoole_http_response))
#3 /home/quzhi/Code/zpjinfu-service/vendor/swoft/framework/src/Server/HttpServer.php(55): swoole_http_server->start()
#4 /home/quzhi/Code/zpjinfu-service/vendor/swoft/framework/src/Console/Command/ServerController.php(125): Swoft\Server\HttpServer->start()
#5 /home/quzhi/Code/zpjinfu-service/vendor/swoft/framework/src/Helper/PhpHelper.php(50): Swoft\Console\Command\ServerController->startComma in /home/quzhi/Code/zpjinfu-service/vendor/swoft/framework/src/Web/Response.php on line 179

我查看后发现 send方法定义了一个 void类型返回值, 但是php7.0貌似并不支持返回void类型
难道这个项目一定要用php7.1+吗?

第一次运行时报错

open(/home/vagrant/Code/swoft/runtime/logs/swoole.log) failed. Error: No such file or directory[2]

运行后随便访问一个url,则框架会自动生成文件,同时生成目录
runtime/logs/notice.log

退出命令行后第二次运行,由于第一次生成的文件/目录,第二次可以正常运行不报错,并可以正常写入swoole.log 文件

其实我觉得框架应该默认带runtime/logs 这个目录,方便写入日志,而不用运行时创建

ORM可否支持软删除

类似laravel框架Eloquent的SoftDeletes
数据表带时间戳字段deleted_at

顺便是否可支持
数据新增自动填充created_at
数据更新自动更新updated_at

是否有debug模式?

开发时更改了代码都需要重启,是否提供开发模式不用每次都重启服务

rpc调用失败 没有正常走到fallback流程

Q A
Bug report? yes
Feature request? no
Swoft version 0.2.2
Swoole version 2.0.12
PHP version 7.2.2
  1. A机器启动RPC服务

  2. B机器调用A机器的rpc服务
    使用了fallback

  3. A服务关闭

  4. B第一次调用失败,有warning报错,并且没有返回fallback的值
    image

  5. B再次调用,走到正常的fallback流程
    ps: 只有B调用成功过,然后把A关掉之后的第一次调用会出这个问题,应该是连接被服务端直接关闭了,但是client的那边缓存了导致?

Yii

Please remove yii from:
Swoft\Helper\ArrayHelper:569

thanks for swoft

psr7文件上传异常

Bug report? | yes
swoft | beta
swoole | 2.1.0
| PHP version 7.1.14 (cli) (built: Feb 2 2018 08:42:59) ( NTS )
mac 环境

Details

用postman 上传文件,几兆的小文件上传都成功了,但是上传120兆的csv,postman无法获得任何响应,直接报错了,程序当中也没有任何异常输出
image

没有异常输出

Provide minimal script to reproduce the issue

/**
     * @RequestMapping(route="/test/upload",method=RequestMethod::POST)
     *
     * @param Request $request
     * @return array
     */
    public function test(Request $request)
    {
        $id = (int)$request->input('bookId');
        if(empty($id)){
            return ["need id"];
        }
        $file = $request->file("book");
        if ($file instanceof UploadedFileInterface) {
            $type = $file->getClientMediaType();
            if($type == "text/csv"){
                try {
                    $file->moveTo('@runtime/uploadfiles/book_'.$id.".csv");
                    $move = "success";
                } catch (\Throwable $e) {
                    var_dump($e);
                    $move = "false";
                }
            }
        }
        return compact('move');
    }

文档RPC那块没怎么看明白

我看文档里面的RPC列子,服务提供者 和服务消费者是在通一个项目下进行的调用。
实际场景是服务提供者和服务消费者分别在各自的项目里面
我想问的是
服务消费者和服务提供者的项目都用你们的swoft框架
服务消费者的项目里面要如何配置信息

内存碎片

请问这个内存碎片问题是怎么解决的

不支持OPTIONS请求

本地开发时,有跨域情况出现,ajax会预发options请求,但是swoft不支持

sql 语句查询出错

Q A
Bug report? yes
Feature request? yes/no
Swoft version beta
Swoole version 2.1.0
PHP version 7.1.4

Details
只配置主数据库,可以通过命令行生成实体,但是直接通过sql语句查询,无法查询

error.log
     2018/03/05 06:07:39 [error] [swoft] [logid:5a9cdeab04f66] [spanid:0] trace[AopHandler.php:42,Swoft\Proxy\Handler\AopHandler->invoke] mysql执行出错,connectError= error=
2018/03/05 06:07:39 [warning] [swoft] [logid:5a9cdeab04f66] [spanid:0] trace[AopHandler.php:42,Swoft\Proxy\Handler\AopHandler->invoke] Key 2-select * from sl_book-transaction-swoft does not exist
2018/03/05 06:07:39 [warning] [swoft] [logid:5a9cdeab04f66] [spanid:0] trace[AopHandler.php:42,Swoft\Proxy\Handler\AopHandler->invoke] Key contextConnects does not exist
2018/03/05 06:07:39 [warning] [swoft] [logid:5a9cdeab2824c] [spanid:0] trace[AopHandler.php:42,Swoft\Proxy\Handler\AopHandler->invoke] Key contextConnects does not exist

notice.log

2018/03/05 06:07:37 [notice] [swoft] [logid:5a9cdea99d433] [spanid:0] [0.74(ms)] [8(MB)] [process-cronTimer] [] profile[] counting[]
2018/03/05 06:07:37 [notice] [swoft] [logid:5a9cdea9a4fa8] [spanid:0] [0.79(ms)] [8(MB)] [process-cronExec] [] profile[] counting[]
2018/03/05 06:07:39 [debug] [swoft] [logid:5a9cdeab04f66] [spanid:0] trace[AopHandler.php:42,Swoft\Proxy\Handler\AopHandler->invoke] sql execute sqlId=d41d8cd98f00b204e9800998ecf8427e, sql=
2018/03/05 06:07:39 [debug] [swoft] [logid:5a9cdeab04f66] [spanid:0] trace[AopHandler.php:42,Swoft\Proxy\Handler\AopHandler->invoke] SQL语句执行结果(defer) sqlId=mysql result=false
2018/03/05 06:07:39 [notice] [swoft] [logid:5a9cdeab04f66] [spanid:0] [18.17(ms)] [8(MB)] [http://localhost:9501/] [] profile[] counting[]
2018/03/05 06:07:39 [notice] [swoft] [logid:5a9cdeab2824c] [spanid:0] [0.34(ms)] [8(MB)] [http://localhost:9501/favicon.ico] [] profile[] counting[]



Provide minimal script to reproduce the issue

 $sql = "select * from sl_book";
        $em = EntityManager::create();
        $query = $em->createQuery($sql);
        $res = $query->execute()->getResult();
        $em->close();

运行例子报错 PHP Fatal error: Uncaught InvalidArgumentException: the name of bean 不存在, name=lineFormate in /home/vagrant/Code/swoft/vendor/swoft/framework/src/Bean/Container.php:71

[2017-11-17 08:24:35 *16581.0]	ERROR	zm_deactivate_swoole (ERROR 503): Fatal error: Uncaught InvalidArgumentException: the name of bean 不存在, name=lineFormate in /home/vagrant/Code/swoft/vendor/swoft/framework/src/Bean/Container.php:70
Stack trace:
#0 /home/vagrant/Code/swoft/vendor/swoft/framework/src/Bean/Container.php(277): Swoft\Bean\Container->get('lineFormate')
#1 /home/vagrant/Code/swoft/vendor/swoft/framework/src/Bean/Container.php(186): Swoft\Bean\Container->injectProperties(Object(Swoft\Log\FileHandler), Array, Array)
#2 /hom

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.