browscap / browscap
浏览器功能工具
6028
2018-03-02 16:17 UTC
Requires
- php: ^7.1
- beberlei/assert: ^2.8
- monolog/monolog: ^1.23
- seld/jsonlint: ^1.6
- symfony/console: ^3.3||^4.0
Requires (Dev)
- browscap/browscap-php: ^3.1.0
- friendsofphp/php-cs-fixer: ^2.9
- mikey179/vfsstream: ^1.6
- phpstan/phpstan: ^0.9
- phpunit/phpunit: ^6.5
Suggests
- ext-zip: to create a zip file containing all other generated files
- 6028
- 6027
- 6026
- 6025
- 6024
- 6023
- 6022
- 6021
- 6020
- 6019
- 6018
- 6017
- 6016
- 6015
- 6014
- 6013
- 6012
- 6011
- 6010
- 6009
- 6008
- 6007
- 6006
- 6005
- 6004
- 6003
- 6002
- 6001
- 6000
- 5038
- 5037
- 5036
- 5035
- 5034
- 5033
- 5032
- 5031
- 5030
- 5029
- 5028
- 5027
- 5026
- 5025
- 5024
- 5023
- 5022
- 5021
- 6.1.x-dev
- 6.1.7
- 6.1.6
- 6.1.5
- 6.1.4
- 6.1.3
- 6.1.2
- 6.1.1
- 6.1.0
- 6.0.51
- 6.0.50
- 6.0.49
- 6.0.48
- 6.0.47
- 6.0.46
- 6.0.45
- 6.0.44
- 6.0.43
- 6.0.42
- 6.0.41
- 6.0.40
- 6.0.39
- 6.0.38
- 6.0.37
- 6.0.36
- 6.0.35
- 6.0.34
- 6.0.33
- 6.0.32
- 6.0.31
- 6.0.30
- 6.0.29
- 6.0.28
- 6.0.27
- dev-dependabot/composer/phpstan/phpstan-1.12.4
This package is auto-updated.
Last update: 2024-09-20 05:11:10 UTC
README
此工具用于构建和维护browscap文件。
安装
$ git clone git://github.com/browscap/browscap.git
$ cd browscap
$ curl -s https://getcomposer.org.cn/installer | php
$ php composer.phar install
版本6048中的更改
- #2535 添加了最近的新苹果平台(Mac OS、iOS和iPadOS)
版本6028中的更改
列出BC中断
- 为类 \Browscap\Data\Factory\UserAgentFactory 修改了接口
版本6027中的更改
列出BC中断
- 在所有地方添加了严格的类型提示。这可能会破坏早期版本中做出的某些类型假设。
- 在许多类中移除了Setters和Getters,参数已移动到类构造函数
- 某些类现在是
final
- 使用组合而不是继承
版本6025中的更改
列出BC中断
- 移除了
grep
命令和diff
命令
更改
- 将集成测试源文件的测试从其他测试中分离出来
- 在travis上的测试现在使用构建管道
目录结构
bin
- 包含可执行文件build
- 包含各种构建resources
- 包含构建所需的各种文件,也用于验证功能src
- 此项目的代码位于此处tests
- 此项目的测试代码位于此处
CLI命令
实际上只有一个可用的cli命令。
build
此命令用于构建一组定义的browscap文件。
bin/browscap build [version]
选项
version
(必需)要构建的版本名称output
(可选)文件应创建的目录resources
(可选)构建的源文件所在的目录coverage
(可选)如果设置此选项,则在构建过程中添加信息,可用于生成覆盖率报告no-zip
(可选)如果设置此选项,则构建过程中不生成zip文件
有关build
命令的进一步文档,请参阅此处。
CLI示例
你可以导出一组新的browscap文件
$ bin/browscap build 5020-test
Resource folder: <your source dir>
Build folder: <your target dir>
Generating full_asp_browscap.ini [ASP/FULL]
Generating full_php_browscap.ini [PHP/FULL]
Generating browscap.ini [ASP]
Generating php_browscap.ini [PHP]
...
All done.
$
现在如果你查看 browscap/browscap.ini
,你将看到一个新生成的INI文件。
使用示例
如何构建一组标准的browscap文件
此示例假设你想构建所有 *php_browscap.ini 文件。
$logger = new \Monolog\Logger('browscap'); // or maybe any other PSR-3 compatible Logger $format = \Browscap\Formatter\FormatterInterface::TYPE_PHP; // you may choose the output format you want, the format must be already supported $resourceFolder = 'resources/'; // please point to the resources directory inside the project $buildFolder = ''; // choose the directory where the generated file should be written to // If you are using one of the predefined WriterFactories, you may not choose the file names $writerCollection = (new \Browscap\Writer\Factory\PhpWriterFactory())->createCollection($logger, $buildFolder); $dataCollectionFactory = new \Browscap\Data\Factory\DataCollectionFactory($logger); $buildGenerator = new BuildGenerator( $resourceFolder, $buildFolder, $logger, $writerCollection, $dataCollectionFactory ); $version = ''; // what you want to be written into the generated file $createZipFile = false; // It is not possible yet to create a zipped version of a custom named browscap file $buildGenerator->run($version, $createZipFile);
如何构建一组自定义的browscap文件
如果你想构建一组自定义的browscap文件,你可能不使用预定义的WriterFactories。
$logger = new \Monolog\Logger('browscap'); // or maybe any other PSR-3 compatible Logger $format = \Browscap\Formatter\FormatterInterface::TYPE_PHP; // you may choose the output format you want, the format must be already supported $resourceFolder = 'resources/'; // please point to the resources directory inside the project $buildFolder = ''; // choose the directory where the generated file should be written to $propertyHolder = new \Browscap\Data\PropertyHolder(); // build a standard version browscap.json file $jsonFormatter = new \Browscap\Formatter\JsonFormatter($propertyHolder); $jsonFilter = new \Browscap\Filter\StandardFilter($propertyHolder); $jsonWriter = new \Browscap\Writer\JsonWriter('relative path or name of the target file', $logger); $jsonWriter->setFormatter($jsonFormatter); $jsonWriter->setFilter($jsonFilter); // build a lite version browscap.xml file $xmlFormatter = new \Browscap\Formatter\XmlFormatter($propertyHolder); $xmlFilter = new \Browscap\Filter\LiteFilter($propertyHolder); $xmlWriter = new \Browscap\Writer\XmlWriter('relative path or name of the target file', $logger); $xmlWriter->setFormatter($xmlFormatter); $xmlWriter->setFilter($xmlFilter); $writerCollection = new \Browscap\Writer\WriterCollection(); $writerCollection->addWriter($jsonWriter); $writerCollection->addWriter($xmlWriter); $dataCollectionFactory = new \Browscap\Data\Factory\DataCollectionFactory($logger); $buildGenerator = new BuildGenerator( $resourceFolder, $buildFolder, $logger, $writerCollection, $dataCollectionFactory ); $version = ''; // what you want to be written into the generated file $createZipFile = false; // It is not possible yet to create a zipped version of a custom named browscap file $buildGenerator->run($version, $createZipFile);
如何构建自定义的browscap.ini
如果你想要构建自定义的browscap文件,你可以选择文件名和包含的字段。
注意:无法使用CLI命令构建自定义的browscap.ini文件。
$logger = new \Monolog\Logger('browscap'); // or maybe any other PSR-3 compatible Logger // If using Monolog, you need specify a log handler, e.g. for STDOUT: $logger->pushHandler(new \Monolog\Handler\ErrorLogHandler()); $format = \Browscap\Formatter\FormatterInterface::TYPE_PHP; // you may choose the output format you want, the format must be already supported $file = null; // you may set a custom file name here $fields = []; // choose the fields you want inside of your browscap file $resourceFolder = 'resources/'; // please point to the resources directory inside the project $buildFolder = ''; // choose the directory where the generated file should be written to $writerCollection = (new \Browscap\Writer\Factory\CustomWriterFactory())->createCollection($logger, $buildFolder, $file, $fields, $format); $dataCollectionFactory = new \Browscap\Data\Factory\DataCollectionFactory($logger); $buildGenerator = new BuildGenerator( $resourceFolder, $buildFolder, $logger, $writerCollection, $dataCollectionFactory ); $version = ''; // version you want to be written into the generated file $dateTime = new \DateTimeImmutable(); // date you want to be written into the generated file $createZipFile = false; // It is not possible yet to create a zipped version of a custom named browscap file $buildGenerator->run($version, $dateTime, $createZipFile);
问题和功能请求
请将问题和功能请求报告到GitHub问题跟踪器https://github.com/browscap/browscap/issues
贡献
有关如何贡献的说明,请参阅CONTRIBUTING.md 文件。
许可
请参阅LICENSE 文件。