A
A
Alexander Ivanov2016-05-12 00:05:18
PHP
Alexander Ivanov, 2016-05-12 00:05:18

What needs to be fixed in the phalcon application?

I think that the problem is that I did not connect some use.
Understanding phalcon Learned from
this tutorial https://www.youtube.com/watch?v=I9uBJubkA_c
Output 2 warnings:
Notice: Undefined property: Phalcon\Config::$controllerDir in C:\www\OpenServer\domains\ localhost\test\app\config\loader.php on line 6

<?php
  $loader = new \Phalcon\loader();

  $loader->registerDirs(
    array(
      $config->application->controllerDir,//эта строка
      $config->application->modelsDir
    )
  )->register();

Notice: Undefined property: Phalcon\Config::$ViewsDir in C:\www\OpenServer\domains\localhost\test\app\config\services.php on line 29
<?php
use Phalcon\Loader;
use Phalcon\Di\FactoryDefault;
use Phalcon\Mvc\View;
use Phalcon\Mvc\View\Engine\Volt as PhVolt;
use Phalcon\Mvc\Application;
use Phalcon\Mvc\Model\Metadata\Memory as PhMetadataMemory;
use Phalcon\Mvc\Url as UrlProvider;
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;

$di = new FactoryDefault();

/**
 * Генерация юрл в приложении
 * */

$di->set('', function() use ($config){
  $url = new UrlResolver();
  $url->setBaseUrl($config->application->baseUrl);

  return $url;
}, true);

/**
 * Настраиваем базовый URI так, чтобы все генерируемые URI содержали директорию "tutorial"
 */
$di->set('view', function() use ($config){
  $view = new View();
  $view->setViewsDir($config->application->ViewsDir); //эта строка
  $view->registerEngines(array(
    ".twig" => 'Phalcon\Mvc\View\Engine\Volt'
  ));

  return $view;
}, true);

/**
 * Подключение базы данных
 */
$di->set('db', function() use ($config){
  return new DbAdapter(array(
    array(
      "host" => $config->database->host,
      "username" => $config->database->username,
      "password" => $config->database->password,
      "dbname" => $config->database->dbname
    )
  ));
});

/**
 * Пока не знаю для чего
 */
$di->set('MetaDataAdapter', function() {
  return new MetaDataAdapter();
});

/**
 * Видимо сессии
 */
$di->set('session', function() {
  $session = new SessionAdapter();
  $session->start();

  return $session;
});

it also gives the message
Views directory must be a string or an array
(the view can be a string or an array)
index in public
<?
error_reporting(E_ALL);

try {

    $config = include  __DIR__ . "/../app/config/config.php"; //подключение базы данных

    include  __DIR__ . "/../app/config/loader.php"; //пока не знаю зачем

    include  __DIR__ . "/../app/config/services.php"; //подключение файла настроек

    $application = new \Phalcon\Mvc\Application($di);

    echo $application->handle()->getContent();//комментирую эту строку убирается сообщение про services.php 

}  catch (\Exception $e) {
    echo $e->getMessage();
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ivanov, 2016-05-12
@cimonlebedev

I solved the answer in the comment

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question