How to prune Zend Framework? - zend-framework

I wouldn't use most of the classes from Zend Framework, that's why I'm looking for the thinnest possible ZF configuration.
Is there a better way of finding what I really need other than deleting the whole library/Zend folder, then putting back files based on the error messages that I receive?

I have not used it myself, but http://blog.fedecarg.com/2009/02/01/zend-framework-automatic-dependency-tracking/ may be what you are looking for.

Hm...
There is a lot of information about Zend Framework on SO and with a little bit of reading you would have found the answers to your question
You would also find the answers to your question by just reading the introduction to Zend Framework on the Zend Framework website.
No, that's not how you'll do it. Zend Framework, unlike most/all other PHP frameworks, is rigidly loosely coupled. You can use every component stand-alone. You can only use the loader, or only Zend_Translate. Or you can just use the MVC modules, or Zend_Db, etc.
Of course if you use Zend_Form and want to validate or filter the input, you'll need Zend_Validate and Zend_Filter. But you'll know that because you'll instantiate objects. So just copy into your empty library folder the modules you need. Or even better, copy everything in! A) you won't regret it. B) disk space is not your problem.

What I would do is set up the plugin loader cache and then purge all files apart from the ones called within the automatically generated include file.
zend.loader.pluginloader.performance
I hope it makes sense... :o)

Related

How to use Zend Framework Begining of time

first ive already installed zend framework skeleton application with command from and composer.pharphp composer.phar require zend..... and i type composer suggests and then install all the suggested application on my computer.
composer require zend...
know i have many file and folder about zend framework, but i cant use it.
can anybody tell me about how to use or implement zend framework.
in the code i understand a litle but its blanks on the Controller and Bootstraps.
for know i want to know about to use zend framework, thanks.
Trying to teach you how to use ZF in a single answer would cost a lot, because of the complexity of the framework. Since that, I strongly recommend you to read the tutorial that Zend guys prepared for us to learn the use of the framework.
If you are using ZF1: Tutorial
If you are using ZF2: Tutorial
I really think it's a good starting point and, if in the future you have more specific questions, you can (obviously) ask them here.
I hope this helps and welcome you to Zend Framework ;).

Zend Framework and fuelphp

I wanted to know if it was possible to use zend framework libraries from zend 1.11 in fuelphp? fuel looks nice and I started looking at it as I believe its the next logical step for any CI developer.
Is there any site or a howto for using zend library with fuel?
Thanks
It really depends on what portions of Zend Framework you want to use. Some parts, e.g. Zend_View are tied into the MVC-part of the framework, but components like Zend_Pdf or Zend_Service_* have only few dependencies and should work fine in other frameworks as well.
What you should do is check out the Reference Manual to see what other components are required by the component you are trying to use. And then put them in a library folder. Alternatively, just put the whole Zend Framework in a folder if you don't mind carrying the dead weight with you.
I've been using ZF-components standalone and found that it's useful to add it to include_path as you would when using ZF as MVC-framework, because some ZF-classes are instantiated dynamically, i.e. not via require_once and that won't work without the folder containing Zend/ being in the include_path.
Finally you have to add the folder to your autoloader, this should be as easy as:
Autoloader::add_namespace('Zend', __DIR__.'/path/to/Zend/library');

Zend Framework contextually load stylesheets

Is it possible in Zend Framework to contextually autoload a stylesheet based on a unique identifier?
I'd like to load css based on the layout and the action name by first checking if the stylesheet exists then loading it.
Is that possible?
Yes it is possible and surprisingly simple to implement. I have just started trying this for myself in a small project I am working on.
See Andy Baird's blog on this, which also includes the code you need to get you started. He continues it in a second blog which takes the concept slightly further.
He uses the same technique for both CSS and javascript files, so you may want to try it with both too.

How can I keep just the required files in zend framework for my application?

I'm not sure where to ask this, but frankly I'm using some libraries from the zend framework but at this moment have the entire framework in my library folder. Is there any script or exe out there which go through the application and tell which files are not being used and which are. Theres loads of includes and easy loading going on there.
The files that are included via require_once in the Zend Framework code are mostly required only if they are used.
But if you want to be 100% sure that only the really used ones are loaded (on the fly), use the autoloader in combination with a script that strips all the require_once, as shown in the "Class Loading" part the official performance guide. There is a "How can I eliminate unnecessary require_once statements?" section. And this is a well know ZF optimisation technique, so it should be done anyway.

How to name files using gettext translations with Zend Framework

I'm using gettext translation adapter in a Zend Framework projekt. But I'm wondering what's the best practise when naming and placing these translation files within my project?
At first I had APPLICATION_PATH/languages/sv_SE.po (and sv_SE.mo)
But then I read about the auto searching features of Zend Framework and started wondering if it would be better to have the languages in subfolders. But the structure APPLICATION_PATH/languages/sv_SE/sv_SE.po and APPLICATION_PATH/languages/en_US/en_US.po didn't feel quite natural. Using array adapters ect it have felt easier to come up with a good naming conventions... But what is the best practise when it comes to using gettext translations in Zend Framework? Is it most common to have all translations in a single file or should one use something like
APPLICATION_PATH/languages/en_US/admin.po
APPLICATION_PATH/languages/en_US/forms.po
APPLICATION_PATH/languages/en_US/othercrap.po
Feels like this apporach might make it tedious when scaning source for strings to translate since one would have to open several files etc.
I ended up using
APPLICATION_PATH/languages/en_US/admin.po
APPLICATION_PATH/languages/en_US/forms.po
APPLICATION_PATH/languages/en_US/othercrap.po
which has worked fine.