i have studied design patterns and want to use them to code an open source library (not an application).
but i have never coded a library before and don’t know where should i include files, should i have a bootstrap file that loads everything or should every class load their own classes they are dependent on etc.
are there any tutorials for writing libraries in php from start to finnish?
thanks
I can’t point you to a tutorial, but the easiest way to have a plug and play library is to have one class per class file, so that the user has the option to use __autoload and simply instantiate your classes without having to change anything in their existing code. This way is most accessible to most developers.
This method still allows you to create one ‘standalone’ include file that includes all your other class files.
Other options include making it into a PEAR package or asking people to place your files in the include path. However this is not optimal in my opinion for people who don’t have access to anything other than their own public_html folder (on shared hosting, for example).