gd4Ark / teacher-scoring-system

📝 基于 VUE全家桶、Lumen 开发的 WEB 评教系统
MIT License
91 stars 18 forks source link

后台安装报个错 #2

Closed richard008 closed 4 years ago

richard008 commented 4 years ago

命令:composer install 各种报错,基本上都解决了,最后只有一个没解决: I:\SRC\teacher-scoring-system-master\server>composer install Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Nothing to install or update Generating optimized autoload files Deprecation Notice: Class App\Http\Middleware\CORSMiddleware located in I:/SRC/teacher-scoring-system-master/server/app\Http\Middleware\CorsMiddleware.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://E:/Program Files/composer/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201 20 packages you are using are looking for funding. Use the composer fund command to find out more!


上面问题没解决的情况下强行运行:php artisan migrate --seed 报错:I:\SRC\teacher-scoring-system-master\server>php artisan migrate --seed In ServiceProvider.php line 84: Trying to access array offset on value of type null

代码: protected function loadViewsFrom($path, $namespace) { if (is_array($this->app->config['view']['paths'])) { //报错行 foreach ($this->app->config['view']['paths'] as $viewPath) { if (is_dir($appPath = $viewPath.'/vendor/'.$namespace)) { $this->app['view']->addNamespace($namespace, $appPath); } } }

    $this->app['view']->addNamespace($namespace, $path);
}

mysql安装信息: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 28 Server version: 8.0.19 MySQL Community Server - GPL Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

.env文件内容为: APP_NAME=Lumen APP_ENV=local APP_KEY= APP_DEBUG=true APP_URL=http://localhost APP_TIMEZONE=UTC

LOG_CHANNEL=stack LOG_SLACK_WEBHOOK_URL=

DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=test DB_USERNAME=root DB_PASSWORD=123456 DB_STRICT_MODE=false

CACHE_DRIVER=file QUEUE_CONNECTION=sync

JWT_SECRET=gb0EusMVAnzSbxg9pRmf5EJq4K6cwiTh JWT_TTL=1440


后端

cd server composer install

创建好数据库且填写 .env 文件后,进行数据迁移 不明白是不是问题出在这一句,或者是上面那一步的报错导致下面的错误。

php artisan migrate --seed

有点卡住了,前后不明,各种方法都试过了,主要不明白问题出在哪,希望能得到帮助。谢谢。

richard008 commented 4 years ago

composer降级到1.9.3,没有报错了,看来composer install的问题解决了。 那php artisan migrate --seed 报错的原因基本上找到了:创建好数据库且填写 .env 文件后,进行数据迁移。 这一句语焉不详,mysql版本innodb?mysql数据库需要事先按照某种数据库格式建立好?如果可以的话能不能给一个mysql的导出sql。

richard008 commented 4 years ago

仔细追踪代码发现:似乎好像少了某个config.php文件,这个config.php里面配置了一些 'view'

richard008 commented 4 years ago

强行注释掉上面报错的84行相关代码: protected function loadViewsFrom($path, $namespace) { /**

再次运行:php artisan migrate --seed

In Connection.php line 664:

could not find driver (SQL: select * from information_schema.tables where table_schema = test and table_name = migr ations)

In PDOConnection.php line 31:

could not find driver

In PDOConnection.php line 27:

could not find driver

richard008 commented 4 years ago

配置好PDO可以执行php artisan migrate --seed了 但是 protected function loadViewsFrom($path, $namespace) {

    //  if (is_array($this->app->config['view']['paths'])) {
    //     foreach ($this->app->config['view']['paths'] as $viewPath) {
    //        if (is_dir($appPath = $viewPath.'/vendor/'.$namespace)) {
    //            $this->app['view']->addNamespace($namespace, $appPath);
    //         }
    //     }
    // }

    // $this->app['view']->addNamespace($namespace, $path);

}

依然只能注释。

richard008 commented 4 years ago

作者可以给个部署的方法吗?用Apache部署server文件夹,打开localhost是一个文件夹目录结构,localhost:8080界面正常报错network error。 apache部署项目根路径,打开localhost依然是一个文件夹目录结构,localhost:8080界面正常,但是依然报错network error。 部署server/pulibc路径,打开localhost显示:Lumen (5.7.8) (Laravel Components 5.7.*) 能给个详细点的部署方式吗?新人学习用。

richard008 commented 4 years ago

根据ISSUSE1中的回复,查看api apache部署到./根目录下时: http://127.0.0.1:82/admin 报错:无法访问此网站127.0.0.1 拒绝了我们的连接请求。 http://127.0.0.1/teacher-scoring/server/public/ 报错:404 Not Found The requested URL was not found on this server. apache部署到./server目录下时:http://127.0.0.1:82/admin 报错:无法访问此网站127.0.0.1 拒绝了我们的连接请求。 http://127.0.0.1/teacher-scoring/server/public/ 报错:404 Not Found The requested URL was not found on this server.

localhost:8080,界面正确,都是报错error:network error

richard008 commented 4 years ago

根据API调整文件夹及文件夹名称为teacher-scoring/server/public,配置apache路径为上级菜单。 浏览器打开http://127.0.0.1/teacher-scoring/server/public/ 正常显示:Lumen (5.7.8) (Laravel Components 5.7.*) http://127.0.0.1:82/admin 报错:无法访问此网站127.0.0.1 拒绝了我们的连接请求。 localhost:8080,界面正确,依然报错error:network error。 哪里出了问题?

richard008 commented 4 years ago

谢谢,终于搞定了,php版本和mysql版本的问题