What is Swoft?
Swoft is a PHP high performance microservice coroutine framework. It has been published for many years and has become the best choice for php. It can be like Go, built-in coroutine web server and common coroutine client and is resident in memory, independent of traditional PHP-FPM. There are similar Go language operations, similar to the Spring Cloud framework flexible annotations.
Through three years of accumulation and direction exploration, Swoft has made Swoft the Spring Cloud in the PHP world, which is the best choice for PHP's high-performance framework and microservices management.
Github
https://github.com/swoft-cloud/swoft
Swoft v2.0.7
Swoft v2.0.7
continues to sail on v2.0.6
and has been used in a large number of production operations, which has been recognized and supported by many users. The official version has made a lot of improvements and optimizations, with better performance.
- Added Http Session function component, provides http session management, supports multiple storage drivers
- Enhanced TCP server request support to add global or corresponding method middleware
- Enhanced Websocket server message request support for adding global or corresponding method middleware
Http Session
Install the swoft/session component with Composer
- Execute
composer require swoft/session
in the directory where the project composer.json is located. - Add
Swoft\Http\Session\SessionMiddleware
middleware to the global middleware
In app/bean.php
:
'httpDispatcher' => [
// Add global http middleware
'middlewares' => [
\Swoft\Http\Session\SessionMiddleware::class,
],
],
The default is based on local file drivers, saved in the runtime/sessions
directory
More on the driver only need to configure the corresponding handler
.
For example, configure the Redis
driver:
'sessionHandler' => [
'class' => RedisHandler::class,
// Config redis pool
'redis' => bean('redis.pool')
],
Websocket Messaging Middleware
- Global middleware
Configured in app/bean.php
:
/** @see \Swoft\WebSocket\Server\WsMessageDispatcher */
'wsMsgDispatcher' => [
'middlewares' => [
\App\WebSocket\Middleware\GlobalWsMiddleware::class
],
],
- Acting on the controller
/**
* Class HomeController
*
* @WsController(middlewares={DemoMiddleware::class})
*/
class TestController
{}
TCP Request Middleware
- Global middleware
Configured in app/bean.php
:
/** @see \Swoft\Tcp\Server\TcpDispatcher */
'tcpDispatcher' => [
'middlewares' => [
\App\Tcp\Middleware\GlobalTcpMiddleware::class
],
],
- Acting on the controller
/**
* Class DemoController
*
* @TcpController(middlewares={DemoMiddleware::class})
*/
class DemoController
{
// ....
}
Update Log
Upgrade tips:
Swoole\WebSocket\Server::push
The fourth parameter$finish
was changed to int type after swoole4.4.12
.- The
TcpServerEvent::CONNECT
event parameter of the tcp server remains the same as receive and close.$fd, $server
swap positions.
Github
https://github.com/swoft-cloud/swoft
Fixed:
- When fixing config injection, if the value is not found, the default value of the corresponding type will be used to override the attribute, causing the default value of the attribute to be overwritten d84d50a7
- Fixed when using the message schedule in ws server, no empty data was filtered, resulting in one more response. Avoid method swoft-cloud/swoft#1002 [d84d50a7](https://github.com/swoft-cloud/swoft-component/ Pull/522/commits/d84d50a76c4c7ff19dc0896868745cfe8f0d93c9)
- Fixed when using message scheduling in tcp server, no empty data was filtered, resulting in one more response. 07a01ba1
- Fixed missing swoft/stdlib library dependencies when using console component independently c569c81a
- Fixed
ArrayHelper::get
When the input key is integer, the parameter parameter is incorrect a44dcad - Fix console rendering using table, when calculating int value, calculate width report type error 74a835ab
- Fixed error in the component user can not customize the default error handling level 4c78aeb
- Fix Enable and disable Component settings
isEnable()
does not work da8c51e56 - Fixes Using the
uniqid()
method in the cygwin environment must set the second parameter to true c7f688f - Fixed Unable to set process title in cygwin environment and cause error c466f6a
- Fixed Unable to delete browser cookie data using http
response->delCookie()
8eb9241 - Fixed ws server message dispatching, the received ext data is not necessarily an array causing an error ff45b35
- Fix log file split by time c195413
- Fix the log
JSON
format small problem a3fc6b9 - Fixed
rpc
service providergetList
call twice fd03e71 - Fix
redis cluster
does not supportauth
parameter 7a678f - Fix model query
json
type, does not supportarray
6023a9 - Fixed redis
multi
operation not connected in time e5f698 - Fix redis does not support
expireAt
,geoRadius
749241 - Fixed
crontab
timestamp detection deviation problem eb08a46
Update(Update):
- Update console also emits an event before rendering the help message
ConsoleEvent::SHOW_HELP_BEFORE
d3f7bc3 - Simplify and unify http, ws, tcp, rpc server management command logic f202c826
- Update the ws and tcp Connection classes to add the
newFromArray
andtoArray
methods to facilitate exporting information and restoring connections via third-party storage (redis
) [a8b0b7c](https://github.com/swoft-cloud/swoft -component/pull/528/commits/a8b0b7c77d56d4392eba75d13a911816b9dc0cee) - Optimize server to add a unified swoole pipe message event handler, use the swowt event in ws, tcp to handle interprocess messages 1c51a8c
Enhancement:
- Now tcp requests support adding global or corresponding method middleware, and the process and usage are similar to http middleware. Useful only when using system scheduling 6b593877
- Now the websocket message request supports adding global or corresponding method middleware, and the process and usage are similar to http middleware. Useful only when using system scheduling 9739815
- Event Management allows setting
destroyAfterFire
to clean up the data carried in the event after each event dispatch 50bf43d3 - Database error exception added
code
returns fd306f4 - Coroutine file operation
writeFile
New write failure exception 08c4244 - RPC new parameter verification 8646fc5