Phalcon Framework 3.3.2

Phalcon\Di\Exception: Service 'view' wasn't found in the dependency injection container

/home/phucben/public_html/desktop.php (115)
#0Phalcon\Di->get(view, null)
#1Phalcon\Di->getShared(view)
#2Phalcon\Mvc\Application->handle()
/home/phucben/public_html/desktop.php (115)
<?php
require 'config/define.php';
require 'config/loader.php';
 
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;
use Glang\Auth\Auth;
 
class Application extends \Phalcon\Mvc\Application{
 
    protected function _registerServices(){
        $di = new \Phalcon\DI\FactoryDefault();
        //connect db
        $this->_connect($di);
 
        $loader = new \Phalcon\Loader();
 
        /**
         * We're a registering a set of directories taken from the configuration file
         */
        $loader->registerDirs(
            array(
                __DIR__ . '/apps/library/',
            )
        )->register();
 
        //Registering a router
        $di->set('router', function(){
            return require __DIR__ . '/config/routes.php';
        });
 
        $di->set('url', function(){
            $url = new \Phalcon\Mvc\Url();
            $url->setBaseUri(URL);
            return $url;
        }, true);
        $this->setDI($di);
 
        $di->set('session', function(){
            $session    = new Phalcon\Session\Adapter\Files();
            $session->start();
            return $session;
        });
 
        $di->set('cookies', function() {
            $cookies = new Phalcon\Http\Response\Cookies();
            $cookies->useEncryption(false);
            return $cookies;
        });
        //$di = new Phalcon\DI();
        $di->set('modelsManager', function(){
            return new Phalcon\Mvc\Model\Manager();
        });
 
        //auth
        $di->set('auth', function(){
            return new Auth();
        });
        //cache page
        $viewCache = new \Phalcon\Cache\Frontend\Output(array(
            "lifetime" => 2659200
        ));
        $di->set('viewCache', function() use ($viewCache){
            return new Phalcon\Cache\Backend\File($viewCache, array(
                "cacheDir"  => PATH_ROOT."cache/default/",
                "prefix"    => "d.Output.".date("W")."__"
            ));
        });
        //cache items
        $itemCache = new Phalcon\Cache\Frontend\Data(array(
            "lifetime" => 2659200
        ));
        $di->set('itemCache', function() use ($itemCache) {
            return new \Phalcon\Cache\Backend\File($itemCache, array(
                "cacheDir"  => PATH_ROOT."cache/default/",
                "prefix"    => "d.Data.".date("W")."__"
            ));
        });
    }
 
    public function _connect($di){
        $di->set('db', function(){
            $connection = new DbAdapter(array(
                /*
                'host'      => 'localhost',
                'username'  => 'root',
                'password'  => 'trinhthinh_47',
                'dbname'    => 'phuc_ben',
                'charset'   => 'utf8'
                */
                'host'      => 'localhost',
                'username'  => 'phucben_admin33',
                'password'  => 'admin_-@33$$$',
                'dbname'    => 'phucben_pben2',
                'charset'   => 'utf8'
            ));
            $connection->connect();
            return $connection;
    });
    }
 
    public function main(){
        $this->_registerServices();
        //Register the installed modules
        $this->registerModules(array(
            'frontend' => array(
                'className' => 'Multiple\Frontend\Module',
                'path'      => 'apps/frontend/Module.php'
            ),
            'backend' => array(
                'className' => 'Multiple\Backend\Module',
                'path'      => 'apps/backend/Module.php'
            )
        ));
        $this->auth;
        echo $this->handle()->getContent();
    }
}
 
try {
    $application = new Application();
    $application->main();
}
catch(Exception $exc) {
    throw $exc;
 
    throw new \Exception('Error has occurred');
}
#3Application->main()
/home/phucben/public_html/desktop.php (121)
<?php
require 'config/define.php';
require 'config/loader.php';
 
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;
use Glang\Auth\Auth;
 
class Application extends \Phalcon\Mvc\Application{
 
    protected function _registerServices(){
        $di = new \Phalcon\DI\FactoryDefault();
        //connect db
        $this->_connect($di);
 
        $loader = new \Phalcon\Loader();
 
        /**
         * We're a registering a set of directories taken from the configuration file
         */
        $loader->registerDirs(
            array(
                __DIR__ . '/apps/library/',
            )
        )->register();
 
        //Registering a router
        $di->set('router', function(){
            return require __DIR__ . '/config/routes.php';
        });
 
        $di->set('url', function(){
            $url = new \Phalcon\Mvc\Url();
            $url->setBaseUri(URL);
            return $url;
        }, true);
        $this->setDI($di);
 
        $di->set('session', function(){
            $session    = new Phalcon\Session\Adapter\Files();
            $session->start();
            return $session;
        });
 
        $di->set('cookies', function() {
            $cookies = new Phalcon\Http\Response\Cookies();
            $cookies->useEncryption(false);
            return $cookies;
        });
        //$di = new Phalcon\DI();
        $di->set('modelsManager', function(){
            return new Phalcon\Mvc\Model\Manager();
        });
 
        //auth
        $di->set('auth', function(){
            return new Auth();
        });
        //cache page
        $viewCache = new \Phalcon\Cache\Frontend\Output(array(
            "lifetime" => 2659200
        ));
        $di->set('viewCache', function() use ($viewCache){
            return new Phalcon\Cache\Backend\File($viewCache, array(
                "cacheDir"  => PATH_ROOT."cache/default/",
                "prefix"    => "d.Output.".date("W")."__"
            ));
        });
        //cache items
        $itemCache = new Phalcon\Cache\Frontend\Data(array(
            "lifetime" => 2659200
        ));
        $di->set('itemCache', function() use ($itemCache) {
            return new \Phalcon\Cache\Backend\File($itemCache, array(
                "cacheDir"  => PATH_ROOT."cache/default/",
                "prefix"    => "d.Data.".date("W")."__"
            ));
        });
    }
 
    public function _connect($di){
        $di->set('db', function(){
            $connection = new DbAdapter(array(
                /*
                'host'      => 'localhost',
                'username'  => 'root',
                'password'  => 'trinhthinh_47',
                'dbname'    => 'phuc_ben',
                'charset'   => 'utf8'
                */
                'host'      => 'localhost',
                'username'  => 'phucben_admin33',
                'password'  => 'admin_-@33$$$',
                'dbname'    => 'phucben_pben2',
                'charset'   => 'utf8'
            ));
            $connection->connect();
            return $connection;
    });
    }
 
    public function main(){
        $this->_registerServices();
        //Register the installed modules
        $this->registerModules(array(
            'frontend' => array(
                'className' => 'Multiple\Frontend\Module',
                'path'      => 'apps/frontend/Module.php'
            ),
            'backend' => array(
                'className' => 'Multiple\Backend\Module',
                'path'      => 'apps/backend/Module.php'
            )
        ));
        $this->auth;
        echo $this->handle()->getContent();
    }
}
 
try {
    $application = new Application();
    $application->main();
}
catch(Exception $exc) {
    throw $exc;
 
    throw new \Exception('Error has occurred');
}
#4include_once(/home/phucben/public_html/desktop.php)
/home/phucben/public_html/index.php (22)
<?php
if(filter_input(INPUT_COOKIE,"mgs") == "mgs")
{
  include_once __DIR__."/mobile/mobile.php";
  exit;
}
 
if(filter_input(INPUT_COOKIE,"mobile") != null)
{
    include_once __DIR__."/mobile/mobile.php";
}
else
{
  include "Mobile_Detect.php";
  $detect     = new Mobile_Detect;
  $version    = $detect->isMobile();
  if($version != false){
    setcookie("mobile", md5(time()), time() + 864000);
    include_once __DIR__."/mobile/mobile.php";
  }
  else{
    include_once __DIR__."/desktop.php";
  }
}
KeyValue
_url/Tin-tuc
KeyValue
PATH/usr/local/bin:/usr/bin:/bin
TEMP/tmp
TMP/tmp
TMPDIR/tmp
PWD/
HTTP_ACCEPTtext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_ACCEPT_ENCODINGgzip
HTTP_CONNECTIONKeep-Alive
CONTENT_LENGTH0
HTTP_HOSTphucben.com
HTTP_USER_AGENTCCBot/2.0 (https://commoncrawl.org/faq/)
REDIRECT_UNIQUE_IDW6oVas@uuxFmqfBnjyjGiwAAAQc
REDIRECT_STATUS200
UNIQUE_IDW6oVas@uuxFmqfBnjyjGiwAAAQc
SERVER_SIGNATURE
SERVER_SOFTWAREApache
SERVER_NAMEphucben.com
SERVER_ADDR112.78.2.153
SERVER_PORT80
REMOTE_ADDR54.80.83.123
DOCUMENT_ROOT/home/phucben/public_html
REQUEST_SCHEMEhttp
CONTEXT_PREFIX
CONTEXT_DOCUMENT_ROOT/home/phucben/public_html
SERVER_ADMINwebmaster@phucben.com
SCRIPT_FILENAME/home/phucben/public_html/index.php
REMOTE_PORT45642
REDIRECT_URL/Tin-tuc
REDIRECT_QUERY_STRING_url=/Tin-tuc
SERVER_PROTOCOLHTTP/1.1
REQUEST_METHODGET
QUERY_STRING_url=/Tin-tuc
REQUEST_URI/Tin-tuc
SCRIPT_NAME/index.php
PHP_SELF/index.php
REQUEST_TIME_FLOAT1537873259.2361
REQUEST_TIME1537873259
#Path
0/home/phucben/public_html/index.php
1/home/phucben/public_html/Mobile_Detect.php
2/home/phucben/public_html/desktop.php
3/home/phucben/public_html/config/define.php
4/home/phucben/public_html/config/loader.php
5/home/phucben/public_html/apps/library/auth/Auth.php
6/home/phucben/public_html/config/routes.php
Memory
Usage786432