walkor / webman-framework Goto Github PK
View Code? Open in Web Editor NEWwebman-framework
webman-framework
Currently on first visit to a page (session cookie doesn't exist yet), session cookie will ignore all other cookies set inside the $_header['Set-Cookie'] array of Response class.
cookie set through convenience method (Set-Cookie key):
cookies deleted (simulating first visit):
current workaround (using set-cookie):
How about setting the session cookie header using "set-cookie" key instead, so it doesn't conflict with convenience method key?
I would submit a pull request, but I can't seem to find where exactly you're setting the header for session cookie. If you could direct me to it I'd be happy to create PR.
v1.5.1 中将原来的 createUnsafeImmutable
改成了 createUnsafeMutable
,这会导致逻辑变更:
Immutable 会以系统环境中的 env 为主,.env 为辅
Mutable 会以.env 为主,系统环境中的 env 为辅
请问这改动是否符合改动预期
个人认为 Immutable 的形式应该更符合使用需求,因为一般在 docker 环境,会通过 env 覆盖 .env 的配置的
如果符合预期,这块目前有没有什么办法能做到动态改变 env 的使用模式
目前使用的折中办法:在 docker 环境下,如果通过 env 传递,那 .env 就不要配置这个参数
class A implements MiddlewareInterface
{
public function process(Request $request, callable $next): Response
{
$response = $next($request);
$err = $response->exception();
if ($err) {
var_dump($err->getMessage());
return response('err');
}
return $response;
}
}
class B implements MiddlewareInterface
{
public function process(Request $request, callable $next): Response
{
throw new \ErrorException('tes234t');
$response = $next($request);
return $response;
}
}
public static function decode(string $buffer, TcpConnection $connection): Request
{
static $requests = [];
$cacheable = static::$enableCache && !isset($buffer[512]);
if (true === $cacheable && isset($requests[$buffer])) {
$request = clone $requests[$buffer];
$request->connection = $connection;
$connection->request = $request;
$request->properties = [];
return $request;
}
$request = new static::$requestClass($buffer);
$request->connection = $connection;
$connection->request = $request;
if (true === $cacheable) {
$requests[$buffer] = $request;
if (count($requests) > 512) {
unset($requests[key($requests)]);
}
}
return $request;
}
workerman中http的$request已经是单独实例化了$request = new static::$requestClass($buffer);
,属于局部变量了,为啥webman中还需要把请求弄个上下文呢?Context::set(Request::class, $request);
对于定义了多个命名空间的包,key($autoload['psr-4'])
取到不可控。
除了我自己的代码,为了兼容thinkphp
的一些依赖,我还定义了一个think
命名空间。
"autoload": {
"psr-4": {
"tpext\\myadmin\\": "src/",
"think\\": "think/"
},
"files": [
"src/helper.php"
]
}
我使用本地git仓库作为依赖的时候取到的是第一个tpext\myadmin
。
发布到packgist
上面再用另外一台电脑安装测试,取到的是think
(也许是排序过),就是这么邪门。
为了兼容,我只能两个命名空间都放个Install.php
,其中think
下面的是继承自真正的那个。
<?php
namespace think;
class Install extends \tpext\myadmin\Install
{
}
现在的问题是,只要安装其他thinkphp
相关的库[think-template/think-orm/think-cache],因为里面都有think
命名空间,
都匹配都我包里面的这个think\Install
重新执行一遍。
建议不要用key($autoload['psr-4'])
取一个,而是遍历数组。
TypeError: Webman\App::__construct(): Argument #1 ($request_class) must be of type string, Workerman\Worker given, called in /webman/start.php on line 55 and defined in /webman/vendor/workerman/webman-framework/src/App.php:96
Also the new App construct have no container.
Incompatible webman-framework and webman.
https://github.com/walkor/webman-framework/blob/master/src/App.php#L96
https://github.com/walkor/webman/blob/master/start.php#L97
And it's a breaking change, so need to be a major version and not a minor version (1.4)
/**
* @return bool
*/
public function acceptJson()
{
return false !== strpos($this->header('accept'), 'json');
}
如上,若 $this->header('accept')
的值为 null
则产生异常
我在设置 server.max_request
这个配置的时候观察到一个现象, 当请求数到达 server.max_request
设置的数值触发重启条件时, 若浏览器未完全关闭 此时 Webman\App::$_worker->connections
永远不会变成 0 , 从而导致无法重启, 这是为何?
若生产环境触发重启条件但是重启总是不成功, 是不是表示会有内存溢出这类风险?
/**
* 被调用开始前执行
* @param $func eg. 'App\Login\Weibo::login'
* @param $serviceName 应用名称 例如'userService'
* @param $serverIp eg. '192.1.1.1'
* @return StatsCenter_Tick object
*/
$tick = \SwooleTracker\Stats::beforeExecRpc($func, $serviceName, $serverIp);
/**
* 被调用结束后执行
* @param $tick StatsCenter_Tick object
* @param $ret true/false
* @param $errno 201
* @return void
*/
\SwooleTracker\Stats::afterExecRpc($tick, $ret, $errno);
It is necessary to add support for spool tracker extension in onmessage.
Webman-framework v1.3.21
Workerman version:4.0.42
PHP version:7.4.3
报错内容:
//不知道为什么会有个Admin
ErrorException: include(/vagrant/webman1/app/Admin/view/hello.html): failed to open stream: No such file or directory in /vagrant/webman1/vendor/workerman/webman-framework/src/support/view/Raw.php:60
Stack trace:
#0 /vagrant/webman1/vendor/workerman/webman-framework/src/support/view/Raw.php(60): {closure}()
#1 /vagrant/webman1/vendor/workerman/webman-framework/src/support/view/Raw.php(60): include()
#2 /vagrant/webman1/support/helpers.php(165): support\view\Raw::render()
#3 /vagrant/webman1/vendor/foo/admin/src/TestController.php(7): view()
#4 /vagrant/webman1/vendor/workerman/webman-framework/src/App.php(135): Foo\Admin\TestController->SayHello()
#5 /vagrant/webman1/vendor/workerman/workerman/Connection/TcpConnection.php(638): Webman\App->onMessage()
#6 /vagrant/webman1/vendor/workerman/workerman/Events/Select.php(295): Workerman\Connection\TcpConnection->baseRead()
#7 /vagrant/webman1/vendor/workerman/workerman/Worker.php(2465): Workerman\Events\Select->loop()
#8 /vagrant/webman1/vendor/workerman/workerman/Worker.php(1574): Workerman\Worker->run()
#9 /vagrant/webman1/vendor/workerman/workerman/Worker.php(1416): Workerman\Worker::forkOneWorkerForLinux()
#10 /vagrant/webman1/vendor/workerman/workerman/Worker.php(1390): Workerman\Worker::forkWorkersForLinux()
#11 /vagrant/webman1/vendor/workerman/workerman/Worker.php(557): Workerman\Worker::forkWorkers()
#12 /vagrant/webman1/start.php(112): Workerman\Worker::runAll()
#13 {main}
复现流程:
1.创建一个插件 php webman plugin:create --name=foo/admin
2.在vendor/foo/admin/src下新建TestController.php文件,内容:
<?php
namespace Foo\Admin;
class TestController{
function SayHello(){
return view('hello');
}
}
3.在app\view下新建hello.html,内容:
<html>
<body>
Hello.
</body>
</html>
4.在config/route.php中添加:
Route::get('/hello', [\Foo\Admin\TestController::class, 'SayHello']);
运行程序,访问/hello,直接报错。
发现报错内容/vagrant/webman1/app/Admin/view/hello.html
,app和view之间多了个奇怪的Admin,感觉是来自于命名空间?不理解为什么会自动加上这个。
Route::group('/a', function () {
Route::resource('/x', app\admin\controller\AdminController::class);
});
Route::group('/b', function () {
Route::resource('/x', app\admin\controller\AdminController::class);
});
该形式可以注册 /a/x/index
和 /b/x/index
的路由,但是它们的 name 都是 x.index
目前看路由的 name 注册和获取太过直接了当,貌似没有太好的解决办法
Using phpunit to add unit test.
Route::get('/foo', function (\Webman\Http\Request $request) {
return 'bar';
});
升级到 1.4.6 之后当 $request 类型非 config('app.request_class') 时(且必须是等于),会报错,Controller action 中同样存在问题
如果要打印当前的路由列表目前没有办法实现,如果应该不是先调用Route::group,Route::$_instance属性会一直是空的,那么$_routes就会一直是空数组。想要查看当前的路由列表就没有办法处理了,不知在目前的情况下有没有其他办法?
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.