Search code examples
phpzend-frameworkzend-framework-mvc

Problem related to Creation of folder inside the application folder and access its classes in Zend-Framework?


I have following structure in my Zend-Project :

-application
      -   PDF
      -   configs
      -   controllers
      -   models
      -   views
      -   Bootstrap.php
-library
-public
-tests

I have created a new folder PDF inside application folder. And I have write some classes inside it[PDF].

What I want is to access this classes inside the indexAction() of the IndexController, but it showing an error like :

"Class 'Application_PDF_FormDocument' not found in D:\xampp\htdocs\zendapp\application\controllers\IndexController.php on line 13"

What may be the possible reason?

Please provide some help.....

Thanks In Advance......


Solution

  • I agree with ChanibaL regarding the naming of your classes. you should be naming it PDF_FormDocumnet. Next, in application.ini, regerster the namespace:

    autoloaderNamespaces[] = "PDF_"
    

    Lastly, in your index.php make sure you are adding it to the include path:

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

    That should do the trick