public function init() { $dbParams = ['driver' => $this->driver, 'host' => $this->host, 'user' => $this->user, 'password' => $this->password, 'dbname' => $this->dbname, 'charset' => 'utf8mb4']; $this->pathProxy = $this->path . DIRECTORY_SEPARATOR . 'proxy'; if (!is_dir($this->pathCache)) { File::createDirectory($this->pathCache); } if (!is_dir($this->pathProxy)) { File::createDirectory($this->pathProxy); } $config = new Configuration(); $cache = new \Doctrine\Common\Cache\FilesystemCache($this->pathCache); $config->setMetadataCacheImpl($cache); $config->setQueryCacheImpl($cache); $driverImpl = $config->newDefaultAnnotationDriver($this->path); $config->setMetadataDriverImpl($driverImpl); $config->setProxyDir($this->pathProxy); $config->setProxyNamespace('app\\tables\\proxy'); if ($this->applicationMode == "development") { $config->setAutoGenerateProxyClasses(true); } else { $config->setAutoGenerateProxyClasses(false); } $this->doctrine = EntityManager::create($dbParams, $config); }
public function __construct() { $this->path = MAIN_DIRECTORY . DIRECTORY_SEPARATOR . 'log'; if (!is_dir($this->path)) { File::createDirectory($this->path, $this->dirMode, true); } $this->logFile = $this->path . DIRECTORY_SEPARATOR . 'app.log'; $this->log = new Logger('app'); $webProcessor = new WebProcessor(); $format = "[%datetime%] %channel%.%level_name%: %message% %extra.ip% %extra.http_method% %context% %extra%\n"; $formatter = new LineFormatter($format, null, true); $logRotate = new RotatingFileHandler($this->logFile, 45, Logger::INFO, true, 0777); $logRotate->setFormatter($formatter); $this->log->pushHandler($logRotate); $this->log->pushProcessor($webProcessor); }