A
A
Alexander Ivanov2017-02-22 22:20:40
Phalcon
Alexander Ivanov, 2017-02-22 22:20:40

Why isn't volt working?

Exception: Service 'voltService' wasn't found in the dependency injection container - such a line comes out
like this, I connected it in index.php:

//    $view->registerEngines(
//      [
//        ".volt" => "voltService",
//      ]
//    );

I don’t have volt installed in the phalcon version, or have I not added something else somewhere?
instructional video
use Phalcon\Loader;
use Phalcon\Tag;
use Phalcon\Mvc\Url;
use Phalcon\Mvc\View;
use Phalcon\Mvc\Application;
use Phalcon\DI\FactoryDefault;
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;
use Phalcon\Mvc\View\Engine\Volt;

....

  // Register Volt as a service
  $di->set(
    "voltService",
    function ($view, $di) {
      $volt = new Volt($view, $di);

      $volt->setOptions(
        [
          "compiledPath"      => "../app/compiled-templates/",
          "compiledExtension" => ".compiled",
        ]
      );

      return $volt;
    }
  );

  // Setting up the view component
  $di['view'] = function() {
    $view = new View();
    $view->setViewsDir('../app/views/');
    $view->registerEngines(
      [
        ".volt" => "voltService",
      ]
    );
    return $view;
  };

If I connect Register Volt as a service, then the following message:
Exception: Volt directory can't be written

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ivanov, 2017-02-22
@cimonlebedev

$volt->setOptions(
        [
          "compiledPath"      => "../app/cache/",
          "compiledExtension" => ".compiled",
        ]
      );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question