定制 zeichen32/website-info 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

zeichen32/website-info

Composer 安装命令:

composer require zeichen32/website-info

包简介

PHP library to retrieve server info from any webpage like installed cms, webserver, etc

README 文档

README

Build Status

PHP library to retrieve server information like installed cms, webserver, dns lookup, etc... from any webpage

Requirements:

Install the library

The preferred way to install this library is to use Composer.

$ php composer.phar require zeichen32/website-info ~1.0

Usage

// Create a new WebsiteInfo instance with all default parser
$ws = \WebsiteInfo\Factory::createWithDefaultParser();

// OR
$ws = \WebsiteInfo\Factory::create(array(
            new \WebsiteInfo\Parser\Webserver\Apache(),
            new \WebsiteInfo\Parser\Webserver\Nginx(),
            new \WebsiteInfo\Parser\Webserver\IIS(),
            // ...
    ));

// Retrieve informations about wordpress.com
$result = $ws->get('http://wordpress.com');

print_r($result);
Array
(
    [headers] => Array
        (
            [request] => Array
                (
                    [Host] => Array
                        (
                            [0] => wordpress.org
                        )

                    [user-agent] => Array
                        (
                            [0] => WebsiteInfo
                        )

                )

            [response] => Array
                (
                    [Server] => Array
                        (
                            [0] => nginx
                        )

                    [Content-Type] => Array
                        (
                            [0] => text/html; charset=utf-8
                        )

                )

        )

    [webserver] => Array
        (
            [name] => Nginx
            [version] => unknown
            [score] => 1
            [raw] => nginx
        )

    [embed] => Array
        (
            [title] => WordPress Blog Tool, Publishing Platform, and CMS
            [description] =>
            [url] => https://wordpress.org/
            [type] => link
            [embed_code] =>
            [images] => Array
                (
                    [collection] => Array
                        (
                            [0] => http://wpdotorg.files.wordpress.com/2012/10/red-negative-w-crop.jpg
                        )

                    [base] => Array
                        (
                            [image] => http://wpdotorg.files.wordpress.com/2012/10/red-negative-w-crop.jpg
                            [width] => 264
                            [height] => 354
                            [aspect_ration] =>
                        )

                )

            [author] => Array
                (
                    [name] =>
                    [url] =>
                )

            [provider] => Array
                (
                    [name] => wordpress
                    [url] => https://wordpress.org
                    [icon] => https://s.w.org/favicon.ico?2
                    [icons] => Array
                        (
                            [0] => https://wordpress.org/favicon.ico
                            [1] => https://wordpress.org/favicon.png
                        )

                )

        )

    [lookup] => Array
        (
            [ip] => Array
                (
                    [0] => 66.155.40.249
                    [1] => 66.155.40.250
                )

            [hostname] => wordpress.org
            [dns] => Array
                (
                    ...
                )

        )

)

Available parser

Parser Class Description
Apache WebsiteInfo\Parser\Webserver\Apache Try to find information about apache webserver
Nginx WebsiteInfo\Parser\Webserver\Nginx Try to find information about nginx webserver
IIS WebsiteInfo\Parser\Webserver\IIS Try to find information about Microsoft IIS webserver
Drupal WebsiteInfo\Parser\CMS\Drupal Try to find information about installed Drupal CMS
Joomla WebsiteInfo\Parser\CMS\Joomla Try to find information about installed Joomla! CMS
Magento WebsiteInfo\Parser\CMS\Magento Try to find information about installed Magento system
phpBB WebsiteInfo\Parser\CMS\PHPBB Try to find information about installed phpBB system
Shopware WebsiteInfo\Parser\CMS\Shopware Try to find information about installed Shopware system
Typo3 WebsiteInfo\Parser\CMS\Typo3 Try to find information about installed Typo3 CMS
vBulletin WebsiteInfo\Parser\CMS\VBulletin Try to find information about installed vBulletin system
Wordpress WebsiteInfo\Parser\CMS\Wordpress Try to find information about installed Wordpress CMS
Google WebsiteInfo\Parser\Analytics\Google Try to find information about used google ads and analytics
Piwik WebsiteInfo\Parser\Analytics\Piwik Try to find information about used piwik analytics
Embed WebsiteInfo\Parser\Embed\Embed Try to find embed information
Lookup WebsiteInfo\Parser\Lookup Try to find lookup informations like dns, ip etc.

Create your own parser

  1. Create a new parser that do something with the response
namespace Acme\Parser;

use WebsiteInfo\Event\ParseResponseEvent;
use WebsiteInfo\Parser\AbstractParser;

class MyParser extends AbstractParser {

    public function onParseResponse(ParseResponseEvent $event)
    {
        // Get response object
        $response = $event->getResponse();
        
        // Do something with the response
        $something = $this->doSomething( (string) $response->getBody() );

        // Add a new section to the output container
        $event->getData()->addSection('my_new_section', array(
            'foo' => 'bar',
            'version' => '1.0',
            'score' => 1,
            'raw' => $something
        ));
    }
}
  1. Use your parser
// Create a new WebsiteInfo instance
$ws = \WebsiteInfo\Factory::createWithDefaultParser();

// Register your parser
$ws->addParser(new \Acme\Parser\MyParser());

// Retrieve informations about wordpress.com
$result = $ws->get('http://wordpress.com');

Using the result container cache

  1. Using the ArrayCache (Memory Cache)
// Create a new WebsiteInfo instance
$ws = \WebsiteInfo\Factory::createWithDefaultParser();

// Using the array cache
$ws->setCache(new \TwoDevs\Cache\ArrayCache());

// Retrieve informations about wordpress.com
$result = $ws->get('http://wordpress.com');
  1. If doctrine cache is installed, it can be used to cache the result container using the doctrine cache adapter.
// Create a new WebsiteInfo instance
$ws = \WebsiteInfo\Factory::createWithDefaultParser();

// Create a new DoctrineCache instance
$doctrineCache = new \Doctrine\Common\Cache\FilesystemCache('var/cache');

// Create a new DoctrineCache adapter
$cacheAdapter = new \TwoDevs\Cache\DoctrineCache($doctrineCache);

// Using the cache
$ws->setCache($cacheAdapter);

// Retrieve informations about wordpress.com
$result = $ws->get('http://wordpress.com');
  1. If zend cache is installed, it can be used to cache the result container using the zend cache adapter.
// Create a new WebsiteInfo instance
$ws = \WebsiteInfo\Factory::createWithDefaultParser();

// Create a new ZendStorage instance
$zendCache = new \Zend\Cache\Storage\Adapter\Memory();

// Create a new ZendCache adapter
$cacheAdapter = new \TwoDevs\Cache\ZendCache($zendCache);

// Using the cache
$ws->setCache($cacheAdapter);

// Retrieve informations about wordpress.com
$result = $ws->get('http://wordpress.com');

How to use a different HttpClient

This library use the Saxulum HttpClientInterface which allows you to simple change the used HttpClient.

For example you want to use Buzz as HttpClient:

  1. Add the Buzz adapter to your composer.json:
$ php composer.phar require saxulum-http-client-adapter-buzz ~1.0
  1. Create a new BuzzClient
    // Create a new Buzz Client 
    $buzz = new \Buzz\Browser();
    
    // Create the client adapter
    $client = new \Saxulum\HttpClient\Buzz\HttpClient($guzzle);
    
    // Create a new WebsiteInfo instance with all default parser and custom client
    $ws = \WebsiteInfo\Factory::createWithDefaultParser($client);
    
    // Retrieve informations about wordpress.com
    $result = $ws->get('http://wordpress.com');
    
    print_r($result);
        

zeichen32/website-info 适用场景与选型建议

zeichen32/website-info 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 01 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「oembed」 「cms」 「server」 「opengraph」 「twitter cards」 「lookup」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 zeichen32/website-info 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 zeichen32/website-info 我们能提供哪些服务?
定制开发 / 二次开发

基于 zeichen32/website-info 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 21
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 24
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-01-21