ZF2 Modules Galore!

I’m a slacker

So, I haven’t made a post in over a year and I feel so bad I want to do an awesome post to make up for it. So, behold, a quick & dirty summary of all my available ZF2 modules. I tend to jump around from module to module depending on my current needs so I’ll try and list the state of each module.

The Modules

I’ll list each module in descending order from how useful I personally think they are. Your own mileage may vary. As always, I’m accepting PR’s so if you want to contribute please do so!

SpiffyNavigation

is aimed to be a replacement for Zend\Navigation once ZF3 comes around. I used a RecursiveIterator with composite pattern to make traversing containers quick. This makes SpiffyNavigation very performant!

It’s missing some view helpers and a few other features like priority but overall it’s pretty solid.

Tests: Yes
Documentation: Yes
Production ready: Yes

SpiffyConfig

is my newest module which is not ready for production but came from my previous work on . The goal of SpiffyConfig is to expedite configuration via annotations without sacrificing performance. It’s hard to explain this one so I’ll use a few examples:


namespace Application\Controller;

use SpiffyConfig\Annotation\Controller;
use SpiffyConfig\Annotation\Route;
use SpiffyConfig\Annotation\Service;
use Zend\Mvc\Controller\AbstractActionController;

/**
 * @Controller\Invokable(name="index")
 * @Service\Invokable(name="index", key="controllers")
 * @Route\Generic(type="literal", action="index", name="home", mayTerminate=true, options={"route":"/"})
 */
class IndexController extends AbstractActionController
{
    public function indexAction()
    {
    }

    /**
     * @Route\Literal("/child1", parent="home", name="child1")
     */
    public function testAction()
    {
    }

    /**
     * @Route\Segment("/child2/:id", parent="home/child1", name="child2", mayTerminate=true, options={"constraints":{"id":"\d+"}})
     */
    public function anotherAction()
    {
    }
}

I know that’s a lot of stuff to figure out but give me a few days and I hope to have some documentation up that explains everything.

Tests: No
Documentation: No
Production ready: No

SpiffyAuthorize

 aims to be a replacement for ACL/RBAC solutions by implementing into them into a single code base. Right now, only RBAC is setup, but I’m open to PR’s from anyone wanting to add ACL implementation.

Tests: Yes
Documentation: Yes
Production ready: No

SpiffyCrud

 is a solution for RAD of CRUD operations. I took some ideas from Django’s admin tool and tried to come up with a system that is easy to use but also offers full customization should the need arise.

Tests: No
Documentation: Some
Production ready: No

SpiffyDatatables

is a thin wrapper around jQuery Datatables and is used as the default renderer in SpiffyCrud.

Tests: No
Documentation: No
Production ready: Yes

SpiffyTinyMce

is a thin wrapper around TinyMCE.

Tests: No
Documentation: No
Production ready: Yes

SpiffyConnect

is a module I wrote to replace HybridAuth because anyone whose worked with HybridAuth knows it’s a gigantic pain in the ass. It features a simple, consistent, API for multiple providers. I was building this for a work project which was canceled so I stopped development but the core features are in and I would love to pick this back up at some point.

Tests: No
Documentation: Some
Production ready: No

SpiffyUser

is YAUM (Yet Another User Module). I was working on a rewrite of ZfcUser but supporting multiple backends is a problem that is not easily solved so I instead chose to focus on Doctrine and PHP 5.4 to take advantage of traits and the power they bring to Doctrine. That said, it is possible to get SpiffyUser working with Zend\Db if you create your own ObjectManager and ObjectRepositories.

SpiffyUser aims to keep a very slim core and provide features through the use of extension modules. The entire API is heavily event driven. All extensions are enabled if installed and disabled if uninstalled. This reduces the need to modify configuration.

If anyone wants to pick up the work I did on ZfcUser all the modules are available on my GitHub. Feel free to fork them and take them over.

Tests: No
Documentation: No
Production ready: No

SpiffyUserRemember

 is an extension for SpiffyUser that provides simple remember me cookie support.

SpiffyUserMetadata

 is an extension to provide additional user metadata. This extension is no longer required due to the architecture of SpiffyUser but I left it listed for brevity.

SpiffyUserAuthorize

 integrates SpiffyUser and SpiffyAuthorize into a unified system.

SpiffyTest

is a simple module that bootstraps the Zend\Mvc\Application and Zend\ServiceManager\ServiceManager and provides custom module.config.php and application.config.php files for use in a testing environment. Most of my modules that have tests use this as.

Show & Tell

Combining SpiffyConfig, SpiffyCrud, and SpiffyDatatables into one system let’s me do the following.


namespace SpiffyPage\Controller;

use SpiffyConfig\Annotation\Controller;
use SpiffyConfig\Annotation\Route;
use SpiffyCrud\Controller\AbstractCrud;

/**
 * @Controller\Invokable
 * @Route\Generic(name="spiffypage.admin", type="crud", options={"route":"/admin/pages"});
 */
class PageAdmin extends AbstractCrud
{
    /**
     * @var string
     */
    protected $modelName = 'SpiffyPage\Crud\Model\Page';

    /**
     * @var string
     */
    protected $route = 'spiffypage.admin';
}

 


namespace SpiffyPage\Crud\Model;

use SpiffyConfig\Annotation\Service;
use SpiffyCrud\Model\AbstractModel;

/**
 * @Service\Invokable(key="spiffy_crud|manager")
 */
class Page extends AbstractModel
{
    /**
     * @var string
     */
    protected $displayName = 'Pages';

    /**
     * @var string
     */
    protected $entityClass = 'SpiffyPage\Entity\Page';
}

2013-08-23_13-32-05

 

In Closing

I hope you enjoy using ZF2 as much as I do! If you have, or are considering writing, a module that is similar in scope to any of the ones I listed above please consider contacting me or submitting PR’s so that we can collaborate. Two heads are better than one! Also, I listed several modules above as not ready for production primarily due to the lack of tests and documentation but every module listed above does function.

6 Responses to “ZF2 Modules Galore!”

  1. Hello,
    About ‘SpiffyConfig’ module, it’s better not to bring annotation to programming logic,
    I recently have read this article about annotations and seems logical which using annotations for routing as symphony does make some serious problems which may cause problems.
    Here is the article: http://r.je/php-annotations-are-an-abomination.html

  2. […] Модули для ZF2 в изобилии! — Автор реализовал и описал целый ряд полезных модулей для Zend Framework 2. […]

  3. SpiffyJr says:

    It’s up to the developer to determine what is or is not appropriate for their project. I enjoy writing modules and annotations is something that ZF2 didn’t have so I explored adding them which turned out to be a fun project.

  4. othella says:

    Is it possible to have a simple demo of how to use SpiffyDatatables ? Your plugin does exactly what I need but I’m going crazy trying to render any table! Thx

  5. […] ZF2 Module in Massen — Author hat jede Menge nützliche Module für ZF2 realisiert und erklärt. […]

  6. SpiffyJr says:

    I’m going to try and work up some documentation for all my modules shortly (in the next week or so).