Jump to content

zend tool


dgoosens

Recommended Posts

hi all,

 

I have been using zend tools within netbeans for quite a while now and this always worked like a charm...

 

However, I am in the middle of a new development where I wanted to use a slightly different file structure, and it seems that I am no longer able to create any controllers or actions in the default module (other modules work fine).

 

The file structure I decided to use is like this:

/appplication
   /data
      /session
      /cache
   /modules
      /default
         /config
         /controllers
         /models
         /views
      /admin
         /config
         /controllers
         /models
         /views
      [...]
/library
   /App
   /Zend
/public

 

In my opinion, this is a much cleaner file structure... but that is not the point.

 

I did change my default config.ini file accordingly:

bootstrap.path = APPLICATION_PATH "/modules/default/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/modules/default/controllers"

resources.layout.layout = "layout"
resources.layout.layoutPath = APPLICATION_PATH "/modules/default/views/layouts"

resources.view.encoding = 'utf-8'
resources.view.basePath = APPLICATION_PATH "/modules/default/views"
resources.view[] =

resources.frontController.moduleDirectory = APPLICATION_PATH "/modules/"
resources.modules[] =

resources.frontController.defaultController = "index"
resources.frontController.defaultAction = "index"
resources.frontController.defaultModule = "default"
resources.frontController.prefixDefaultModule = false
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"

 

and the application works fine like this... in the browser

 

But, when trying to run a zend tool command to create a new controller or action in the default module I get the following errors:

zf.sh create controller test 1 default


Fatal error: Call to a member function search() on a non-object in /home/dgoosens/DEV/LIB/ZendFramework-1.10.8/library/Zend/Tool/Project/Provider/Controller.php on line 82

Call Stack:
    0.0011     814336   1. {main}() /home/dgoosens/DEV/LIB/ZendFramework-1.10.8/bin/zf.php:0
    0.0012     814336   2. ZF::main() /home/dgoosens/DEV/LIB/ZendFramework-1.10.8/bin/zf.php:632
    0.0053    1314392   3. ZF->run() /home/dgoosens/DEV/LIB/ZendFramework-1.10.8/bin/zf.php:74
    0.0053    1314392   4. ZF->_runTool() /home/dgoosens/DEV/LIB/ZendFramework-1.10.8/bin/zf.php:117
    0.0064    1453760   5. Zend_Tool_Framework_Client_Abstract->dispatch() /home/dgoosens/DEV/LIB/ZendFramework-1.10.8/bin/zf.php:608
    0.1268    8921832   6. Zend_Tool_Framework_Client_Abstract->_handleDispatch() /home/dgoosens/DEV/LIB/ZendFramework-1.10.8/library/Zend/Tool/Framework/Client/Abstract.php:241
    0.1269    8923048   7. Zend_Tool_Framework_Client_Abstract->_handleDispatchExecution() /home/dgoosens/DEV/LIB/ZendFramework-1.10.8/library/Zend/Tool/Framework/Client/Abstract.php:318
    0.1269    8923680   8. call_user_func_array() /home/dgoosens/DEV/LIB/ZendFramework-1.10.8/library/Zend/Tool/Framework/Client/Abstract.php:324
    0.1269    8924424   9. Zend_Tool_Project_Provider_Controller->create() /home/dgoosens/DEV/LIB/ZendFramework-1.10.8/library/Zend/Tool/Framework/Client/Abstract.php:0
    0.1667    9451320  10. Zend_Tool_Project_Provider_Controller::hasResource() /home/dgoosens/DEV/LIB/ZendFramework-1.10.8/library/Zend/Tool/Project/Provider/Controller.php:119

 

If I run the command without specifying "default" as a module, zend tool creates a new file structure below /application/

 

The same command on the admin module, runs fine...

So, my guess is zend tool does not read the config.ini settings file correctly, OR that it skips all the default settings...

 

Any of you have encountered this kind of issues ?

If so, did you figure out a way to bypass this ?

 

(I could obviously create the files manually... but having zend tool doing the work for me is so nice)

Link to comment
Share on other sites

thanks a lot ignace,

 

you would not know where this particular setting is located in the zend tool files would you ?

 

I suppose that it should be fairly easy to overrule the settings for the default module so that it works just like it does for all the other modules...

Link to comment
Share on other sites

Open the zf.bat with a text editor.

 

lol

that would be zf.sh in my case (no bloody Windows here)

 

but, that will not help, obviously... as this only is a wrapper for zf.php that uses all the classes in Zend_Tool

That's where I need to figure out where the module default settings are defined...

 

 

Link to comment
Share on other sites

ok...

so I figured it out...

 

this has nothing to do with the Zend_Tool scripts but with the .zfproject.xml that was generated for the project.

This XML file contains the project layout... which, obviously uses the default Zend Application layout.

 

All I had to do there was create a new <moduleDirectory> node under <modulesDirectory> with a moduleName="default" attribute

Then, cut/paste all the controller, model and view nodes in there... and that did the trick

 

Just in case, here is a simplified version of the XML file:

<?xml version="1.0"?>
<projectProfile type="default" version="1.10">
  <projectDirectory>
    <projectProfileFile filesystemName=".zfproject.xml"/>
    <applicationDirectory classNamePrefix="Application_">
      <modulesDirectory enabled="false">
        <moduleDirectory moduleName="default">
          <apisDirectory enabled="false"/>
          <configsDirectory>
            <applicationConfigFile type="ini"/>
          </configsDirectory>
          <controllersDirectory>
            <controllerFile controllerName="Index">
              <actionMethod actionName="index"/>
            </controllerFile>
            <controllerFile controllerName="Error"/>
            <controllerFile controllerName="Test">
              <actionMethod actionName="index"/>
            </controllerFile>
		[...]
          </controllersDirectory>
          <formsDirectory enabled="false"/>
          <layoutsDirectory enabled="false"/>
          <modelsDirectory>
            [...]
          </modelsDirectory>
          <viewsDirectory>
            <viewScriptsDirectory>
              <viewControllerScriptsDirectory forControllerName="Index">
                <viewScriptFile forActionName="index"/>
              </viewControllerScriptsDirectory>
              <viewControllerScriptsDirectory forControllerName="Error">
                <viewScriptFile forActionName="error"/>
              </viewControllerScriptsDirectory>
              <viewControllerScriptsDirectory forControllerName="Test">
                <viewScriptFile forActionName="index"/>
              </viewControllerScriptsDirectory>
   			  [...]
            </viewScriptsDirectory>
            <viewHelpersDirectory/>
            <viewFiltersDirectory enabled="false"/>
          </viewsDirectory>
          <bootstrapFile filesystemName="Bootstrap.php"/>
        </moduleDirectory>
        <moduleDirectory moduleName="admin">
          <apisDirectory enabled="false"/>
          <configsDirectory enabled="false"/>
          <controllersDirectory>
            <controllerFile controllerName="Index">
              <actionMethod actionName="index"/>
              [...]
            </controllerFile>
          </controllersDirectory>
          <formsDirectory enabled="false"/>
          <layoutsDirectory enabled="false"/>
          <modelsDirectory>
		  [...]
          </modelsDirectory>
          <viewsDirectory>
            <viewScriptsDirectory>
              <viewControllerScriptsDirectory forControllerName="Index">
                <viewScriptFile forActionName="index"/>
              </viewControllerScriptsDirectory>
			[...]
              </viewControllerScriptsDirectory>
            </viewScriptsDirectory>
            <viewHelpersDirectory/>
            <viewFiltersDirectory/>
          </viewsDirectory>
        </moduleDirectory>
        [...]
    </applicationDirectory>
    <dataDirectory enabled="false">
      [...]
    </dataDirectory>
    <docsDirectory>
	[...]
    </docsDirectory>
    <libraryDirectory>
      [...]
    </libraryDirectory>
    <publicDirectory>
      [...]
    </publicDirectory>
    <projectProvidersDirectory enabled="false"/>
    <temporaryDirectory enabled="false"/>
    <testsDirectory>
      [...]
    </testsDirectory>
  </projectDirectory>
</projectProfile>

Link to comment
Share on other sites

just noticed that with the XML configuration, it was not possible anymore to create new modules...

it should be like this:

 

<?xml version="1.0"?>
<projectProfile type="default" version="1.10">
  <projectDirectory>
    <projectProfileFile filesystemName=".zfproject.xml"/>
    <applicationDirectory classNamePrefix="Application_">
 <apisDirectory enabled="false"/>
      <configsDirectory>
        <applicationConfigFile type="ini"/>
      </configsDirectory>
      <controllersDirectory>
      </controllersDirectory>
      <formsDirectory enabled="false"/>
      <layoutsDirectory enabled="false"/>
      <modelsDirectory>
      </modelsDirectory>
      <modulesDirectory enabled="false">
        <moduleDirectory moduleName="default">
          <apisDirectory enabled="false"/>
          <configsDirectory>
            <applicationConfigFile type="ini"/>
          </configsDirectory>
          <controllersDirectory>
            <controllerFile controllerName="Index">
              <actionMethod actionName="index"/>
            </controllerFile>
            <controllerFile controllerName="Error"/>
            <controllerFile controllerName="Test">
              <actionMethod actionName="index"/>
            </controllerFile>
         [...]
          </controllersDirectory>
          <formsDirectory enabled="false"/>
          <layoutsDirectory enabled="false"/>
          <modelsDirectory>
            [...]
          </modelsDirectory>
          <viewsDirectory>
            <viewScriptsDirectory>
              <viewControllerScriptsDirectory forControllerName="Index">
                <viewScriptFile forActionName="index"/>
              </viewControllerScriptsDirectory>
              <viewControllerScriptsDirectory forControllerName="Error">
                <viewScriptFile forActionName="error"/>
              </viewControllerScriptsDirectory>
              <viewControllerScriptsDirectory forControllerName="Test">
                <viewScriptFile forActionName="index"/>
              </viewControllerScriptsDirectory>
              [...]
            </viewScriptsDirectory>
            <viewHelpersDirectory/>
            <viewFiltersDirectory enabled="false"/>
          </viewsDirectory>
          <bootstrapFile filesystemName="Bootstrap.php"/>
        </moduleDirectory>
        <moduleDirectory moduleName="admin">
          <apisDirectory enabled="false"/>
          <configsDirectory enabled="false"/>
          <controllersDirectory>
            <controllerFile controllerName="Index">
              <actionMethod actionName="index"/>
              [...]
            </controllerFile>
          </controllersDirectory>
          <formsDirectory enabled="false"/>
          <layoutsDirectory enabled="false"/>
          <modelsDirectory>
           [...]
          </modelsDirectory>
          <viewsDirectory>
            <viewScriptsDirectory>
              <viewControllerScriptsDirectory forControllerName="Index">
                <viewScriptFile forActionName="index"/>
              </viewControllerScriptsDirectory>
            [...]
              </viewControllerScriptsDirectory>
            </viewScriptsDirectory>
            <viewHelpersDirectory/>
            <viewFiltersDirectory/>
          </viewsDirectory>
        </moduleDirectory>
        [...]
  </modulesDirectory>
      <viewsDirectory>
      </viewsDirectory>
    </applicationDirectory>
    <dataDirectory enabled="false">
      [...]
    </dataDirectory>
    <docsDirectory>
      [...]
    </docsDirectory>
    <libraryDirectory>
      [...]
    </libraryDirectory>
    <publicDirectory>
      [...]
    </publicDirectory>
    <projectProvidersDirectory enabled="false"/>
    <temporaryDirectory enabled="false"/>
    <testsDirectory>
      [...]
    </testsDirectory>
  </projectDirectory>
</projectProfile>

 

One has to leave the default nodes in place...

Link to comment
Share on other sites

  • 1 year later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.