定制 yuav/mogilefs 二次开发

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

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

yuav/mogilefs

最新稳定版本:1.2

Composer 安装命令:

composer require yuav/mogilefs

包简介

MogileFS PHP Model

README 文档

README

Build Status

This library is an abstraction model for a file stored in MogileFS. The idea is to have a clearly defined api to use for storing and retrieving files from MogileFS.

On find, only paths are retrieved by default, while other properties like domain and class are lazyloaded on request.

This model also include a mysql adapter, as a hack to do bulk operations for looking up multiple paths in one operation. This adapter is likely to break for future MogileFS versions, but MogileFS currently doesn’t support getting multiple paths in one query natively.

Example usage

add with composer

{
    "require": {
        "yuav/mogilefs": "dev-master"
    }
}
<?php
// Config example
$config = array(
	'adapter' => array(
		'tracker' => array('127.0.0.1','127.0.0.2:1234'),
		'domain' => 'dev'
	)
);

// Save
$mapper = new MogileFS_File_Mapper($config); // see tests/config.php
$file = new MogileFS_File();
$file->setKey('motd');
$file->setFile('/etc/motd');
$savedFile = $mapper->save($file);

// Find
$file = $mapper->find('motd');
var_dump($file->getPaths());

Config options

Options should be injected into MogileFS_File_Mapper constructor in an associative array.

For an example see: tests/config.php

Mapper options:

  • adapter

  • defaultadapter

The adapter option can either be an instance of MogileFS_File_Mapper_Adapter_Abstract, or a set of adapter options for the defaultadapter which should contain class name of adapter to instantiate if no adapter is set.

Tracker adapter options:

  • domain (required)

  • tracker (required)

  • request_timeout (seconds)

  • noverify

  • pathcount

The tracker section should contain an array of MogileFS trackers.

Mysql adapter options:

  • domain (required)

  • pdo_options (required)

  • username

  • password

Testing

Tests where performed on Ubuntu 12.04.

To get tests running I installed MogileFS as described in the quickstart: https://code.google.com/p/mogilefs/wiki/QuickStartGuide

I also did one additional command:

	mogadm class add toast dev --mindevcount=3

tests/config.php is set up according to the above setup

Design

All properties except key and paths are lazyloaded on request. This means that no request is sent to the backend server for file info until the getClass() or similar is called within the MogileFS_File model.

MogileFS::getFile() downloads the file to a temporary local file, which should to be deleted by application after use.

Adapters interact with datasource, while mapper populate the File model from adapter output. All adapters have to produce the same output for mapper to parse it correctly.

A test adapter is implemented to allow for application testing without having a live MogileFS running

Naming convention, and design tries to follow that of the Zend Framework 1.x. This also includes sub optimal require_once calls, for compatibility. I reccomend you use an autoloader instead.

统计信息

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

GitHub 信息

  • Stars: 13
  • Watchers: 5
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2013-10-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固