Location of zend framework models and startup

I began to document myself regarding the Zend Framework, as I will soon start using it in production. Everything worked fine until I started using and working with models :).

The default value for models based on Zend recommendations is application/models/DbTablewhere all models will be selected. This location makes me call the type model Application_Model_DbTable_Actors. For me, this is a very long model name, not easy to use.

The directory structure I want to get looks something like this:

application/
  models/
    actors/
      ActorsMapper.php
      Actor.php
    books/
      BooksMapper.php
      Book.php

and etc.

So, all my models will be in the directory models, but grouped into their own directories.

ActorsMapper Actor ( Zend_Db_Table Zend_Db_Row).

, , , - $actors = new ActorsMapper(), Fatal error: Class not found, .

, models include_path:

  • includePaths.models = APPLICATION_PATH "/models" application.ini

include

  • :

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

, .

Zend_Db_Table, , .

.

p.s. zend - 1.11.1

+3
2

Zend Framework . , Application_Model_Actors_Actor

Application\
 Models\
  Actors\
   Actor.php

, . , , namespacing, ( ) Zend Framework 2, .

0

Zend_Application_Bootstrap_Bootstrap,

$loader = $this- > getResourceLoader();

$loader- > addResourceType ('books', 'models/books', 'Model_Book'); $ Loader- > addResourceType ( '', '/', 'Model_Actor');

​​ .

0

Source: https://habr.com/ru/post/1780223/


All Articles