Hyperf releases v2.1, an enterprise level PHP micro service cloud native collaboration framework

Time:2021-6-14

Update content

After several months of development and debugging and internal online trial, it was finally released todayV2.1Version, it does not add some cross era features, but it is forV3.0The arrival of the version laid a good foundation.

This week, we mainly improved the dependent version of some components, the minimum PHP Version (> = 7.3), and added theSwowDriver adaptation. Published on2.1.0Version.

To update tov2.1.0Version, just add theHyperfThe dependent version of the related component is changed to2.1.*Please refer toUpdate Guide

Warning: all code changes have been noted in the updated content. In addition to updating according to the update guide, you still need to read it carefullyUpdate contentTo avoid omission

Direct access to the official websitehyperf.ioOr documenthyperf.wikiView updates

Dependent upgrade

  • upgradephpVersion to>=7.3
  • Upgrade componentsphpunit/phpunitVersion to^9.0
  • Upgrade componentsguzzlehttp/guzzleVersion to^6.0|^7.0
  • Upgrade componentsvlucas/phpdotenvVersion to^5.0
  • Upgrade componentsendclothing/prometheus_client_phpVersion to^1.0
  • Upgrade componentstwig/twigVersion to^3.0
  • Upgrade componentsjcchavezs/zipkin-opentracingVersion to^0.2.0
  • Upgrade componentsdoctrine/dbalVersion to^3.0
  • Upgrade componentsleague/flysystemVersion to^1.0|^2.0

remove

  • removeHyperf\Amqp\BuilderDiscarded member variables$name
  • removeHyperf\Amqp\Message\ConsumerMessageInterfaceAbandoned methodsconsume()
  • removeHyperf\AsyncQueue\Driver\DriverDiscarded member variables$running
  • removeHyperf\HttpServer\CoreMiddlewareAbandoned methodsparseParameters()
  • removeHyperf\Utils\Coordinator\ConstantsDiscarded constantsON_WORKER_STARTandON_WORKER_EXIT
  • removeHyperf\Utils\CoordinatorAbandoned methodsget()
  • Remove profilerate-limit.php, please userate_limit.php
  • Remove useless classesHyperf\Resource\Response\ResponseEmitter
  • Add componenthyperf/paginatorfromhyperf/databaseRemove from dependency.
  • removeHyperf\Utils\Coroutine\ConcurrentMethods instats()

change

  • methodHyperf\Utils\Coroutine::parentIdReturns the coroutine ID of the parent coroutine

    • If it is in the main coroutine, 0 is returned.
    • If used in a non coroutine environment, theRunningInNonCoroutineExceptionAbnormal.
    • If the orchestration environment has been destroyed, aCoroutineDestroyedExceptionAbnormal.
  • classHyperf\Guzzle\CoroutineHandler

    • Deletedexecute()method.
    • methodinitHeaders()The initialized header list will be returned instead of directly adding the$headersAssignment to the client.
    • DeletedcheckStatusCode()method.
  • #2720No longer in methodPDOStatement::bindValue()Set indata_typeTo avoid the problem that the index cannot be hit when integer is used in string index.

  • #2871fromStreamInterfaceWhen getting data from the(string) $bodyinstead of$body->getContents()Because of the methodgetContents()Only the remaining data, not all, is returned.

  • #2909Duplicate middleware settings are allowed.

  • #2935RevisedException FormatterDefault rule for.

  • #2979command linegen:modelNo longer automaticallydecimalFormat tofloat

Disuse

  • classHyperf\AsyncQueue\Signal\DriverStopHandlerWill be inv2.2Version, please useHyperf\Process\Handler\ProcessStopHandlerInstead.
  • classHyperf\Server\SwooleEventWill be inv3.0Version, please useHyperf\Server\EventInstead.

newly added

  • #2659 #2663AddedSwowDriver support.
  • #2671New monitorHyperf\AsyncQueue\Listener\QueueHandleListenerTo record the running log of asynchronous queue.
  • #2923New classHyperf\Utils\Waiter, which can be used to wait for a coroutine to end.
  • #3001New methodHyperf\Database\Model\Collection::columns(), similar toarray_column
  • #3002byJson::decodeandJson::encodeNew parameters$depthand$flags

repair

  • #2741The fix custom process could not be used in theSwowDriven by the use of the problem.

optimization

  • #3009OptimizedprometheusTo support ithttpsandhttpagreement.

About hyperf

Hyperf is based onSwoole 4.5+The PHP coroutine framework with high performance and high flexibility, built-in coroutine server and a large number of commonly used components, has better performance than the traditional onePHP-FPMThe standard components are based onPSR standardImplementation, based on powerful dependency injection design, ensures that most components or classes areReplaceableAndReusableYes.

Framework component library in addition to the common coroutine versionMySQL clientRedis client, and we’ve also prepared theEloquent ORMWebsocket server and clientJSON RPC server and clientGrpc server and clientOpentracing (Zipkin, Jaeger) clientGuzzle HTTP clientElasticsearch clientConsul, Nacos Service CenterEtcd clientAMQP componentsNATs componentsConfiguration centers of Apollo, etcd, zookeeper, Nacos and alicloud ACMCurrent limiter based on token bucket algorithmUniversal connection poolFuseSwagger document generationSwoole TrackerBlade, Smarty, twig, plates and thinktemplate view enginesSnowflake global ID generatorPrometheus service monitoringAnd so on, which saves the trouble of implementing the corresponding version.

Hyperf also providesDependency injection container based on psr-11annotationAOP aspect oriented programmingMiddleware based on psr-15Custom processEvent manager based on psr-14Redis / rabbitmq message queueAutomatic model cachingCache based on psr-16Crontab second level timing taskSessionI18N internationalizationValidation form validationAnd other very convenient functions, to meet the rich technical scenarios and business scenarios, out of the box.

The original intention of the framework

Although the framework based on PHP language is now in an era of contention, we still can’t see a perfect framework with elegant design and ultra-high performance, or a framework that really paves the way for PHP micro services. This is the original intention of hyperf and its team members, and we will continue to invest in and make efforts for it, You are also welcome to join us in the open source construction.

Design concept

Hyperspeed + Flexibility = HyperfFrom the name we willUltra high speedandflexibilityAs the gene of hyperf.

  • For ultra-high speed, we are based on the spool coroutine and do a lot of optimization on the framework design to ensure ultra-high performance output.
  • For flexibility, we are based on hyperf’s powerful dependency injection components, which are all based onPSR standardMost of the components or classes in the framework are replaceable.

Based on the above characteristics, hyperf will have rich possibilities, such as single web service, API service, gateway service, distributed middleware, micro service architecture, game server, Internet of things (IOT), etc.

Complete documentation

We have invested a lot of time in the construction of documents to provide a high-quality document experience to solve various problems caused by the lack of documents. A large number of examples are also provided on the documents, which are also friendly to novices.

Hyperf official development document

Production available

We have done a lot of unit tests for the components to ensure the correctness of the logic1660Single test and total test5116Hyperf is a project that has experienced severe production environment. At present, many large Internet enterprises have deployed hyperf to their own production environment and run stably.

Official website and communication

GithubPoint star to support us

Gitee code cloudPoint star to support us

Hyperf website

Hyperf document

Hyperf communication group (full): 862099724

Hyperf communication group 2: 811414891

Nail group (full): 34538367

Nail group 2: 34488757

This work adoptsCC agreementReprint must indicate the author and the link of this article

Recommended Today

[database] MySQL exercises and answers (educational administration management system)_ MySQL_ 5.7)

✨ statement The answer to the exercise is not guaranteed to be completely correct, which is for reference only MySQL:5.7 Recommended software: Navicat premium Learning SQL statements requires diligent practice! ✨ Field description of each table course CId Course serial number, primary key PCId Prerequisite course DId Opening department number, foreign key CName Course name […]