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

Issue after upgrading php 7.2 and composer update #15895

Closed
vzani opened this issue Mar 14, 2018 · 4 comments
Closed

Issue after upgrading php 7.2 and composer update #15895

vzani opened this issue Mar 14, 2018 · 4 comments

Comments

@vzani
Copy link

vzani commented Mar 14, 2018

After upgrading php to 7.2 and running composer update, started facing the following issues:


An Error occurred while handling another error:
yii\base\InvalidConfigException: Unknown component ID: request in /home/xxx/public_html/poc/vendor/yiisoft/yii2/di/ServiceLocator.php:139
Stack trace:
#0 /home/xxx/public_html/poc/vendor/yiisoft/yii2/base/Module.php(742): yii\di\ServiceLocator->get('request', true)
#1 /home/xxx/public_html/poc/vendor/yiisoft/yii2/web/Application.php(160): yii\base\Module->get('request')
#2 /home/xxx/public_html/poc/vendor/yiisoft/yii2/web/ErrorHandler.php(501): yii\web\Application->getRequest()
#3 /home/xxx/public_html/poc/vendor/yiisoft/yii2/web/ErrorHandler.php(115): yii\web\ErrorHandler->shouldRenderSimpleHtml()
#4 /home/xxx/public_html/poc/vendor/yiisoft/yii2/base/ErrorHandler.php(104): yii\web\ErrorHandler->renderException(Object(yii\base\InvalidConfigException))
#5 [internal function]: yii\base\ErrorHandler->handleException(Object(yii\base\InvalidConfigException))
#6 {main}
Previous exception:
yii\base\InvalidConfigException: The configuration for the "log" component must contain a "__class" element. in /home/www/public_html/poc/vendor/yiisoft/yii2/di/ServiceLocator.php:206
Stack trace:
#0 /home/xxx/public_html/poc/vendor/yiisoft/yii2/di/ServiceLocator.php(262): yii\di\ServiceLocator->set('log', Array)
#1 /home/xxx/public_html/poc/vendor/yiisoft/yii2/base/Component.php(180): yii\di\ServiceLocator->setComponents(Array)
#2 /home/xxx/public_html/poc/vendor/yiisoft/yii2/BaseYii.php(566): yii\base\Component->__set('components', Array)
#3 /home/xxx/public_html/poc/vendor/yiisoft/yii2/base/BaseObject.php(97): yii\BaseYii::configure(Object(yii\web\Application), Array)
#4 /home/xxx/public_html/poc/vendor/yiisoft/yii2/base/Application.php(207): yii\base\BaseObject->__construct(Array)
#5 /home/xxx/public_html/poc/index.php(19): yii\base\Application->__construct(Array)
#6 {main}

My composer.json require:

"require": {
    "php": ">=5.4.0",
    "bower-asset/jquery": ">=2.2.1",
    "yiisoft/yii2": ">=2.0.6",
    "yiisoft/yii2-bootstrap": "*",        
    "yiisoft/yii2-swiftmailer": "*",
	"kartik-v/yii2-nav-x": "*",
	"kartik-v/yii2-icons": "*",
	"newerton/yii2-jcrop": "dev-master",
	"kartik-v/yii2-grid": "@dev",
	"yiisoft/yii2-imagine": "~2.0.0",
	"serhatozles/yii2-simplehtmldom": "dev-master",
	"yiisoft/yii2-authclient": "~2.0.0",
	"kartik-v/yii2-widgets": "*",
	"kartik-v/yii2-datecontrol": "dev-master",		
	"alexandernst/yii2-device-detect": "0.0.9",
	"filsh/yii2-oauth2-server": "2.0.1.x-dev",
	"kartik-v/yii2-mpdf": "dev-master",
	"kartik-v/yii2-helpers": "dev-master"
	
}

My "components"

    'components' => [
    	'mailer' => [
    		'class' => 'yii\swiftmailer\Mailer',
    		'useFileTransport' => false
    	],
    	
        'user' => [
            'identityClass' => 'common\models\User',
    		'enableAutoLogin' => false,
    		//'enableSession' => true,
        	
        ],
    	
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
    	'urlManager' => [
    		'class' => 'yii\web\UrlManager',
    		'enableStrictParsing' => true,
    		'showScriptName' => false,
    		'enablePrettyUrl' => true,
    		 
    		'rules' => [
    			'/' => '/index',
    			'<controller:[-\w]+>/<id:\d+>' => '<controller>/view',
    			'<controller:[-\w]+>/<action:[-\w]+>/<id:\d+>' => '<controller>/<action>',
    			'<controller:[-\w]+>/<action:[-\w]+>' => '<controller>/<action>',
    	
    	
    		],
    	], 

    ]

Thanks

@leandrogehlen
Copy link
Contributor

you need to change :

yiisoft/yii2": ">=2.0.6" to "yiisoft/yii2": "~2.0.14"

@samdark
Copy link
Member

samdark commented Mar 14, 2018

Yes. As notes in multiple 2.0 release announcements:

Since there is Yii 2.1 in development now, make sure you have a version constraint in your composer.json, that does not allow it to be installed automatically on update, so when next major version of Yii is released, your project won't break by itself. A version constraint that does not include 2.1 is for example ~2.0.14, make sure you do not have >= or * in version constraints in composer.json.

@samdark samdark closed this as completed Mar 14, 2018
@dpanzer
Copy link

dpanzer commented Jul 16, 2018

Aside from this issue about constraining the version in the composer file, I found that I was able to solve the actual error by modifying the log key as follows:

'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
            'class' => 'yii\log\Logger',
        ],

The message is straightforward - it needs a class for the log, so you give it one.

@dieos2
Copy link

dieos2 commented Jun 27, 2023

sorry but where is this component file?

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

5 participants