Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phalcon\Mvc\View\Exception: View was not found in the views directory #2

Closed
emog opened this issue Feb 20, 2015 · 2 comments
Closed

Comments

@emog
Copy link

emog commented Feb 20, 2015

in index.php
/**
* Setting up volt
*/
$di->set('volt', function($view, $di) {

    $volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di);

    $volt->setOptions(array(
        "compiledPath" => "../cache/volt/"
    ));

    return $volt;
}, true);
/**
 * Register the mail service which use Swift library
 */
$di->set('mail', function() {
    $config = new Phalcon\Config\Adapter\Ini(__DIR__ . '/../app/config/mail.ini');
    $mailer = new \Phalcon\Ext\Mailer\Manager(array(
        "driver" => $config->mail->driver,
        "host" => $config->mail->host,
        "port" => $config->mail->port,
        'encryption' => $config->mail->encryption,
        'username' => $config->mail->username,
        'password' => $config->mail->password,
        'from' => array("email" => $config->mail->fromEmail, "name" => $config->mail->fromName)
    ));
    return $mailer;
});

In Model:

public function beforeCreate() {
    $mailer = $this->getDI()->getMail();
    $viewPath = 'emailTemplates/newuser-' . $this->notifyLang . '';

    $message = $mailer->createMessageFromView($viewPath, array('password' => $this->plainpass))
            ->to(array($this->email => $this->rname))
            ->subject('User Registration')
    ;
    $message->send();
}

I Got The Error:

Phalcon\Mvc\View\Exception: View '/var/www/html/new/app/views/emailTemplates/newuser-bg' was not found in the views directory
File=/var/www/html/new/app/vendor/phalcon-ext/mailer/src/Manager.php
Line=312
#0 [internal function]: Phalcon\Mvc\View\Simple->_internalRender('emailTemplates/...', Array)
#1 /var/www/html/new/app/vendor/phalcon-ext/mailer/src/Manager.php(312): Phalcon\Mvc\View\Simple->render('emailTemplates/...', Array)
#2 /var/www/html/new/app/vendor/phalcon-ext/mailer/src/Manager.php(106): Phalcon\Ext\Mailer\Manager->renderView('emailTemplates/...', Array, '/var/www/html/n...')
#3 /var/www/html/new/app/models/Staff.php(37): Phalcon\Ext\Mailer\Manager->createMessageFromView('emailTemplates/...', Array, '/var/www/html/n...')
#4 [internal function]: Staff->beforeCreate()
#5 [internal function]: Phalcon\Mvc\Model->fireEventCancel('beforeCreate')
#6 [internal function]: Phalcon\Mvc\Model->_preSave(Object(Phalcon\Mvc\Model\MetaData\Memory), false, 'id')
#7 [internal function]: Phalcon\Mvc\Model->save()
#8 /var/www/html/new/app/controllers/StaffController.php(233): Phalcon\Mvc\Model->create()
#9 [internal function]: StaffController->createAction()
#10 [internal function]: Phalcon\Dispatcher->dispatch()
#11 /var/www/html/new/public/index.php(288): Phalcon\Mvc\Application->handle()
#12 {main}

I have checked many times that the view is there. when i do something like
nano /var/www/html/new/app/views/emailTemplates/newuser-bg.volt I have open the view in editor.

I can't understand why Phalcon\Mvc\View thinks that It is not there.

Could you help me with this issue.

@KorsaR-ZN
Copy link
Contributor

@Advokata Sorry for the long answer...
Today will decide the issue.

@KorsaR-ZN
Copy link
Contributor

@Advokata Please upgrade to v2.0.2

P.S
Service "view" in DI for volt engine, configure according to official docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants