|
|||
|
Hello everyone,
I have a few questions that I've not been able to find answers for. Perhaps I've overlooked them. I am using the following environment. Ubuntu 7.10 32bit MySQL 5.0 PHP 5.2.x Zend Framework 1.5 I have started a test application, and I have broken down my application directory as follows: Code:
application/
|-- config
| |-- datasources.xml
`-- modules
|-- admin
| |-- config
| |-- controllers
| | |-- IndexController.php
| |-- models
| `-- views
| |-- filters
| |-- helpers
| `-- scripts
| `-- index
| |-- extract.phtml
| |-- index.phtml
`-- default
|-- config
|-- controllers
| |-- IndexController.php
| |-- UserController.php
|-- models
| `-- Persons.php
`-- views
|-- filters
|-- helpers
`-- scripts
`-- index
|-- extract.phtml
|-- index.phtml
Code:
$frontController->addModuleDirectory($this->module_path); For my next question. In my 'library' directory, I have the Zend library directory. I also have my own Library, 'MyLibs'. How can I use Zend_autoload with, 'MyLibs'? ...and finally.... I am currently using the Zend_Registry to store database connection information for a particular application. I have also read about Globals.php and how to use it. I am assuming its better to use the registry as I am currently using it. Why would I use something like Globals.php vs the registry? Did I miss something as to why Globals.php is good or does Zend_Registry really replace it? Any thoughts, insight or suggestions that anyone may have would be greatly appreciated. Thank you. |
|
|||
|
I used this trick to get around the problem:
Tony Ngo Zend Framework (the post "Zend Controller Plugin - Model Include" from Tuesday, March 4th, 2008) Put the code for the Kupo_Controller_Plugin_IncludeModel class in library/kupo/controller/plugin/IncludeModel.php and register it with your front controller in your bootstrapper index.php with $frontController->registerPlugin(new Kupo_Controller_Plugin_IncludeModel()); It automatically adds all dirs named "models" to your include path, so you can get to them from your controllers. Beware, this is my first day using Zend, and I'm pretty new to PHP! But it seems to work. From various forums it sounds like this is something that'll make it into the framework before long. |
|
|||
|
Thanks, I'll give it a try!
I've been able to pretty much get everything else working pretty easily with ZF thus far. I'm sure you'll come to enjoy it. :-) Well, off to tackle my next challenge Zend_Auth and Zend_Acl. :-D |
|
|||
|
One thing that I think would really help newbies like myself is a good overview/tutorial on using modules with Zend from someone who's had a lot of experience with it. Seems like there's a list of standard things like this that you have to consider when using modules, and I see the same questions over and over in forum posts. I've been able to coble together enough to get it working, but I'm sure there are some best practices I'm missing that only come from experience. For now I'll just keep at it...
Eric |
|
|||
|
ecmcn,
Yes, there are a few things, but ZF uses configuration over convention. This gives you a lot of flexibility. As you can see in my original post, I package my modules under the 'application/modules' directory. Others may choose to package their modules differently, thats great, thats how they prefer to deal with it. In my opinion, there should be something akin to addControllerDirectory(). This would provide a consistent way to add module/model directories. Or perhaps addModuleDirectory() could take a configuration array or something else? I've really come to like the flexibility to change my directory layout to suite my needs. I could never remember the layout of a Rails directory. ;-) (Though I do think Rails is slick), this way I don't have to remember the layout, just some basic rules. |
|
|||
|
I prefer to just add the models directory by adding it to the include_path. This is the line of code in my bootstrap file:
PHP Code:
|
|
|||
|
Quote:
From the API-docs: addControllerDirectory Add a single path to the controller directory stack /friedhelm |
|
|||
|
Quote:
include_path is a php thing, not a zend framework thing. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|