You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in index.php
`$config = new Config(
new ConfigPaths($rootPath,'config','../vendor'),
);
// Run HTTP application runner
$runner = new HttpApplicationRunner($rootPath, $_ENV['YII_DEBUG'], $_ENV['YII_ENV']);
$runner->withConfig($config)->run();`
throwable: Yiisoft\Di\NotFoundException: No definition or class found or resolvable for "Psr\Log\LoggerInterface" while building "Yiisoft\ErrorHandler\ErrorHandler" -> "Psr\Log\LoggerInterface". in ****\vendor\yiisoft\di\src\Container.php:542
Stack trace:
#0 ****\vendor\yiisoft\di\src\Container.php(503): Yiisoft\Di\Container->buildInternal() #1 ****\vendor\yiisoft\di\src\Container.php(153): Yiisoft\Di\Container->build() #2 ****\vendor\yiisoft\yii-runner-http\src\HttpApplicationRunner.php(86): Yiisoft\Di\Container->get() #3 ****\webroot\app\index.php(48): Yiisoft\Yii\Runner\Http\HttpApplicationRunner->run()
if (getenv('YII_ENV') === 'test') {
$c3 = dirname(DIR) . '/c3.php';
if (file_exists($c3)) {
require_once $c3;
}
}
$rootPath = dirname(DIR,2).'/app';
$config = new Config(
new ConfigPaths($rootPath,'config','../vendor'),
);
// Run HTTP application runner
$runner = new HttpApplicationRunner($rootPath, $_ENV['YII_DEBUG'], $_ENV['YII_ENV']);
$runner->withConfig($config)->run();`
### stack
2022-03-10 07:21:05.871100 [error][application] Yiisoft\Di\NotFoundException with message 'No definition or class found or resolvable for "Psr\Log\LoggerInterface" while building "Yiisoft\ErrorHandler\ErrorHandler" -> "Psr\Log\LoggerInterface".'
throwable: Yiisoft\Di\NotFoundException: No definition or class found or resolvable for "Psr\Log\LoggerInterface" while building "Yiisoft\ErrorHandler\ErrorHandler" -> "Psr\Log\LoggerInterface". in ***\vendor\yiisoft\di\src\Container.php:542
Stack trace:
#0 ***\vendor\yiisoft\di\src\Container.php(503): Yiisoft\Di\Container->buildInternal() #1 ***\vendor\yiisoft\di\src\Container.php(153): Yiisoft\Di\Container->build() #2 ***\vendor\yiisoft\yii-runner-http\src\HttpApplicationRunner.php(86): Yiisoft\Di\Container->get() #3 ***\webroot\app\index.php(56): Yiisoft\Yii\Runner\Http\HttpApplicationRunner->run() #4 {main}
time: 1646896865.871105
memory: 2721656
category: 'application'
mkdir /tmp/yii3log; cd /tmp/yii3log; git clone https://github.com/yiisoft/app .
rm composer.lock
nano composer.lock
paste your dependencies, remove yii-debug-* packages from require-dev section
composer i --prefer-dist
./yii serve &
curl -I localhost:8080
And we will see the following output:
HTTP/1.1 200 OK
Host: localhost:8080
Date: Sun, 13 Mar 2022 09:43:58 GMT
Connection: close
Set-Cookie: PHPSESSID=s72n72r674fsn06tujtlmckp8vqkqj6e47hhaanib7lafmgn; Domain=localhost; Path=/; HttpOnly; SameSite=Lax
Content-Type: text/html; charset=UTF-8
If it works for you and doesn't work from your app please share whole project as git repository. Just commit all files and push them to remote repository.
Activity
terabytesoftw commentedon Mar 10, 2022
Can you please post the entire index.php, and the full stack, thanks.
fufudao commentedon Mar 10, 2022
index.php
`<?php
declare(strict_types=1);
use Yiisoft\Yii\Runner\Http\HttpApplicationRunner;
use Yiisoft\Config\Config;
use Yiisoft\Config\ConfigPaths;
use Yiisoft\Yii\Runner\ConfigFactory;
/**
*/
// PHP built-in server routing.
if (PHP_SAPI === 'cli-server') {
// Serve static files as is.
/** @psalm-suppress MixedArgument */
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
if (is_file(DIR . $path)) {
return false;
}
}
require_once dirname(DIR,2) . '/app/autoload.php';
if (getenv('YII_ENV') === 'test') {
$c3 = dirname(DIR) . '/c3.php';
if (file_exists($c3)) {
require_once $c3;
}
}
$rootPath = dirname(DIR,2).'/app';
$config = new Config(
new ConfigPaths($rootPath,'config','../vendor'),
);
// Run HTTP application runner
$runner = new HttpApplicationRunner($rootPath, $_ENV['YII_DEBUG'], $_ENV['YII_ENV']);
$runner->withConfig($config)->run();`
### stack
2022-03-10 07:21:05.871100 [error][application] Yiisoft\Di\NotFoundException with message 'No definition or class found or resolvable for "Psr\Log\LoggerInterface" while building "Yiisoft\ErrorHandler\ErrorHandler" -> "Psr\Log\LoggerInterface".'
in ***\vendor\yiisoft\di\src\Container.php:542
Stack trace:
#0 ***\vendor\yiisoft\di\src\Container.php(503): Yiisoft\Di\Container->buildInternal()
#1 ***\vendor\yiisoft\di\src\Container.php(153): Yiisoft\Di\Container->build()
#2 ***\vendor\yiisoft\yii-runner-http\src\HttpApplicationRunner.php(86): Yiisoft\Di\Container->get()
#3 ***\webroot\app\index.php(56): Yiisoft\Yii\Runner\Http\HttpApplicationRunner->run()
#4 {main}
Message context:
throwable: Yiisoft\Di\NotFoundException: No definition or class found or resolvable for "Psr\Log\LoggerInterface" while building "Yiisoft\ErrorHandler\ErrorHandler" -> "Psr\Log\LoggerInterface". in ***\vendor\yiisoft\di\src\Container.php:542
Stack trace:
#0 ***\vendor\yiisoft\di\src\Container.php(503): Yiisoft\Di\Container->buildInternal()
#1 ***\vendor\yiisoft\di\src\Container.php(153): Yiisoft\Di\Container->build()
#2 ***\vendor\yiisoft\yii-runner-http\src\HttpApplicationRunner.php(86): Yiisoft\Di\Container->get()
#3 ***\webroot\app\index.php(56): Yiisoft\Yii\Runner\Http\HttpApplicationRunner->run()
#4 {main}
time: 1646896865.871105
memory: 2721656
category: 'application'
xepozz commentedon Mar 12, 2022
Do you have this file?
fufudao commentedon Mar 13, 2022
yes , I have new ErrorHandler in index.php, it's ok, same problem, thanks
$runner = new HttpApplicationRunner($rootPath, $_ENV['YII_DEBUG'], $_ENV['YII_ENV']);
$runner->withTemporaryErrorHandler(new ErrorHandler(
new Logger([new FileTarget(dirname(DIR) . '/runtime/logs/app.log')]),
new JsonRenderer(),
));
$runner->withConfig($config)->run();
fufudao commentedon Mar 13, 2022
yes , I have new ErrorHandler in index.php, it's ok, thanks
xepozz commentedon Mar 13, 2022
Could you share your repo?
fufudao commentedon Mar 13, 2022
the same with repo, without yiisoft/yii-debug
"php": "^8.0",
"httpsoft/http-message": "^1.0.5",
"psr/container": "^1.0",
"psr/http-message": "^1.0",
"psr/http-server-handler": "^1.0",
"symfony/console": "^5.3",
"vlucas/phpdotenv": "^5.3",
"yiisoft/aliases": "^2.0",
"yiisoft/assets": "^2.0",
"yiisoft/cache": "^1.0",
"yiisoft/cache-file": "^1.0",
"yiisoft/config": "^1.0",
"yiisoft/csrf": "^1.2",
"yiisoft/data-response": "^1.0",
"yiisoft/definitions": "^1.0",
"yiisoft/di": "^1.0",
"yiisoft/error-handler": "^2.0",
"yiisoft/factory": "^1.0",
"yiisoft/files": "^1.0",
"yiisoft/html": "^2.0",
"yiisoft/http": "^1.2",
"yiisoft/i18n": "^1.0.0",
"yiisoft/log": "^1.0",
"yiisoft/log-target-file": "^1.0",
"yiisoft/router": "^1.0",
"yiisoft/router-fastroute": "^1.0",
"yiisoft/view": "^4.0",
"yiisoft/yii-console": "^1.0",
"yiisoft/yii-event": "^1.0",
"yiisoft/yii-http": "^1.0",
"yiisoft/yii-runner-console": "^1.0",
"yiisoft/yii-runner-http": "^1.0",
"yiisoft/yii-view": "^4.0"
xepozz commentedon Mar 13, 2022
So let's roll from the scratch:
mkdir /tmp/yii3log; cd /tmp/yii3log; git clone https://github.com/yiisoft/app .rm composer.locknano composer.lockyii-debug-*packages fromrequire-devsectioncomposer i --prefer-dist./yii serve &curl -I localhost:8080And we will see the following output:
If it works for you and doesn't work from your app please share whole project as git repository. Just commit all files and push them to remote repository.
fufudao commentedon Mar 17, 2022
hi, I follow your advice, it's ok, then I move app/public to another place, error!
I use this index.php
log-----------------------------------
Message context:
vjik commentedon Mar 17, 2022
@fufudao try replace
to
Configshould use recursive merge for params.ConfigFactoryconfigure it.