DEV Community

Cover image for PHP microservices framework — Swoft 2.0.5 published
stelin
stelin

Posted on

PHP microservices framework — Swoft 2.0.5 published

What is Swoft?

Swoft is a PHP microservices coroutine framework based on the Swoole extension. Like Go, Swoft has a built-in coroutine web server and a 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, powerful global dependency injection container, comprehensive service governance, flexible and powerful AOP, standard PSR specification implementation and so on.

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.

Efficient seconds crontab

The following simple lines of code define a timed task that is executed every second, which can completely replace the system crontab.

<?php declare(strict_types=1);

namespace App\Crontab;

use Swoft\Crontab\Annotaion\Mapping\Cron;
use Swoft\Crontab\Annotaion\Mapping\Scheduled;

/**
 * Class CronTask
 *
 * @since 2.0
 *
 * @Scheduled()
 */
class CronTask
{
    /**
     * @Cron("* * * * * *")
     */
    public function secondTask()
    {
        printf("second task run: %s ", date('Y-m-d H:i:s', time()));
    }
}

The crontab starts with the service and will see the following display:

-w1249

Exception management

During the development process, if the error message is a string of characters, it is not convenient for the business to solve the problem. If the component is used, all error messages will be displayed as follows:

whoops

Update

Fixed:

  • Fixing early interrupt request logic may result in incorrect formatting of the corresponding Content-Type f031398
  • Fixed the use of sgo to create child coroutines, at the end did not clean up the mapping with the top coroutine de11ae5b
  • Fix Xml format parsing method 24d0038
  • Fix class proxy Unique string problem 444ddeb
  • Fixed context()->get() problem and discard Context::mustGet() method 6acc1b5
  • Fixed interface injection, class name access error 2d9a31f
  • Repair model uses the paginate method, the result set has no mapping field 3027287
  • Fixed websocket server error when there are multiple workers and actively closes non-current worker connections 7666969

Update:

  • The default worker num setting is obtained by the swoole_cpu_num function 553f6500
  • The validator is adjusted to, the default is not required, the user opens e5b258d
  • No longer throws containerException inside the swowt to the user-used layer 1e74893
  • console output Add interactive methods such as confirm select 0181138a

Enhancement:

  • The console command option sets CommandOption, which now allows options to be described as multiple lines of information e5914983
  • All messaging methods for websocket server, support for incoming opcode parameter dc164ffe9
  • The websocket module allows setting the default opcode of the current module for automatic processing of return data settings opcode 9e3e9672
  • Enhanced websocket related classes, now the message processing method allows to inject more data object types Request Response 3d6c60b4
  • When the worker exits, the websocket server will automatically close all connections 5ea10ecc
  • Add Timer timer package eb92ee6
  • Add Coroutine Method Package d8c2b88

Resource

Top comments (0)