0
votes

I'm trying to create a wordpress plugin using zend framework 2 ( I'm new to zf ).
I've googled it a lot but I couldn't figure how to get it right with controllers and views.

I have the following directory structure:

  1. zend-plugin

  2. plugin.php

  3. library

    • Zend
  4. config
    • application.config.php
  5. data
    • cache
  6. module
    • CMP
      • config
      • language
      • src
        • CMP
          • controller
      • view
        • CMP
          • index
        • error
        • layout
  7. public

plugin.php looks like this:

set_include_path(
    implode(PATH_SEPARATOR, array(
            get_include_path(),
            CMP__PATH,
            CMP__PATH . '/library',
        )));

    $zf2Path = false;

if (is_dir(CMP___LIB_PATH)) {
    $zf2Path = CMP___LIB_PATH;
} elseif (getenv('ZF2_PATH')) {      // Support for ZF2_PATH environment variable or git submodule
    $zf2Path = getenv('ZF2_PATH');
} elseif (get_cfg_var('zf2_path')) { // Support for zf2_path directive value
    $zf2Path = get_cfg_var('zf2_path');
}

if ($zf2Path) {
    if (isset($loader)) {
        $loader->add('Zend', $zf2Path);
    } else {
        include $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
        Zend\Loader\AutoloaderFactory::factory(array(
                'Zend\Loader\StandardAutoloader' => array(
                    'autoregister_zf' => true
                )
            ));
    }
} 
Zend\Mvc\Application::init(require 'config/application.config.php')->run();

I don't know how to do next to add menu pages or display plugin's dashboard page. It trows this error : 'Module(CMP) could not be initialized'.

Any help, please??
Thanks!

Updated!
Here you can find a solution to this problem. For further information, please let me know.

1

1 Answers

0
votes

I did exactly you need, I wrote a wordpress plugin allow you do that.

If you still interested on this please consider visit my webpage about this, I would be glad to share with you

In my web page there are many examples.

I answered your another question on stackoverflow.

your another question on stackoverflow

my web page about this subject