Depends on the purpose of your library
Case 1, used by many modules:
Place it in your vendor folder, make sure to be PSR-0 compliant, that makes autoloading easy.
Case 2, used by only one module:
Place it in under modules/your_module/src and edit the Module.phps getAutoloaderConfig() method to have it autoloaded.
....
class Module {
....
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php', // classmap for production usage
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, // your module's files autoloading (development usage and fallback)
'library_namespace' => __DIR__ . '/src/librarys_namespace/potential_subfolder', // your library files autoloading (development usage and fallback). eg: 'acme' => '/src/acme/library' for acme namespace
),
),
);
}
....
Case 3, your library is 3rd party module:
Place it within the vendor folder, for references look at ZfcUser
I think your use-case would most like be case 1, your library modifies behaviour of e.g. the Zend\Mvc\Controller\AbstractActionController or additional plugins.
But if a plugin is only used by one module you'll be better of placing it parallel to your Modules code as described in Case 2.