PHPackages                             moln/gzfextra - 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. [Framework](/categories/framework)
4. /
5. moln/gzfextra

Abandoned → [zfegg/zend-db-feature](/?search=zfegg%2Fzend-db-feature)ArchivedLibrary[Framework](/categories/framework)

moln/gzfextra
=============

Zend framework 2 extra

1.4(10y ago)01501MITPHPPHP &gt;=5.4

Since Mar 11Pushed 10y agoCompare

[ Source](https://github.com/Moln/gzfextra)[ Packagist](https://packagist.org/packages/moln/gzfextra)[ RSS](/packages/moln-gzfextra/feed)WikiDiscussions master Synced today

READMEChangelog (6)Dependencies (3)Versions (9)Used By (0)

gzfextra
========

[](#gzfextra)

Zend framework 2 extra

Installation using Composer
---------------------------

[](#installation-using-composer)

```
{
    "require": {
        "moln/gzfextra": "~1.0"
    }
}

```

Db - 数据库抽象调用
------------

[](#db---数据库抽象调用)

ZF2 自建 `TableGateway` 方法比较麻烦, 每个Table 要在 service\_manager 加配置. `Gzfextra\Db\TableGateway\TableGatewayAbstractServiceFactory` 为抽象常用 TableGateway 调用.

### Example - 使用举例

[](#example---使用举例)

module.config.php

```
return array(
    'service_manager'    => array(
        'abstract_factories' => array(
            'Gzfextra\Db\TableGateway\TableGatewayAbstractServiceFactory',
        ),
    ),
    'tables' => array(
        'UserTable'  => array(
            'table'     => 'users',
            'invokable' => 'User\\Model\\UserTable',
            'primary'   => 'user_id',
        ),
        'RoleTable' => array(
            'table'     => 'roles',
            'invokable' => 'User\\Model\\RoleTable',
            'primary'   => 'role_id',
        ),
    ),
);
```

User\\Model\\UserTable.php

```
namespace User\Model;
use Zend\Db\TableGateway\TableGateway as ZendTableGateway;

/**
 * UserTable
 *
 * 默认带有公共函数特性
 * @method int fetchCount($where)
 * @method \ArrayObject|\Zend\Db\RowGateway\RowGateway find($id)
 * @method \Zend\Paginator\Paginator fetchPaginator($where = null)
 * @method int deletePrimary($key)
 */
class UserTable extends ZendTableGateway
{
}
```

控制器调用

```
public function indexAction()
{
    $users = $this->getServiceLocator()->get('UserTable');
    $row = $users->find(1);
}
```

Router - 公共路由
-------------

[](#router---公共路由)

ZF2 自带的 `Zend\Mvc\ModuleRouteListener` 不方便, 每新的 `Controller` 都需要在 `ControllerPlugin` 配置下. `Gzfextra\Router\GlobalModuleRouteListener`

### Example - 使用举例

[](#example---使用举例-1)

```
class Module
{
    public function onBootstrap(MvcEvent $e)
    {
        $eventManager = $e->getApplication()->getEventManager();

        $gListener = new GlobalModuleRouteListener();
        $eventManager->attach($gListener);
    }

    public function getConfig()
    {
        return GlobalModuleRouteListener::getDefaultRouterConfig();
    }
}
```

默认路由方式: `/module/controller/action/param1/value1/param2/value2/...`

FileStorage - 文件存储抽象
--------------------

[](#filestorage---文件存储抽象)

文件存储模式

- Filesystem (存储文件系统
- Ftp (存储FTP
- Sftp (存储sftp

### Example - 使用举例

[](#example---使用举例-2)

module.config.php

工厂方式

```
return array(
    'service_manager' => array(
        'factories' => array(
            'FileStorage' => '\Gzfextra\FileStorage\StorageFactory'
        )
    ),
    'file_storage'    => array(
        'type'    => 'fileSystem',
        'options' => array(
            'default_path' => realpath('./public/uploads'),
            'validators'   => array(
                'Extension' => array('gif', 'jpg', 'jpeg', 'png'),
                'Size'      => array('max' => 1024 * 1024),
                'IsImage',
            ),
            'filters'      => array(
                'LowerCaseName',
                'RenameUpload' => array(
                    'target'               => 'shop',
                    'use_upload_extension' => true,
                    'randomize'            => true,
                ),
            ),
        ),
    ),
);
```

抽象工厂

```
return array(
    'service_manager' => array(
        'abstract_factories' => array(
            '\Gzfextra\FileStorage\StorageAbstractFactory'
        ),
    ),
    'file_storage_configs' => array(
        'ImageFileStorage'    => array(
            'type'    => 'fileSystem',
            'options' => array(
                'default_path' => realpath('./public/uploads'),
                'validators'   => array(
                    'Extension' => array('gif', 'jpg', 'jpeg', 'png'),
                    'Size'      => array('max' => 1024 * 1024),
                    'IsImage',
                ),
                'filters'      => array(
                    'LowerCaseName',
                    'RenameUpload' => array(
                        'target'               => 'shop',
                        'use_upload_extension' => true,
                        'randomize'            => true,
                    ),
                ),
            ),
        ),
        'ZipFileStorage'    => array(
            'type'    => 'ftp',
            'options' => array(
                'ftp' => array(
                    'host' => 'localhost',
                    'username' => 'ftpuser',
                    'password' => '123456',
                    'pasv' => true,
                ),
                'default_path' => '/',
                'validators'   => array(
                    'Extension' => array('zip'),
                ),
                'filters'      => array(
                    'LowerCaseName',
                    'RenameUpload' => array(
                        'target'               => 'zipfile',
                        'use_upload_extension' => true,
                        'randomize'            => true,
                    ),
                ),
            ),
        ),
    ),
);
```

控制器调用

```
public function indexAction()
{
    $fileStorage = $this->getServiceLocator()->get('ImageFileStorage');
    if ($fileStorage->isValid()) {
        $file = $fileStorage->upload($file);
        // var_dump($file);
    }
}
```

Tool - Gzfextra 工具
------------------

[](#tool---gzfextra-工具)

依赖 `zendframework/zftool`

EasyMvc - (正在评估ZF2 框架流程是否能简化部分)
-------------------------------

[](#easymvc---正在评估zf2-框架流程是否能简化部分)

Mvc - 扩展Mvc模块
-------------

[](#mvc---扩展mvc模块)

- `Gzfextra\Controller\Plugin\Params` 类似 ZF1的 $this-&gt;getParam(), 默认取路由, 不存在取POST&amp;GET

UiFramework
-----------

[](#uiframework)

目前限 KendoUi

- KendoUi 的控制器插件

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

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

Recently: every ~39 days

Total

7

Last Release

3969d ago

Major Versions

0.9-alpha → 1.0.x-dev2015-03-17

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2050694?v=4)[Moln](/maintainers/Moln)[@Moln](https://github.com/Moln)

---

Top Contributors

[![Moln](https://avatars.githubusercontent.com/u/2050694?v=4)](https://github.com/Moln "Moln (17 commits)")

---

Tags

ZendFrameworkzf2zfextra

### Embed Badge

![Health badge](/badges/moln-gzfextra/health.svg)

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

###  Alternatives

[zucchi/zucchi

Zucchi Component Library for Zend Framework 2

121.5k1](/packages/zucchi-zucchi)

PHPackages © 2026

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