views:

146

answers:

2

Hello. I wish to use the Translator classes of Zend framework in my app, but I don't want to include the whole framework. I grabbed the:

  • Locale folder
  • Translate folder
  • Exception.php
  • Loader.php
  • Locale.php
  • Registry.php
  • Translate.php

and copied into a custom folder named zend.translator. Obviously I had to edit all them to adjust the includes to the new path... Is this the way to go? I'm worried to have to edit all those files every time a new version is released.

+2  A: 

You could use the Zend_Loader_Autoloader to include only the classes from Zend Framework that you actually use. So you wouldn't have to check all the dependencies yourself. Just put the complete Framework on your include_path and the Autoloader will take care of it.

That way, you don't have to edit all the files. And autoloading can also give you a significant performance boost.

Techpriester
+1  A: 

No. That's definitely not the way to go.

First of all, grab the whole framework. It does not add any overhead to your application besides occupying some more diskspace. Should you find out later you want to use some more components, you have everything in place already. ZF will not instantiate anything you don't use, so it won't impact performance to have the whole thing.

Second, don't change the files. ZF uses a naming convention you can easily use with autoloading. You can either use the Zend_Autoloader or roll your own. Basically, you just have to replace underscores in a filename with slashes and add '.php'.

Gordon