Sorry, I missed modules
You can add assets in service I did something like that at module when registered it
<?php
namespace Evc\Backend;
use Phalcon\Mvc\ModuleDefinitionInterface;
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;
use Phalcon\Logger;
use Phalcon\Logger\Adapter\File as FileLogger;
use Phalcon\Events\Manager as EventsManager;
class Module implements ModuleDefinitionInterface
{
public function registerAutoloaders( \Phalcon\DiInterface $dependencyInjector = null )
{
$loader = new \Phalcon\Loader();
$loader->registerNamespaces(array(
'Evc\Backend\Controllers' => realpath(__DIR__ . '/controllers/')
));
$loader->register();
}
public function registerServices( \Phalcon\DiInterface $di )
{
$config = include __DIR__."/../../shared/config/".ENVIRONMENT.".config.php";
$dispatcher = $di->get('dispatcher');
$eventManager = $di->getShared('eventsManager');
//$eventManager->attach('dispatch:beforeExecuteRoute', new Gate());
$dispatcher->setEventsManager($eventManager);
$dispatcher->setDefaultNamespace("Evc\\Backend\\Controllers\\");
$di->get('view')->setViewsDir(realpath(__DIR__ . '/views/'));
$di->set('assets', function() use ($config) {
$assets = new \Phalcon\Assets\Manager();
$assets
->collection('footerJS')
->addJs('//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js', false)
->addJs('//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js', false)
->addJs('p/resources/backend/plugins/fastclick/fastclick.min.js', true)
->addJs('p/resources/backend/dist/js/app.min.js', true)
->addJs('p/resources/backend/plugins/slimScroll/jquery.slimscroll.min.js', true)
;
$assets
->collection('headerCss')
->addCss('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css', false, false)
->addCss('https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css', false, false)
->addCss('https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css', false, false)
->addCss('p/resources/backend/dist/css/AdminLTE.css', true)
->addCss('p/resources/backend/dist/css/skins/skin-blue.min.css', true)
//TODO use minified tools
// ->addCss($config->application->backendAssets.'/plugins/jvectormap/jquery-jvectormap-1.2.2.css', true)
// ->setTargetPath($config->application->documentRoot.'/assets/css/css.minified.backend.css')
// ->setTargetUri('/assets/css/css.minified.backend.css')
// ->join(true)
// ->addFilter(new \Phalcon\Assets\Filters\Cssmin())
;
return $assets;
});
}
}
as you can see you can easily add it to sevices and use it in volt