Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8770781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:37:34+00:00 2026-06-13T17:37:34+00:00

$di = new \Phalcon\DI\FactoryDefault(); /** * The URL component is used to generate all

  • 0
$di = new \Phalcon\DI\FactoryDefault();

/**
 * The URL component is used to generate all kind of urls in the application
 */
$di->set('url', function() use ($config) {
    $url = new \Phalcon\Mvc\Url();
    $url->setBaseUri($config->application->baseUri);
    return $url;
});

$di->set('voltService', function()  {
    $volt = new Phalcon\Mvc\View\Engine\Volt($view, $di);
    $volt->setOptions(array(
        "compiledPath" => "../app/compiled/",
        "compiledExtension" => ".php"
    ));
    return $volt;
});

/**
 * Setting up the view component
 */
$di->set('view', function() use ($config) {
    $view = new \Phalcon\Mvc\View();
    $view->setViewsDir($config->application->viewsDir);
    $view->registerEngines(array(".phtml" => 'voltService'));
    return $view;
});

I use this article : http://docs.phalconphp.com/en/0.6.0/reference/volt.html ,but tip error message

Notice: Undefined variable: view in
/var/www/html/phalconblog/public/index.php on line 40

Notice: Undefined variable: di in
/var/www/html/phalconblog/public/index.php on line 40

Fatal error: Call to undefined method
Phalcon\Mvc\View\Engine\Volt::setOptions() in
/var/www/html/phalconblog/public/index.php on line 42

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:37:35+00:00Added an answer on June 13, 2026 at 5:37 pm

    I tried that too and had similar issues – not sure why.

    EDIT

    The correct way is:

    // Register Volt as a service
    $di->set(
        'volt', 
        function($view, $di) 
        {
            $volt = new Phalcon\Mvc\View\Engine\Volt($view, $di);
    
            $volt->setOptions(
                array(
                    'compiledPath'      => $config->volt->path,
                    'compiledExtension' => $config->volt->extension,
                    'compiledSeparator' => $config->volt->separator,
                    'stat'              => (bool) $config->volt->stat,
                )
            );
    
            return $volt;
        }
    );
    
    // Register Volt as template engine
    $di->set(
        'view', 
        function() 
        {
            $view = new \Phalcon\Mvc\View();
            $view->setViewsDir($config->application->viewsDir);
    
            $view->registerEngines(array(".volt" => 'volt'));
    
            return $view;
        }
    );
    

    The below is a workaround but not advised:

    /**
     * Setting up the view component
     */
    $di->set(
        'view', 
        function() use ($config, $di) 
        {
            $view = new \Phalcon\Mvc\View();
            $view->setViewsDir($config->application->viewsDir);
    
            $volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di);
            $volt->setOptions(
                array(
                    'compiledPath'      => $config->volt->path,
                    'compiledExtension' => $config->volt->extension,
                    'compiledSeparator' => $config->volt->separator,
                    'stat'              => (bool) $config->volt->stat,
                )
            );
    
            /**
             * Register Volt
             */
            $view->registerEngines(array('.phtml' => $volt));
    
            return $view;
        }
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

New to webdev. I need to use the same menu on all the pages
New to Git and just started to use Github. Just created my first public
new AjaxOptions { OnBegin = MyFunction, Url=/Controller/JSONAction/+OnbeginRetunrValue, HttpMethod=GET } In my Ajax properties, I
New to Android before I port my application to this platform I wanted to
New to javascript - I'm trying to generate random user ID's for my selenium
New to NodeJS. Yes I know I could use a framework, but I want
New to linux and c++. I wante to create an application that only needs
New to programming and need a little assistance. I have a WPF usercontrol used
New to PDO. Here is my function. We are connected to the database and
new AutoResetEvent(false).WaitOne(Period); What is purpose of this code? Why not use Thread.Sleep instead?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.