承接 snapshotpl/zf-snap-url 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

snapshotpl/zf-snap-url

Composer 安装命令:

composer require snapshotpl/zf-snap-url

包简介

It's the shortest url view helper ever for Zend Framework 2

README 文档

README

It's the shortest url view helper ever for Zend Framework 2! :-)

Version 1.1.2 Created by Witold Wasiczko

Usage

For routing:

user/profile/:id/:slug

Implements interface:

class User implements \ZfSnapUrl\Routable {

    /* CODE */

    public function getRouteName() {
        return 'user/profile';
    }

    public function getRouteParams() {
        return array(
            'id'   => $this->getId(),
            'slug' => $this->getSlug(),
        );
    }
}

Usage in view:

<?= $this->u($this->user) ?>

Or you can define multi routes:

class User implements \ZfSnapUrl\Routable {

    /* CODE */

    public function getRouteName() {
        return 'profile';
    }

    public function getRouteParams() {
        return array(
            'profile' => array(
                'route'  => 'user/profile'
                'params' => array(
                    'id'   => $this->getId(),
                    'slug' => $this->getSlug(),
                );
            ),
            'edit' => function () {
                // You can use closures
                return array(
                    'route'  => 'user/super-long-route-name/edit'
                    'params' => array(
                        'id'   => $this->getId(),
                    );
                ),
            },
        );
    }
}

And just write in view to print user profile url:

To link user profile (default defined in getRouteName())
<?= $this->u($this->user) ?>
Alias for prev usage
<?= $this->u($this->user, 'profile') ?>
Custom route
<?= $this->u($this->user, 'edit') ?>

Without ZfSnapUrl you need to write THIS every single time (!):

<?= $this->url('user/profile', array('id' => $this->user->getId(), 'slug' => $this->user->getSlug())) ?>

How to install?

Via composer

{
    "require": {
        "snapshotpl/zf-snap-url": "1.*"
    }
}

Tests

composer install --dev

or

composer update

then

phpunit --configuration tests/

Changelog

  • 1.1.2 Fixes ZF version dependencies in composer.json, small README improvements
  • 1.1.1 Travis CI
  • 1.1.0 Support for multi routes
  • 1.0.0 Stable version with unit test

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2013-07-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固