if your classes in app/library are namespaced, you should register them: https://docs.phalcon.io/en/latest/reference/loader.html#registering-namespaces
but maybe the loader just can't find the ap/library directory. Bellow a classic MVC app structure:
app/
config/
config.php
service.php
loader.php
controllers/
models/
.....
then:
// in config.php:
return new \Phalcon\Config(array(
....
'application' => array(
'controllersDir' => __DIR__ . '/../../app/controllers/',
'modelsDir' => __DIR__ . '/../../app/models/',
'viewsDir' => __DIR__ . '/../../app/views/',
'pluginsDir' => __DIR__ . '/../../app/plugins/',
'libraryDir' => __DIR__ . '/../../app/library/',
'cacheDir' => __DIR__ . '/../../app/cache/',
'baseUri' => '/',
),
.....
// in loader.php:
$loader = new \Phalcon\Loader();
/**
* We're a registering a set of directories taken from the configuration file
*/
$loader->registerDirs(
array(
$config->application->controllersDir,
$config->application->modelsDir,
$config->application->pluginsDir,
$config->application->libraryDir
)
)->register();