5

Zend framework is well known for loosely coupled components.

I would like to use XML-RPC from zend framework, is there any dependency for XML-RPC? Like if I had taken out XML-RPC folder off Zend Framework Library and try to instantiate RPC object, would it throw error?

Where can I find the proper way of separating component from the framework?

Thanks

Hossain Khan
  • 6,332
  • 7
  • 41
  • 55
  • Thanks everyone for putting all your thoughts and recommendation. @Jani Hartikainen has done tremendous job building that module to accomplish this task, but @KingCrunch also pointed an important thing. It's just the space that is wasted but doesn't give any extra load on the server and easier to maintain future versions for upgrading. ciao!! – Hossain Khan Dec 01 '10 at 02:41

4 Answers4

8

I wrote a tool which takes ZF components and their dependencies so you can easily take just one (or several) component from ZF.

http://epic.codeutopia.net/pack/

It doesn't have the latest ZF release 1.11 (because I'm lazy), but 1.10.6 should work just fine.

Jani Hartikainen
  • 42,745
  • 10
  • 68
  • 86
  • Great job!!! I was looking something like this. Perfecto!! Just wondering, how did you find all the dependency? going through recursive require/include files? – Hossain Khan Dec 01 '10 at 02:28
  • It goes through the files and searches for require's to other files and generates some data files based on this. It's on Github https://github.com/jhartikainen/packageizer but be warned that the code isn't very polished since I originally just wrote it as an experiment :) – Jani Hartikainen Dec 01 '10 at 22:42
2

You should never split single components off a framework or library independent from Zend Framework, or any other. Especially when using PHP there is also no performance reason, because with PHPs autoloading functionality it will always just include the files, which are requested.

KingCrunch
  • 128,817
  • 21
  • 151
  • 173
  • @King Crunch so are you ssuggesting OP should use the whole of Zend Framework just to use the XmlRpc classes? – martynthewolf Nov 30 '10 at 14:59
  • 2
    No, he should not _use_ it. But will you unpack a JAR archive, just to get rid of some classes? The most obvious reason is that it is much harder to update. You need to extract "your" class files every new release and then you can not be sure, if there arent new dependencies. Removing unused classes just saves some (cheap) hdd-space, not more, but its very easy to break your application. – KingCrunch Nov 30 '10 at 15:09
  • You don't need to have a Zend Framework application to use Zend_Xml_Rpc. But As KC stated, there's no point in ripping out individual components. I use Zend_Cache and Zend_Log as standalone items all the time, but I don't go copying the individual files to my own projects for kicks. – Darryl E. Clarke Nov 30 '10 at 15:35
  • Ok, I was asking this because, I found on multiple sources that ZF has loosely coupled components/modules which can be used without using the whole framework stack. So, I was wondering if there is any well known way of using something like this. Keeping 90% of the code weighing 20MB+ just for single component didn't seem to be good idea. Anyway, I'll keep 'em as is to use any module. – Hossain Khan Dec 01 '10 at 02:23
  • You _can_ use single components, without _using_ the whole framework, but its a bad idea to break it. In PHP files, that are not used, are not included. 20MB is nothing ;) – KingCrunch Dec 01 '10 at 08:04
  • 1
    20MB is not nothing. It's PITA to copy 2000+ files over FTP ;) And ZF is designed that way. you need only the files you need. Even the reuqire_once calls are included ;) – Tomáš Fejfar Dec 01 '10 at 12:32
1

You should literally be able to copy the XmlRpc folder from your copy of Zend Framework and use it in your own projects. The only dependency that I can see is in XmlRpc/Exception.php as it requires a file in the root directory of Zend/ (Exception.php) you could simply copy this file along with the XmlRpc folder keeping the directory structure the same and it should work....

martynthewolf
  • 1,718
  • 2
  • 11
  • 22
  • Thanks, but if I wanted to use other modules, I probably had to check required files. That's why I was wondering if there were any proper documentation for using specific module independently. But it turns out that it is not recommended or better not to do it. – Hossain Khan Dec 01 '10 at 02:34
0

My first question is why you would want to do that in the first place. It means that every time you upgrade Zend Framework you now need add a bunch of tooling to manage the removal of some components. One of the purposes of using a framework is so you don't have to manage a bunch of code. Removing parts of a framework is a step backwards IMHO. Disk space is cheap. Network transfer is cheap. If you are going to remove parts of a framework you should have a REALLY, REALLY good reason to do it.

Kevin Schroeder
  • 1,296
  • 11
  • 23