Robert Basic's blog

Archives for July, 2010

Loading custom module plugins

by Robert Basic on July 20, 2010.
Heads-up! You're reading an old post and the information in it is quite probably outdated.

OK, here’s a quicky one from the office :P

I was trying to load a Front Controller plugin which resides in app/modules/my_module/controllers/plugins/ and not in the “usual” lib/My_App/Plugin/. I want this plugin to be called in every request and I want the plugin file to be under it’s “parent” module.

Here’s what I did: added the path to the plugin and it’s namespace to the Zend_Application_Module_Autoloader as a new resource type and then just register the plugin in the front controller in an other _init method.

Code is better, here’s some:

<?php
class News_Bootstrap extends Zend_Application_Module_Bootstrap
{
    /**
     * Autoloader for the "news" module
     *
     * @return Zend_Application_Module_Autoloader
     */
    public function _initNewsAutoload()
    {
        $moduleLoader = new Zend_Application_Module_Autoloader(
                                array(
                                    'namespace' => 'News',
                                    'basePath' => APPLICATION_PATH . '/modules/news'
                                )
                            );

        // adding model resources to the autoloader
        $moduleLoader->addResourceTypes(
                array(
                    'plugins' => array(
                        'path' => 'controllers/plugins',
                        'namespace' => 'Controller_Plugin'
                    )
                )
            );

        return $moduleLoader;
    }

    public function _initPlugins()
    {
        $this->bootstrap('frontcontroller');
        $fc = $this->getResource('frontcontroller');

        $fc->registerPlugin(new News_Controller_Plugin_Scheduler());
    }
}

If anyone knows a better way for doing this, please do share it with me.

Now back to work. Cheerio.

Tags: framework, loading, php, plugin, zend, zf.
Categories: Development, Programming.

Moved

by Robert Basic on July 11, 2010.
Heads-up! You're reading an old post and the information in it is quite probably outdated.

As I said 2 weeks earlier, I decided to move my stuff over to linode. Well, I did it. Kinda.

First step was to change the nameservers of the domain. I thought it’s gonna take a while, so I took my time with moving the files and the database, but (at least on my end) the dns changes were alive and kickin’ under an hour.

My original idea was to run everything on nginx, but that soon turned out to be a bad idea cause there was no way I could setup properly the rewriting - if PHP was working right, CSS was broken. If CSS was working right, PHP was broken. At one point I broke everything. Hooray for me. Then I just took down nginx and all that php-fastcgi stuff and installed apache. Everything is lovely once again, the world is all shiny and pink and full of rainbows and unicorns. But fear not, I will not let nginx beat me in this mad game of rewrites! Just have to do that somewhere else, not on a live server.

Now to setup the emails and my job here is done. Oh, and the sidebar is a tad broken. Sorry bout that.

Carry on now, nothing left to see here.

Tags: about, me, moving.
Categories: Blablabla.