2017 © Pedro Peláez
 

library zf-snap-url

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

image

snapshotpl/zf-snap-url

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

  • Saturday, March 15, 2014
  • by snapshotpl
  • Repository
  • 1 Watchers
  • 2 Stars
  • 29 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

ZfSnapUrl Build Status

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

Version 1.1.2 Created by Witold Wasiczko, (*2)

Usage

For routing:, (*3)

user/profile/:id/:slug

Implements interface:, (*4)

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:, (*5)

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

Or you can define multi routes:, (*6)

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:, (*7)

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 (!):, (*8)

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

How to install?

Via composer, (*9)

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

Tests

composer install --dev

or, (*10)

composer update

then, (*11)

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

The Versions

15/03 2014

dev-master

9999999-dev https://github.com/snapshotpl/ZfSnapUrl

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

  Sources   Download

The Requires

 

The Development Requires

by Grzegorz Rygielski

url zf2 view helper

15/03 2014

1.1.2

1.1.2.0 https://github.com/snapshotpl/ZfSnapUrl

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

  Sources   Download

The Requires

 

The Development Requires

by Grzegorz Rygielski

url zf2 view helper

31/10 2013

1.1.1

1.1.1.0 https://github.com/snapshotpl/ZfSnapUrl

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

  Sources   Download

The Requires

 

The Development Requires

by Grzegorz Rygielski

url zf2 view helper

02/08 2013

1.1.0

1.1.0.0 https://github.com/snapshotpl/ZfSnapUrl

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

  Sources   Download

The Requires

 

The Development Requires

by Grzegorz Rygielski

url zf2 view helper

16/07 2013

1.0.0

1.0.0.0 https://github.com/snapshotpl/ZfSnapUrl

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

  Sources   Download

The Requires

 

The Development Requires

by Grzegorz Rygielski

url zf2 view helper

02/07 2013