当前位置: 首页 > news >正文

企业手机网站开发哪个网站做推广效果好

企业手机网站开发,哪个网站做推广效果好,微信连接微网站,武汉个人做网站的电话一、原理描述 hyperf中,不难发现比如自定义控制器中获取参数,hyperf.php中容器获取,传入的都是接口,而不是实体类。 这是因为框架中的配置文件有设置对应抽象类的子类,框架加载的时候将其作为数组,使用的…

一、原理描述

hyperf中,不难发现比如自定义控制器中获取参数,hyperf.php中容器获取,传入的都是接口,而不是实体类。

这是因为框架中的配置文件有设置对应抽象类的子类,框架加载的时候将其作为数组,使用的时候通过数组对应子类。

实现这个功能就需要composer autoload 代理,即生成的composer.lock文件再处理。但是需要其余对应的composer拉取的程序在composer.json中设置对应数据。

例如

//vendor\hyperf\http-server\composer.json
"extra": {"branch-alias": {"dev-master": "2.2-dev"},"hyperf": {"config": "Hyperf\\HttpServer\\ConfigProvider"}}
//vendor\hyperf\db-connection\composer.json"extra": {"branch-alias": {"dev-master": "2.2-dev"},"hyperf": {"config": "Hyperf\\DbConnection\\ConfigProvider"}}
#vendor/hyperf/http-server/src/ConfigProvider.php
namespace Hyperf\HttpServer;use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\HttpServer\Contract\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;class ConfigProvider
{public function __invoke(): array{return ['dependencies' => [RequestInterface::class => Request::class,ServerRequestInterface::class => Request::class,ResponseInterface::class => Response::class,],'annotations' => ['scan' => ['paths' => [__DIR__,],],],];}
}#vendor\hyperf\db-connection\src\ConfigProvider.php
namespace Hyperf\DbConnection;use Hyperf\Database\Commands\Migrations\FreshCommand;
use Hyperf\Database\Commands\Migrations\GenMigrateCommand;
use Hyperf\Database\Commands\Migrations\InstallCommand;
use Hyperf\Database\Commands\Migrations\MigrateCommand;
use Hyperf\Database\Commands\Migrations\RefreshCommand;
use Hyperf\Database\Commands\Migrations\ResetCommand;
use Hyperf\Database\Commands\Migrations\RollbackCommand;
use Hyperf\Database\Commands\Migrations\StatusCommand;
use Hyperf\Database\Commands\ModelCommand;
use Hyperf\Database\Commands\Seeders\GenSeederCommand;
use Hyperf\Database\Commands\Seeders\SeedCommand;
use Hyperf\Database\ConnectionResolverInterface;
use Hyperf\Database\Connectors\ConnectionFactory;
use Hyperf\Database\Connectors\MySqlConnector;
use Hyperf\Database\Migrations\MigrationRepositoryInterface;
use Hyperf\DbConnection\Listener\RegisterConnectionResolverListener;
use Hyperf\DbConnection\Pool\PoolFactory;class ConfigProvider
{public function __invoke(): array{return ['dependencies' => [PoolFactory::class => PoolFactory::class,ConnectionFactory::class => ConnectionFactory::class,ConnectionResolverInterface::class => ConnectionResolver::class,'db.connector.mysql' => MySqlConnector::class,MigrationRepositoryInterface::class => DatabaseMigrationRepositoryFactory::class,],'commands' => [ModelCommand::class,GenMigrateCommand::class,InstallCommand::class,MigrateCommand::class,FreshCommand::class,RefreshCommand::class,ResetCommand::class,RollbackCommand::class,StatusCommand::class,GenSeederCommand::class,SeedCommand::class,],'listeners' => [RegisterConnectionResolverListener::class,],'annotations' => ['scan' => ['paths' => [__DIR__,],],],'publish' => [['id' => 'config','description' => 'The config for database.','source' => __DIR__ . '/../publish/databases.php','destination' => BASE_PATH . '/config/autoload/databases.php',],['id' => 'query-listener','description' => 'The listener of database to record log.','source' => __DIR__ . '/../publish/DbQueryExecutedListener.php','destination' => BASE_PATH . '/app/Listener/DbQueryExecutedListener.php',],],];}
}

以bin/hyperf.php为例,加载autoload.php文件,执行Hyperf\Di\ClassLoader::init()设置,执行

$application->run();输出命令。

1.1 Hyperf\Di\ClassLoader::init()

Hyperf\Di\ClassLoader::init() 加载配置文件、composer.lock,并合并数据。

主要使用Composer::getMergedExtra('hyperf')['config'],就是composer.lock中extra中的hyperf中config值。

根据config中的值,调用其__invoke()获取数组,并设置。

在上述过程中,涉及ProviderConfig::load();运行,会对ProviderConfig::$providerConfigs数据进行初始化。

ProviderConfig::load()获取的值中包括每个composer拉取的程序中ConfigProvider.php文件中的内容,当然也就包括commands。

ProviderConfig::load()在之后也会被使用。

ClassLoader::init()会调用其构造函数,打印ClassLoader构造中的$config = ScanConfig::instance($configDir);结果,可以看到类内的成员变量包括cacheable、configDir、paths、collectors、ignoreAnnotations、globalImports、dependencies、classMap。

就bin/hyperf.php而言,此时并没有使用配置中的commands数据。

1.2 /config/container.php

hyperf.php中随后加载/config/container.php。

container.php中通过$container = new Container((new DefinitionSourceFactory(true))());,调用DefinitionSourceFactory的构造和__invoke()方法。

DefinitionSourceFactory::__invoke()中通过ProviderConfig::load();加载配置,获取配置中的dependencies数组,最后返回key和object对应的数组。

container.php文件最后返回 Hyperf\Di\Container类,其构造参数的为DefinitionSourceFactory::__invoke()返回的数组。

Hyperf\Di\Container构造方法中会设置$this->definitionSource和$this->resolvedEntries。

1.3 $container->get()

$application对象通过$application = $container->get(Hyperf\Contract\ApplicationInterface::class);获取。调用$container->get()会先判断Container::resolvedEntries是否有数据,有则返回,否则使用Container::make()使用Container::definitionSource创建数据。最后返回对应的实体类。

即为,$application = $container->get(Hyperf\Contract\ApplicationInterface::class);返回ApplicationFactory类,ApplicationFactory构造最后返回Symfony\Component\Console\Application类。

Hyperf\Contract\ApplicationInterface::__invoke()会先执行。其中运行Application::__construct(),设置默认值,比如默认命令为“list”。__invoke()还会将commands数据添加到Symfony\Component\Console\Application中。

1.4 Application::run()

调用 $application->run();,就是调用Symfony\Component\Console\Application::run()。

对于配置文件中commands的处理、console的使用也是在Application::run()方法中。

Application::run()调用Application::doRun()。

doRun()中执行默认的命令“list”,运行Symfony\Component\Console\Command\ListCommand::execute(),其中运行DescriptorHelper::__construct()。

ListCommand::execute()通过DescriptorHelper::describe()运行TextDescriptor(默认)的父类Descriptor::describe()。

Descriptor::describe()中通过其子类实现的describeApplication()方法,获取项目中的commands(配置中的commands),这里即为TextDescriptor::describeApplication()。

TextDescriptor::describeApplication()中通过调用 ConsoleOutput->write()输出内容。

每个命令的execute()方法通过其父类Symfony\Component\Console\Command:run()调用。

dorun()中调用doRunCommand(),这其中会调用Command:run()。

二、原理总结

http://www.zhongyajixie.com/news/31373.html

相关文章:

  • 公众平台网站开发哪家好最常用的搜索引擎有哪些
  • 怎么做网站投放广告的代理商百度网站排名seo
  • 空间查看网站腾讯广告推广平台入口
  • h5做网站教程seo搜索引擎优化推荐
  • 建设网站的技术方案是啥萧山市seo关键词排名
  • 风险地区查询最新长沙seo排名外包
  • 建设一个网站方象科技服务案例
  • 宁波妇科中医哪个好有利于seo优化的是
  • 爱站工具包官网下载吉林关键词优化的方法
  • 宁波做外贸网站推广沈阳seo网站推广
  • 江苏省中医院网站建设深圳seo优化
  • 嘉兴五县两区网站建设关键词优化骗局
  • app试玩网站制作友情链接交换方式有哪些
  • 地方网站模板西安外包网络推广
  • 应用商店软件大全seo产品是什么意思
  • 做企业的网站都要准备什么手续怎么把网站排名到百度前三名
  • 选择建设网站公司要注意什么站长统计app软件下载官网安卓
  • 滕建建设集团网站cpm广告联盟平台
  • 求职招聘网站开发百度seo词条优化
  • 做网站的时候遇到的问题北京网络推广公司
  • 用python做的大型网站软件培训
  • 网站续费申请合肥网络推广培训学校
  • wordpress修改网站标题seo文章生成器
  • 做网站需要哪些东西网站关键词优化排名
  • 苏州网站制作哪家靠谱亚马逊seo是什么意思
  • 做婚纱网站是怎么确认主题福建百度seo排名点击软件
  • access做网站数据库seo网站关键词快速排名
  • 济南专门做网站的公司国际热点事件
  • 上海家装十强企业seo是网络优化吗
  • 做积分商城网站线上销售的方法和技巧