PHPackages                             gamegos/consul-imex - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. gamegos/consul-imex

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

gamegos/consul-imex
===================

Import/Export Tool for Consul Key/Value Storage

0.1.1(9y ago)6202[2 issues](https://github.com/gamegos/consul-imex/issues)MITPHPPHP &gt;=5.5.9

Since Mar 27Pushed 7y ago3 watchersCompare

[ Source](https://github.com/gamegos/consul-imex)[ Packagist](https://packagist.org/packages/gamegos/consul-imex)[ RSS](/packages/gamegos-consul-imex/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (3)Dependencies (3)Versions (7)Used By (0)

Consul Imex (Import/Export) Tool
================================

[](#consul-imex-importexport-tool)

Consul-Imex is a simple import/export tool for [Consul](https://www.consul.io/) key/value storage over Consul HTTP API.

- Export all the keys in a prefix, save it as a json file.
- Import the keys from a json file to Consul under a specified prefix.
- Copy keys:
    - from a prefix to another prefix.
    - from a server to another server under a specified prefix.

Installation
------------

[](#installation)

You can install Consul Imex in several ways:

- Executable phar file (requires PHP &gt;=5.5.9)
- Docker image (requires [Docker](https://www.docker.com/) engine)
- Composer dependency (requires [Git](https://git-scm.com/), [Composer](https://getcomposer.org/) and PHP &gt;=5.5.9)
- Single PHP project (requires [Git](https://git-scm.com/), [Composer](https://getcomposer.org/) and PHP &gt;=5.5.9)

### Install as an executable phar file

[](#install-as-an-executable-phar-file)

Download the phar file from `https://github.com/gamegos/consul-imex/releases/download/1.0.0-rc1/consul-imex.phar`, then assign execute permission for it.

Example:

```
wget -O /usr/local/bin/consul-imex https://github.com/gamegos/consul-imex/releases/download/1.0.0-rc1/consul-imex.phar
chmod +x /usr/local/bin/consul-imex

```

### Install as a docker image

[](#install-as-a-docker-image)

```
docker pull sozpinar/consul-imex

```

### Install as a Composer dependency

[](#install-as-a-composer-dependency)

```
composer require gamegos/consul-imex

```

### Install as a PHP project

[](#install-as-a-php-project)

Install via `composer`:

```
composer create-project gamegos/consul-imex

```

Or clone/download and install manually:

```
git clone https://github.com/gamegos/consul-imex.git
cd consul-imex
composer install

```

Usage
-----

[](#usage)

#### Run as an executable phar file:

[](#run-as-an-executable-phar-file)

```
consul-imex  [options] [arguments]

```

#### Run as a docker container:

[](#run-as-a-docker-container)

See [Notices for Docker Usage](#notices-for-docker-usage) for detailed information of docker usage.

```
docker run -t -v `pwd`:/consul-imex sozpinar/consul-imex  [options] [arguments]

```

#### Run as a composer vendor binary:

[](#run-as-a-composer-vendor-binary)

```
composer exec -- consul-imex  [options] [arguments]

```

#### Run as a PHP script:

[](#run-as-a-php-script)

```
php scripts/consul-imex.php  [options] [arguments]

```

### Export

[](#export)

#### Usage:

[](#usage-1)

```
consul-imex export [options]

```

#### Arguments:

[](#arguments)

- **file:** Output data file.

#### Options:

[](#options)

- **--url (-u):** Consul server url.
- **--prefix (-p):** Path prefix.
- **--token (-c):** Consul token.

### Import

[](#import)

#### Usage:

[](#usage-2)

```
consul-imex import [options]

```

#### Arguments:

[](#arguments-1)

- **file:** Input data file.

#### Options:

[](#options-1)

- **--url (-u):** Consul server url.
- **--prefix (-p):** Path prefix.
- **--token (-c):** Consul token.

### Copy

[](#copy)

#### Usage:

[](#usage-3)

```
consul-imex copy [options]

```

#### Arguments:

[](#arguments-2)

- **source:** Source prefix.
- **target:** Target prefix.

#### Options:

[](#options-2)

- **--source-server (-s):** Source server URL.
- **--target-server (-t):** Target server URL. If omitted, source server is used as target server.
- **--source-server-token (-c):** Source server Consul token.
- **--target-server-token:** Target server Consul token. If omitted, source server token is used as target server token.

Examples
--------

[](#examples)

### Export

[](#export-1)

```
$ consul-imex export -u http://localhost:8500 -p /old/prefix my-data.json
93 keys are fetched.

```

Export using token key:

```
$ consul-imex export -c 4874874a-2a3s-7892-123e-597a4e1v87e1 -u http://localhost:8500 -p /old/prefix my-data.json
93 keys are fetched.

```

### Import

[](#import-1)

```
$ consul-imex import -u http://localhost:8500 -p /new/prefix my-data.json
93 keys are stored. (25 new directories are created.)

```

Import using token key:

```
$ consul-imex import -c 4874874a-2a3s-7892-123e-597a4e1v87e1 -u http://localhost:8500 -p /new/prefix my-data.json
93 keys are stored. (25 new directories are created.)

```

### Copy

[](#copy-1)

Copy keys from `/old/prefix` to `/new/prefix`:

```
$ consul-imex copy -s http://localhost:8500 /old/prefix /new/prefix
93 keys are fetched.
93 keys are stored. (25 new directories are created.)
Operation completed.

```

Copy keys from `/old/prefix` to `/new/prefix` using token:

```
$ consul-imex copy -s http://localhost:8500 -c 4874874a-2a3s-7892-123e-597a4e1v87e1 /old/prefix /new/prefix
93 keys are fetched.
93 keys are stored. (25 new directories are created.)
Operation completed.

```

Copy keys under `/my/prefix` to another server:

```
$ consul-imex copy -s http://localhost:8500 -t http://anotherhost:8500 /my/prefix /my/prefix
93 keys are fetched.
93 keys are stored. (25 new directories are created.)
Operation completed.

```

Copy keys under `/my/prefix` to another server using token:

```
$ consul-imex copy -s http://localhost:8500 -c 4874874a-2a3s-7892-123e-597a4e1v87e1 -t http://anotherhost:8500 --target-server-token 6242c15a-9w4x-2318-61a2-8as8c47317 /my/prefix /my/prefix
93 keys are fetched.
93 keys are stored. (25 new directories are created.)
Operation completed.

```

Copy all keys to another server:

```
$ consul-imex copy -s http://localhost:8500 -t http://anotherhost:8500
492 keys are fetched.
492 keys are stored. (108 new directories are created.)
Operation completed.

```

Notices for Docker Usage
------------------------

[](#notices-for-docker-usage)

### Input/Output File Location

[](#inputoutput-file-location)

To use `import` and `export` commands with docker, the input/output files must be accessible by the container. The default working directory of the image is `/consul-imex` and input/output files are placed under this directory by default.

#### Examples for `export` command:

[](#examples-for-export-command)

**Example 1:** Mount a host directory to the container for `export` operation, then the container will create `my-data.json` file in the host directory.

```
$ docker run -it -v `pwd`:/consul-imex sozpinar/consul-imex export -u 192.168.1.20:8500 -p /foo/bar my-data.json
93 keys are fetched.

```

**Example 2:** Copy the output file to your working directory after `export` operation.

```
$ docker run -it sozpinar/consul-imex export -u 192.168.1.20:8500 -p /foo/bar my-data.json
93 keys are fetched.
$ docker cp `docker ps -ql`:/consul-imex/my-data.json .

```

#### Examples for `import` command:

[](#examples-for-import-command)

**Example 1:** Mount a host directory to the container for `import` operation, then the container will read `my-data.json` file from the host directory.

```
$ docker run -it -v `pwd`:/consul-imex sozpinar/consul-imex import -u 192.168.1.20:8500 -p /new/prefix my-data.json
93 keys are stored. (25 new directories are created.)

```

**Example 2:** Mount a file to the container and use it for `import` operation. This method does not require the input file to be placed in the default working directory.

```
$ docker run -it -v `pwd`/my-data.json:/my-data.json sozpinar/consul-imex import -u 192.168.1.20:8500 -p /new/prefix -v /my-data.json
93 keys are stored. (25 new directories are created.)

```

### Network Configuration

[](#network-configuration)

If your Consul service is in a private network or does not have a public URL, you may have to set up a custom network configuration for the docker container.

#### Example

[](#example)

```
docker run -it --net=host sozpinar/consul-imex copy -s http://localhost:8500 -t http://anotherhost:8500

```

If the default docker network type is `bridge` then the running container does not recognize 'localhost'. So we simply add `--net=host` argument to make the container to use the network of the host machine.

Known Issues
------------

[](#known-issues)

### Directories with values

[](#directories-with-values)

Consul key/value storage allows a directory to have a value like an ordinary key. If a directory has a value, Consul Imex will ignore the value or the sub-keys; this depends how the keys are ordered.

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~149 days

Total

5

Last Release

2785d ago

Major Versions

0.1.1 → 1.0.0-rc12017-04-11

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6543464?v=4)[Safak Ozpinar](/maintainers/sozpinar)[@sozpinar](https://github.com/sozpinar)

---

Top Contributors

[![sozpinar](https://avatars.githubusercontent.com/u/6543464?v=4)](https://github.com/sozpinar "sozpinar (37 commits)")

---

Tags

consul importerconsul exporterjson to consulconsul to json

### Embed Badge

![Health badge](/badges/gamegos-consul-imex/health.svg)

```
[![Health](https://phpackages.com/badges/gamegos-consul-imex/health.svg)](https://phpackages.com/packages/gamegos-consul-imex)
```

###  Alternatives

[spatie/laravel-export

Create a static site bundle from a Laravel app

672139.5k6](/packages/spatie-laravel-export)[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

5.1k4.9k](/packages/shlinkio-shlink)[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

101466.4k45](/packages/friendsoftypo3-content-blocks)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[eliashaeussler/typo3-solver

Solver - Extends TYPO3's exception handling with AI generated solutions. Problems can also be solved from command line. Several OpenAI parameters are configurable and prompts and solution providers can be customized as desired.

302.1k](/packages/eliashaeussler-typo3-solver)[aeliot/todo-registrar

Register TODOs from source code in issue tracker

153.0k](/packages/aeliot-todo-registrar)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
