PHPackages                             cockroach/elephant - 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. cockroach/elephant

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

cockroach/elephant
==================

elephant

1.0.3(6y ago)311MITPHPPHP ^7.0

Since Oct 8Pushed 6y ago1 watchersCompare

[ Source](https://github.com/swoole-boot/elephant)[ Packagist](https://packagist.org/packages/cockroach/elephant)[ Docs](https://github.com/swoole-boot/elephant)[ RSS](/packages/cockroach-elephant/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (5)Used By (0)

elephant
========

[](#elephant)

- [依赖软件包地址](#%E4%BE%9D%E8%B5%96%E8%BD%AF%E4%BB%B6%E5%8C%85%E5%9C%B0%E5%9D%80)
- [swoole-boot微服务架构图](#swoole-boot%E5%BE%AE%E6%9C%8D%E5%8A%A1%E6%9E%B6%E6%9E%84%E5%9B%BE)
- [安装方式](#%E5%AE%89%E8%A3%85%E6%96%B9%E5%BC%8F)
- [目录介绍](#%E7%9B%AE%E5%BD%95%E4%BB%8B%E7%BB%8D)
- [rest](#rest)
- [console](#console)
- [调用swoole-boot服务](#%E8%B0%83%E7%94%A8swoole-boot%E6%9C%8D%E5%8A%A1)
- [服务注册到consul调用方式](#%E6%9C%8D%E5%8A%A1%E6%B3%A8%E5%86%8C%E5%88%B0consul%E8%B0%83%E7%94%A8%E6%96%B9%E5%BC%8F)

依赖软件包地址
=======

[](#依赖软件包地址)

[依赖软件包地址](https://github.com/swoole-boot/soft)

- 1.依赖安装方式可以参考上方地址
- 2.具体依赖项可以参考[cockroach/elephant](https://packagist.org/packages/cockroach/elephant)

[回到目录](#elephant)

swoole-boot微服务架构图
=================

[](#swoole-boot微服务架构图)

[![架构图](https://github.com/swoole-boot/swoole-boot/raw/master/swoole-boot-micro-server.png?raw=true)](https://github.com/swoole-boot/swoole-boot/blob/master/swoole-boot-micro-server.png?raw=true)

[回到目录](#elephant)

安装方式
====

[](#安装方式)

```
#composer create-project cockroach/elephant 目录 版本
#如：
composer create-project cockroach/elephant web 1.0.2
```

[回到目录](#elephant)

目录介绍
====

[](#目录介绍)

```
-- yourpath       微服务项目目录

  -- rest             restful应用目录
     -- config          yaf项目配置
     -- application     应用目录
        -- controllers     控制器
        -- plugins         扩展
        -- modules         模块,模块中可以包含控制器,具体可以参考示例程序

  -- common           公用逻辑目录
     -- config           配置,注意和yaf配置做区分

  -- console          控制台应用
     -- config           yaf项目配置
     -- application      应用目录

```

[回到目录](#elephant)

rest
====

[](#rest)

- nginx配置文件示例

```
server {
        listen 80;
        server_name rest.elephant.com;
        root /yourpath/elephant/rest/public;
        index index.php;

        try_files $uri $uri/ @rewrite;

        location @rewrite {
            rewrite ^/(.*)  /index.php/$1 last;
        }

        location ~ \.php {
            fastcgi_index  /index.php;
            fastcgi_pass   127.0.0.1:9000;
            include fastcgi_params;
            fastcgi_split_path_info       ^(.+\.php)(/.+)$;
            fastcgi_param PATH_INFO       $fastcgi_path_info;
            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }

        access_log /tmp/logs/elephant/rest.elephant.com.log main;
}
```

- 访问示例：

```
http://rest.elephant.com/index/index
http://rest.elephant.com/v1/index/index

```

[回到目录](#elephant)

console
=======

[](#console)

使用方式：

- 格式：

```
/usr/local/php/bin/php index.php [controllerName] [actionName]  [param1] [param2] [paramN]

```

如：

```
/usr/local/php/bin/php index.php index cmd 1 2 3
```

调用swoole-boot服务
===============

[](#调用swoole-boot服务)

1.直接调用，服务地址配置到配置文件中（不推荐）
------------------------

[](#1直接调用服务地址配置到配置文件中不推荐)

- 配置组件

```
    'components' => [
            'boot' => [
                'class' => 'cockroach\client\SwooleBoot',
                'host'  => '127.0.0.1',
                'port'  => 888
            ]
    ]

```

- 调用

```
    /**
     * @var \cockroach\client\SwooleBoot $boot
     */
    $boot = Container::get('boot');

    $result = $boot->call('func',[
        'name' => 'func'
    ]);

```

- 响应结果

```
 {
    "code": "20000",
    "message": "success",
    "data": "Hello World"
 }
```

[回到目录](#elephant)

服务注册到consul调用方式
===============

[](#服务注册到consul调用方式)

- swoole-boot服务注册consul方式可以参考[swoole-boot](https://github.com/swoole-boot/swoole-boot)
- lion网关配置方式可以参考[lion](https://github.com/swoole-boot/lion)

```
     /**
     * @var \cockroach\client\Micro $micro
     */
    $micro = Container::get('swoole-boot');

    $result = $micro->call('v1-GetList',[
        'id'     => '1',
        'name'   => 'func get list 20 test',
        'email'  => 'jhq0113@163.com',
        'age'    => 23,
        'mobile' => '13573898909',
        'order'  => '23492348234234'
    ]);

```

- 响应结果

```
 {
     "func": {
         "id": 1,
         "name": "func get list 20 test",
         "email": "jhq0113@163.com",
         "age": 23,
         "mobile": 13573898909,
         "order": 23492348234234,
         "requestId": "elephant_5d9c59077f7db_eed1d",
         "clientIp": "172.17.0.1",
         "nickname": null,
         "ip": null,
         "sex": null,
         "logo": null,
         "imgUrl": null,
         "call": null,
         "patter": null
     }
 }
```

[回到目录](#elephant)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

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 ~9 days

Total

4

Last Release

2380d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/470981d9a18c9a0f789966cf804d9169fd00148e7f1e3b0b8f70d4def9f56ce4?d=identicon)[cockroach](/maintainers/cockroach)

---

Top Contributors

[![jhq0113](https://avatars.githubusercontent.com/u/10301604?v=4)](https://github.com/jhq0113 "jhq0113 (35 commits)")

---

Tags

phpcockroachyafelephant

### Embed Badge

![Health badge](/badges/cockroach-elephant/health.svg)

```
[![Health](https://phpackages.com/badges/cockroach-elephant/health.svg)](https://phpackages.com/packages/cockroach-elephant)
```

###  Alternatives

[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21421.6k](/packages/imanghafoori-laravel-anypass)

PHPackages © 2026

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