rolice/laravel5-domain-authority 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

rolice/laravel5-domain-authority

Composer 安装命令:

composer require rolice/laravel5-domain-authority

包简介

Domain Authority Consumer

README 文档

README

Domain authority API consumer for Laravel 5 and inclusively any composer project, relying on Moz.

This package is designed to consume statistical data from Moz API service. In order to utilize the functionality you should have at least free moz account, which can be registered here: https://moz.com/community/join.

The API provide SEO, ranking and authority statistics about a websites, specific domains or subdomains, single pages and internal/external linking.

This package is in basic development phase and not all fields and functionalities are covered. However the base is ready and it is matter of definition to fulfill other property data. Link metrics are missing and batch domain requests are not implemented as well.

The package is tested only on Laravel 5. It can be adapted for Laravel 4 easily as it does not depend on the framework heavily.

Feel free to fork and commit improvements and extensions of the project. The issues section is open for comments, problem reports and suggestions.

Requirements

Installations via composer exclusively will require 64-bit version of PHP, due to high values in the bit-fields, used to query Moz API. A fix is not planned currently for 32-bit versions of PHP, since it will require major extension to support it without crapping the style with hardcoded values as strings.

With manual installation it will work correctly util the column value or bitwise sum of columns for mozspace API exceed integer size on 32-bit platforms (32-bit builds of PHP).

Read more about this issue on URL Metrics page in the project Wiki.

Implementation Level (Supported API)

Here is defined the progress of implementation against Moz API. End-points marked with + are implemented, those with - are not.

  • Anchor Text Metrics (-)
  • Link Metrics (-)
  • Top Pages (-)
  • URL Metrics (+)
  • Index Metadata (-)

Additional Features

  • Domain Age Calculator - an interface gathering registration/creation/activation date of a domain and age calculation.

Installation

The installation process is extremely easy with composer.

Use for production installations:

composer require 'rolice/laravel5-domain-authority:0.3.2' (production, stable)

Latest development version:

composer require 'rolice/laravel5-domain-authority:dev-master' (latest, unstable)

Once the package is set up for you with the help of composer you have to define service provider and aliases in the application config file, located at <project_root>/config/app.php.

    'providers' => [
        // ...
        // ...
        'DomainAuthority\ServiceProvider',
    ],
    
    // ...
    
    'aliases' => [
        // ...
        // ...
        'DomainAge'             => 'DomainAuthority\DomainAge',
        'DomainAuthority'       => 'DomainAuthority\DomainAuthority',
        'UrlMetrics'            => 'DomainAuthority\UrlMetrics',
    ],

The two records in aliases section will allow you to use these classes directly into the views, without calling them through their full namespace.

After you are done you have to publish the the package through the following artisan command:

php artisan vendor:publish

This is required in order to publish the config of the package directly in application config folder. You will find there the new file named domainauthority.php. Edit it and enter the data from your Moz account service authorization:

  • Access ID
  • Secret Key

They can be obtained from the [Access section of your API Dashboard in Moz] (https://moz.com/products/mozscape/access).

Now you are ready to consume the data.

Usage

Currently only URL metrics are implemented. An example how to collect title data and domain authority about an URL is written below:

// Gather data in controller, model or anywhere it is appropriate to do so
$data = App::make('DomainAuthority')
    ->urlMetrics('www.seomoz.org', UrlMetrics::DomainAuthority | UrlMetrics::Title);

// Display results somewhere in the views with Blade template engine
{{ $data->DomainAuthority }} / {{ $data->Title }}

The get method of the DomainAuthority requires an URL address and columns. The columns are passed in the same style as for the Moz API - in bit field. The result is an instance of UrlMetrics, with fields named same way as the columns requested (the class constants).

Caution: These fields are dynamically generated with the help of __get magic method and ReflectionClass. They are not defined in the UrlMetrics class. Some functions like proprty_exists may fail on detecting them.

Domain Age Usage

You can use Domain Age interface fairly easily. It works with who.is website and parses the dates from their response. The class is named DomainAge. It contains three methods:

  • since - method that retrieves the registration date of a domain
  • age - method that calls since and gives the current age of a domain, measured in years
  • fromDate - directly calcualate age by given date in string format, again, in years
$since = App::make('DomainAge')->since($this->item->url); // The $since variable will contain Carbon instance or null on failure
$age =  App::make('DomainAge')->age($this->item->url); // Will contain int with years of age, months and others are ignored
$age2 = DomainAge::fromDate('2010-10-01'); // This will calculate directly age from the given date, useful with previously stored values

Inpotant: Keep in mind that since and age methods will produce cURL request to who.is website, and exceeding certain limits may result in temporarily unavailable service or ban. A good idea here is to store domain birth date returned from since method in some data repository (DB, FileSystem, etc.) and use fromDate to directly get age later without new requests.

rolice/laravel5-domain-authority 适用场景与选型建议

rolice/laravel5-domain-authority 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 562 次下载、GitHub Stars 达 5, 最近一次更新时间为 2015 年 06 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 rolice/laravel5-domain-authority 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 562
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 23
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-09