家人们,问个 compsoer加载的问题[已解决]
解决方法
是因为composer autoload_classmap.php文件没类映射导致的
解决办法
composer dump-autoload -o
我是用的webman,有用过webman的小伙伴吗?
问题描述
使用了webman的依赖注入,但是引入组件后服务启动不起来了,加载扩展包之后服务也重启了
程序代码或配置
composer require psr/container ^1.1.1 php-di/php-di ^6 doctrine/annotations ^1.14
重现问题的步骤
vendor包中文件已存在
(base) [root@VM-0-11-centos src]# ls -l
total 80
drwxr-xr-x 2 root root 4096 Apr 10 2022 Annotation
-rw-r--r-- 1 root root 4387 Apr 10 2022 CompiledContainer.php
drwxr-xr-x 2 root root 4096 Apr 10 2022 Compiler
-rw-r--r-- 1 root root 11401 Apr 10 2022 ContainerBuilder.php
-rw-r--r-- 1 root root 13819 Apr 10 2022 Container.php
drwxr-xr-x 8 root root 4096 Apr 10 2022 Definition
-rw-r--r-- 1 root root 224 Apr 10 2022 DependencyException.php
drwxr-xr-x 2 root root 4096 Apr 10 2022 Factory
-rw-r--r-- 1 root root 1002 Apr 10 2022 FactoryInterface.php
-rw-r--r-- 1 root root 4446 Apr 10 2022 functions.php
drwxr-xr-x 2 root root 4096 Apr 10 2022 Invoker
-rw-r--r-- 1 root root 263 Apr 10 2022 NotFoundException.php
drwxr-xr-x 2 root root 4096 Apr 10 2022 Proxy
但是报错
Error: Class 'DI\ContainerBuilder' not found in /app/code/playapi/config/container.php:16
Stack trace:
#0 /app/code/playapi/vendor/workerman/webman-framework/src/Config.php(207): include()
#1 /app/code/playapi/vendor/workerman/webman-framework/src/Config.php(63): Webman\Config::loadFromDir()
#2 /app/code/playapi/vendor/workerman/webman-framework/src/support/App.php(141): Webman\Config::load()
#3 /app/code/playapi/support/bootstrap.php(48): support\App::loadAllConfig()
#4 /app/code/playapi/vendor/workerman/webman-framework/src/support/App.php(104): require_once('/app/code/playa...')
#5 /app/code/playapi/vendor/workerman/workerman/Worker.php(2497): support\App::support\{closure}()
#6 /app/code/playapi/vendor/workerman/workerman/Worker.php(1636): Workerman\Worker->run()
#7 /app/code/playapi/vendor/workerman/workerman/Worker.php(1429): Workerman\Worker::forkOneWorkerForLinux()
配置文件内容(config/container.php)
<?php
/**
* This file is part of webman.
*
* Licensed under The MIT License
* For full copyright and license information, please see the MIT-LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @author walkor<walkor@workerman.net>
* @copyright walkor<walkor@workerman.net>
* @link http://www.workerman.net/
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
//return new Webman\Container;
$builder = new \DI\ContainerBuilder();
$builder->addDefinitions(config('dependence', []));
$builder->useAutowiring(true);
$builder->useAnnotations(true);
return $builder->build();
操作系统环境及workerman/webman等具体版本
os:linux
webman:^1.5.0
本作品采用《CC 协议》,转载必须注明作者和本文链接
推荐文章: