How to fix `Undefined index: db_host ` in phalcon config - phalcon

I have configured server. At last I am getting this issue to make connection.
This is New Linux server as per http://157.245.105.194/test.php
Let me know what is wrong in the code given at : https://docs.google.com/document/d/1M0iqC4_5kGQVgR6aKhKFAwxbpwTOyYN7PyEgjBfL3mQ/edit?usp=sharing
At http://157.245.105.194/styleogram/fs/site/wwwroot/public/
we are getting:
===========
Notice: Undefined index: db_host in /var/www/html/styleogram/fs/site/wwwroot/app/config/config.php on line 56
Notice: Undefined index: db_user in /var/www/html/styleogram/fs/site/wwwroot/app/config/config.php on line 57
Notice: Undefined index: db_password in /var/www/html/styleogram/fs/site/wwwroot/app/config/config.php on line 58
Notice: Undefined index: db_name in /var/www/html/styleogram/fs/site/wwwroot/app/config/config.php on line 59
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [1045] Access denied for user ''#'localhost' (using password: NO)' in /var/www/html/styleogram/fs/site/wwwroot/app/config/config.php:60
Stack trace:
#0 [internal function]: PDO->__construct('mysql:host=;dbn...', NULL, NULL, Array)
#1 [internal function]: Phalcon\Db\Adapter\Pdo->connect(Array)
#2 /var/www/html/styleogram/fs/site/wwwroot/app/config/config.php(60): Phalcon\Db\Adapter\Pdo->__construct(Array)
#3 [internal function]: {closure}()
#4 [internal function]: Phalcon\Di\Service->resolve(NULL, Object(Phalcon\Di\FactoryDefault))
#5 [internal function]: Phalcon\Di->get('db', NULL)
#6 [internal function]: Phalcon\Di->getShared('db')
#7 [internal function]: Phalcon\Mvc\Model\Manager->_getConnection(Object(Article), NULL)
#8 [internal function]: Phalcon\Mvc\Model\Manager->getReadConnection(Object(Article))
#9 [internal function]: Phalcon\Mvc\Model->getReadConnection()
#10 [internal function]: Phalcon\Mvc\Model\Query->_executeSelect(Array, Array, NU in /var/www/html/styleogram/fs/site/wwwroot/app/config/config.php on line 60
===========

The error you see is because your $_SERVER superglobal does not contain the elements you are looking for in your code. You can easily see this in the phpinfo() page you posted (check Apache Information section).
$connection = new MysqlAdapter(
[
"host" => $_SERVER['db_host'],
"username" => $_SERVER['db_user'],
"password" => $_SERVER['db_password'],
"dbname" => $_SERVER['db_name']
]
];
You can remove the references to the $_SERVER array and use strings with the actual information for your installation. For instance $_SERVER['db_host'] could be localhost for you.
Once you do those replacements, check if the error persists - if not, then you have connected to your database correctly.
You can also use the Phalcon\Config object to store configuration data, such as database connection parameters as defined above, instead of setting them in the $_SERVER array.
Alternatively if you want this information to be in the $_SERVER array, then you will have to use the SetEnv in the virtualhost of your apache information.
How to use the setEnv variable in apache?

Related

Laravel 9 and PHP 8.1.7 <Fatal error>: Uncaught Reflection Exception: Class "config" does not exist Container.php:875

I deployed Laravel 9 on localhost and everything was good. When I deployed on cpanel shared hosting, I am getting this error.
Your assistance will be appreciated.
Here are some of the steps I have taken on the localhost but no difference on the shared hosting:
I have cleared the bootstrap contents
composer dump-autoload
: Uncaught ReflectionException: Class "config" does not exist in xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Container/Container.php:875 Stack trace: #0 xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Container/Container.php(875): ReflectionClass->__construct('config') #1 xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Container/Container.php(756): Illuminate\Container\Container->build('config') #2 xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(855): Illuminate\Container\Container->resolve('config', Array, true) #3 xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Container/Container.php(692): Illuminate\Foundation\Application->resolve('config', Array) #4 xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(840): Illuminate\Container\Container->make('config', Array) #5 xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Container/Container.php(1415): Illuminate\Foundation\Application->make('config') #6 xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(515): Illuminate\Container\Container->offsetGet('config') #7 xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(566): Illuminate\Log\LogManager->getDefaultDriver() #8 xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(119): Illuminate\Log\LogManager->parseDriver(NULL) #9 xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(636): Illuminate\Log\LogManager->driver() #10 xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(275): Illuminate\Log\LogManager->error('Call to undefin...', Array) #11 xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(415): Illuminate\Foundation\Exceptions\Handler->report(Object(Error)) #12 xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(113): Illuminate\Foundation\Http\Kernel->reportException(Object(Error)) #13 /home2/phenhost/public_html/index.php(52): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request)) #14 {main} Next Illuminate\Contracts\Container\BindingResolutionException: Target class [config] does not exist. in xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Container/Container.php:877 Stack trace: #0 xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Container/Container.php(756): Illuminate\Container\Container->build('config') #1 xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(855): Illuminate\Container\Container->resolve('config', Array, true) #2 xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Container/Container.php(692): Illuminate\Foundation\Application->resolve('config', Array) #3 xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(840): Illuminate\Container\Container->make('config', Array) #4 xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Container/Container.php(1415): Illuminate\Foundation\Application->make('config') #5 xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(515): Illuminate\Container\Container->offsetGet('config') #6 xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(566): Illuminate\Log\LogManager->getDefaultDriver() #7 xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(119): Illuminate\Log\LogManager->parseDriver(NULL) #8 xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(636): Illuminate\Log\LogManager->driver() #9 xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(275): Illuminate\Log\LogManager->error('Call to undefin...', Array) #10 xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(415): Illuminate\Foundation\Exceptions\Handler->report(Object(Error)) #11 xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(113): Illuminate\Foundation\Http\Kernel->reportException(Object(Error)) #12 /home2/phenhost/public_html/index.php(52): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request)) #13 {main} thrown in xx/xx/xx/xx/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 877

SQLSTATE[HY000] [1049] on YiiFramework

$ yii migrate
Yii Migration Tool (based on Yii v2.0.13-dev)
Exception 'yii\db\Exception' with message 'SQLSTATE[HY000] [1049]
Unknown database 'yii''
in E:\laragon\www\website\vendor\yiisoft\yii2\db\Connection.php:586
Stack trace:
#0 E:\laragon\www\website\vendor\yiisoft\yii2\db\Connection.php(932): yii\db\Connection->open()
#1 E:\laragon\www\website\vendor\yiisoft\yii2\db\Connection.php(919): yii\db\Connection->getMasterPdo()
#2 E:\laragon\www\website\vendor\yiisoft\yii2\db\Command.php(219): yii\db\Connection->getSlavePdo()
#3 E:\laragon\www\website\vendor\yiisoft\yii2\db\Command.php(1031): yii\db\Command->prepare(true)
#4 E:\laragon\www\website\vendor\yiisoft\yii2\db\Command.php(362): yii\db\Command->queryInternal('fetchAll', NULL)
#5 E:\laragon\www\website\vendor\yiisoft\yii2\db\mysql\Schema.php(320): yii\db\Command->queryAll()
#6 E:\laragon\www\website\vendor\yiisoft\yii2\db\mysql\Schema.php(111): yii\db\mysql\Schema->findColumns(Object(yii\db\TableSchema))
#7 E:\laragon\www\website\vendor\yiisoft\yii2\db\Schema.php(661): yii\db\mysql\Schema->loadTableSchema('migration')
#8 E:\laragon\www\website\vendor\yiisoft\yii2\db\Schema.php(174): yii\db\Schema->getTableMetadata('{{%migration}}', 'schema', true)
#9 E:\laragon\www\website\vendor\yiisoft\yii2\console\controllers\MigrateController.php(201): yii\db\Schema->getTableSchema('{{%migration}}', true)
#10 E:\laragon\www\website\vendor\yiisoft\yii2\console\controllers\BaseMigrateController.php(864): yii\console\controllers\MigrateController->getMigrationHistory(NULL)
#11 E:\laragon\www\website\vendor\yiisoft\yii2\console\controllers\BaseMigrateController.php(166): yii\console\controllers\BaseMigrateController->getNewMigrations()
#12 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(0)
#13 E:\laragon\www\website\vendor\yiisoft\yii2\base\InlineAction.php(57): call_user_func_array(Array, Array)
#14 E:\laragon\www\website\vendor\yiisoft\yii2\base\Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#15 E:\laragon\www\website\vendor\yiisoft\yii2\console\Controller.php(135): yii\base\Controller->runAction('', Array)
#16 E:\laragon\www\website\vendor\yiisoft\yii2\base\Module.php(528): yii\console\Controller->runAction('', Array)
#17 E:\laragon\www\website\vendor\yiisoft\yii2\console\Application.php(180): yii\base\Module->runAction('migrate', Array)
#18 E:\laragon\www\website\vendor\yiisoft\yii2\console\Application.php(147): yii\console\Application->runAction('migrate', Array)
#19 E:\laragon\www\website\vendor\yiisoft\yii2\base\Application.php(386): yii\console\Application->handleRequest(Object(yii\console\Request))
#20 E:\laragon\www\website\yii(20): yii\base\Application->run()
#21 {main}
this my db
return [
'class' => 'yii\db\Connection', 'driverName' => 'mysql',
'dsn' => 'mysql:host=localhost;dbname=yii',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
// Schema cache options (for production environment)
//'enableSchemaCache' => true,
//'schemaCacheDuration' => 60,
//'schemaCache' => 'cache', ];
The error message means you need to create a database name 'yii'.
Just use Menu > MySQL > Create database to create the database.

Magento invalid backend name error

I am trying to run a local copy of my website but everytime I run it gives me this error. I tried to look after other similar answer but could not find a relevant answer.
I am using Macbook, XAMPP and Magento 1.8
This is the error displayed
Invalid backend name []
Trace:
#0 /Applications/XAMPP/xamppfiles/htdocs/ameb_prod/lib/Zend/Cache.php(137): Zend_Cache::throwException('Invalid backend...')
#1 /Applications/XAMPP/xamppfiles/htdocs/ameb_prod/lib/Zend/Cache/Backend/TwoLevels.php(135): Zend_Cache::_makeBackend('', Array, true, true)
#2 /Applications/XAMPP/xamppfiles/htdocs/ameb_prod/lib/Zend/Cache.php(153): Zend_Cache_Backend_TwoLevels->__construct(Array)
#3 /Applications/XAMPP/xamppfiles/htdocs/ameb_prod/lib/Zend/Cache.php(94): Zend_Cache::_makeBackend('TwoLevels', Array, true, true)
#4 /Applications/XAMPP/xamppfiles/htdocs/ameb_prod/app/code/core/Mage/Core/Model/Cache.php(137): Zend_Cache::factory('Varien_Cache_Co...', 'TwoLevels', Array, Array, true, true, true)
#5 /Applications/XAMPP/xamppfiles/htdocs/ameb_prod/app/code/core/Mage/Core/Model/Config.php(1354): Mage_Core_Model_Cache->__construct(Array)
#6 /Applications/XAMPP/xamppfiles/htdocs/ameb_prod/app/Mage.php(463): Mage_Core_Model_Config->getModelInstance('core/cache', Array)
#7 /Applications/XAMPP/xamppfiles/htdocs/ameb_prod/app/code/core/Mage/Core/Model/App.php(401): Mage::getModel('core/cache', Array)
#8 /Applications/XAMPP/xamppfiles/htdocs/ameb_prod/app/code/core/Mage/Core/Model/App.php(295): Mage_Core_Model_App->_initCache(Array)
#9 /Applications/XAMPP/xamppfiles/htdocs/ameb_prod/app/code/core/Mage/Core/Model/App.php(337): Mage_Core_Model_App->baseInit(Array)
#10 /Applications/XAMPP/xamppfiles/htdocs/ameb_prod/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#11 /Applications/XAMPP/xamppfiles/htdocs/ameb_prod/index.php(87): Mage::run('', 'store')
#12 {main}

impresspages after installation Fatal error: Uncaught exception

I try install Impresspages on my hosting but after installation have:
Fatal error: Uncaught exception 'Ip\Exception\View' with message 'View view/widget.php not found.' in /Ip/Functions.php:887 Stack trace: #0 /Ip/Internal/Content/Model.php(272): ipView('view/widget.php', Array) #1 /Ip/Internal/Content/Model.php(35): Ip\Internal\Content\Model::_generateWidgetPreview(Array, false) #2 /Ip/Internal/Content/PublicController.php(17): Ip\Internal\Content\Model::generateBlock('main', '13', 0, false) #3 [internal function]: Ip\Internal\Content\PublicController->index() #4 /Ip/Internal/Core/Job.php(126): call_user_func_array(Array, Array) #5 [internal function]: Ip\Internal\Core\Job::ipExecuteController_70(Array) #6 /Ip/Internal/Dispatcher/JobDispatcher.php(39): call_user_func('\Ip\Internal\Co...', Array) #7 /Ip/Dispatcher.php(101): Ip\Internal\Dispatcher\JobDispatcher->handle('ipExecuteContro...', Array) #8 /Ip/Functions.php(368): Ip\Dispatcher->job('ipExecuteContro...', Array) #9 /Ip/Application.php(301): ipJob('ipExecuteContro...', Array) #10 /Ip/Application.php(319): Ip\Application->_handleOnlyR in /Ip/Functions.php on line 887
Where is the problem?
The only thing I could think of right now is that file upload to the server has failed. Try reupload Ip folder.
Thank you.
Problem solved.
The problem was in the server settings.

Fatal error: Uncaught exception 'Zend_Cache_Exception' with message > 'cache_dir must be a directory'

After doing my code update. I got this error.
Could you help me figure this one out?
I gave 777 permission to all of the folders.
Thanks in advance!
Fatal error: Uncaught exception 'Zend_Cache_Exception' with message
'cache_dir must be a directory' in
C:\xampp\htdocs\mts\library\Zend\Cache.php:208 Stack trace: #0
C:\xampp\htdocs\mts\library\Zend\Cache\Backend\File.php(154):
Zend_Cache::throwException('cache_dir must ...') #1
C:\xampp\htdocs\mts\library\Zend\Cache\Backend\File.php(121):
Zend_Cache_Backend_File->setCacheDir('C:\xampp\htdocs...') #2
C:\xampp\htdocs\mts\library\Zend\Cache.php(152):
Zend_Cache_Backend_File->__construct(Array) #3
C:\xampp\htdocs\mts\library\Zend\Cache.php(93):
Zend_Cache::_makeBackend('File', Array, false, false) #4
C:\xampp\htdocs\mts\application\Bootstrap.php(22):
Zend_Cache::factory('Core', 'File', Array, Array) #5
C:\xampp\htdocs\mts\library\Zend\Application\Bootstrap\BootstrapAbstract.php(636):
Bootstrap->_initCache() #6
C:\xampp\htdocs\mts\library\Zend\Application\Bootstrap\BootstrapAbstract.php(589):
Zend_Application_Bootstrap_BootstrapAbstract->_executeResource('cache') 7#
C:\xampp\htdocs\mts\library\Zend\Application\Bootstrap\Boots in
C:\xampp\htdocs\mts\library\Zend\Cache.php on line 208
Setting the cache in bootstrap
protected function _initCaching() {
$frontend = array(
'lifetime' => 7200,
'automatic_serialization' => true
);
$backend = array(
'cache_dir' => sys_get_temp_dir(), /**automatically detects**/
);
$cache = Zend_Cache::factory('core', 'File', $frontend, $backend);
Zend_Registry::set('cache', $cache);
}
Go to C:\xampp\htdocs\mts\library\Zend\Cache\Backend\File.php at line 154 and echo $value before the conditions. It should give you a directory address. Make sure that directory exists in your file system. Basically you need to set this path correctly in your zend configuration.
It's not about permission, ZF can't find the cache directory. Check if the directory you set in application.ini actually exists.
As you are on Windows machine, permissions shouldn't be a problem.