定制 graviton/import-export 二次开发

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

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

graviton/import-export

最新稳定版本:v3.1.0

Composer 安装命令:

composer require graviton/import-export

包简介

Tooling to help importing and exporting graviton data through REST.

README 文档

README

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version Total Downloads License

Simple graviton client to help importing and exporting data.

Installation

composer require graviton/import-export

Usage

Get help:

./vendor/bin/graviton-import-export help

This will show you all available commands.

Load data to a Graviton instance through REST (using the HTTP interface)

Load from dir:

./vendor/bin/graviton-import-export graviton:import http://localhost:8000 ./test/fixtures

Load data into the core database of a Graviton instance

Besides loading data via the HTTP interface, there are core commands available that allow you to load data into the database backend (MongoDB) of a Graviton instance.

You can import a set of existing files via the graviton:core:import command:

./vendor/bin/graviton-import-export graviton:core:import ./test/data

The core commands file format is slightly different from the normal import format as we need to preserve certain class types. Thus, it's best to insert data into MongoDB and export that into the necessary format. This can be done using the export command:

./vendor/bin/graviton-import-export graviton:core:export ./test/dump-dir

This will dump all the data in the default database. The graviton:core:export has more options, refer to the --help print for more details.

Additionally, we have a purge command that allows you to easily purge (meaning delete!) all collections inside a MongoDB database. You need to pass 'yes' as an only parameter to show that you're sure about that action.

./vendor/bin/graviton-import-export graviton:core:purge yes

File format

The files to be loaded must contain yaml with additional yaml frontmatt (yo dawg...).

The frontmatter part defines what target path a file is to be loaded to.

---
target: /core/app/test
---
{ "id": "test", "name": { "en": "Test" }, "showInMenu": true, "order": 100 }

Importing Files to /file/

  • Files cannot be overwritten, an attempt to update a file-dataset with the tool will throw an error.

Example for a File-Upload, i.e. swisscom.png with additional link to be added to the file dataset:

--- 
target: /file/swisscom 
file: swisscom.png 
--- 
id: swisscom 
links: 
    - 
      type: "accountType" 
      $ref: "http://localhost/entity/code/accountType-1" 

Validate Files

Files are not native YML or JSON file so using this command you can easily check if they are ok.

php ./bin/graviton-import-export graviton:validate:import /{full path to}/initialdata/data/

You can also check for any subfolder directly. Output (single error sample):

Validation will be done for: 60047 files 
 60047/60047 [============================] 100%
Finished

With: 1 Errors
/initialdata/data/param/0_general/event/action/error_file.yml: Malformed inline YAML string ("error_file) at line 1 (near "id: "error_file").

Authentication and Headers on "put" import

Some endpoints may require basic auth or some cookie or header to be sent. -a and -c can be used in combination.

-a is for "basic auth", this will do a base 64 encode header. -a{user:passw}
-c is for Customer Header(s), -c{key:value}  just add more if needed, -c is array enabled.
php ./bin/graviton-import-export graviton:import http://... /{full path to}/initialdata/data/ -ajohn:doe -cheader1:value1 -cheader2:value2

Building Docker Runtime

docker build -t graviton/import-export .

Docker Runtime

docker run --rm -ti -v `pwd`:/data graviton/import-export

Building phar package

Run phar build:

composer build

Deploying phar host

cf push <name-of-host>

Or use deploy-scripts to deploy in automated blue/green fashion.

TODO

  • implement importer
  • implement exporter
  • build phar
  • deploy phar
  • automate phar deployment
  • document phar usage

graviton/import-export 适用场景与选型建议

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

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

围绕 graviton/import-export 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

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