如何创建库

I have some code which I want to organize into a class or library for other developers to use more easily on their website.

The way I use the class now is to instantiate an instance of it and start calling the functions I need as I need them.

$class_object = new MyClass();
$class_object->myFunction();

Is this basically all I need to make a library, or do I need to make further changes to turn this into a library?

It depends on what exactly your library is. A class is a good solution if you are describing an object which can have properties and methods, and all the actions are related to that object.

If you only have a collection of functions and you can assume users will have PHP 5.3+, then you might just define them under a namespace.

It depends a lot on the functionality that you're providing. If the library is just a group of functions, then it might be best to have them static:

class MyLib 
{
    public static function convertData( $data )
    {
        // Do something
    }
}

But if it depends on the object being instantiated and stored information within that object, then I'd leave it as-is. It all depends on how you use it.

PHP doesn't have any concept of a library other than what you're already doing. If you want to abstract it (make sure it works outside of your application) and move it into a separate file/directory, you can, but that doesn't qualify it as a library any more than usual!

I will note though, there are some frameworks that use the term library as something specific, but you'll have to look into the individual framework's documentation for that, I'm afraid.

As far as I know, yes. But you do need to make your library compatible with the accepted autoloading standards. That way developers can simply drop it into their system and start using it.

http://groups.google.com/group/php-standards/web/psr-0-final-proposal?pli=1