Use external library in Zend Framework 2:

Step 1 : Go inside the library directory and run the below command:
php /var/www/zf2_test/vendor/bin/classmap_generator.php .
It will generate an autoload_classmap.php in your library folder.

Step 2 : Update the function getAutoloader in any of Module.php:

public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
        PATH_FOR_YOUR_autoload_classmap.php,
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
  __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
)
)
);
}

Step 3 : Now use all the classes of your library using "\" sign before your class name:

$objectName = \ClassName();