小编Jak*_*Lim的帖子

Docker、PhpStorm 和 PHPUnit - 指定了自动加载器的值,但文件不存在

我正在尝试将我的 PhpStorm 调试器与 PHPUnit 连接。我正在使用 Docker env,并且 docker PHPUnit 内部工作正常。问题是当我单击“测试”目录 PPM -> 运行测试时

我懂了:

[docker://environment_php_8_fpm:latest/]:php /opt/.phpstorm_helpers/phpunit.php --no-configuration /opt/project/src/tests
Testing started at 16:19 ...
The value of autoloader is specified, but file doesn't exist '/home/kuba/Work/CodeProjects/advertisement-crawler/src/vendor/autoload.php'

Process finished with exit code 1 
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

我试图在谷歌中找到解决方案,但很难找到有用的东西。

@edit此外,我提供了新路径,在单击刷新新路径后我得到了这个路径是:/opt/project/src/vendor/autoload.php 在此输入图像描述

现在,在 phpstorm 中运行此命令后,我收到了新的错误消息

[docker://environment_php_8_fpm:latest/]:php /opt/.phpstorm_helpers/phpunit.php --configuration /opt/project/src/phpunit.xml
Testing started at 18:48 ...

Fatal error: Uncaught Error: Class "PHPUnit_TextUI_ResultPrinter" not found in /opt/.phpstorm_helpers/phpunit.php on line 231

Error: Class "PHPUnit_TextUI_ResultPrinter" not found in /opt/.phpstorm_helpers/phpunit.php on line 231

Call Stack:
    0.0006 …
Run Code Online (Sandbox Code Playgroud)

php phpunit phpstorm docker

9
推荐指数
1
解决办法
5379
查看次数

Laravel - updateOrCreate 方法,是不是打破了编程原则

我在 Laravel-Eloquent 的方法中找到了updateOrCreate(). 为什么在框架中我们可以找到破坏干净代码和 SOLID 规则的方法?

solid-principles laravel

7
推荐指数
1
解决办法
87
查看次数

Go 不能使用 name (type []string) 作为 ...string 参数的 string 类型

我在编译这段代码时遇到了这个问题:

./greet.go:11:29: cannot use name (type []string) as type string in argument to CheckStringsAreUppercase
Run Code Online (Sandbox Code Playgroud)

但我不明白为什么。name ...string并且words ...string具有完全相同的类型。这是怎么回事?

func Greet(name ...string) string {
        helloWord := "Hello"
    
        if CheckStringsAreUppercase(name) {
            return strings.ToUpper(helloWord)
        }
    
        return helloWord
    }
    
    func CheckStringsAreUppercase(words ...string) bool {
        for _, word := range words {
            if !CheckStringIsUppercase(word) {
                return true
            }
        }
    
        return true
    }
Run Code Online (Sandbox Code Playgroud)

variadic-functions go slice

1
推荐指数
1
解决办法
4560
查看次数

创建索引后 MySQL 查询速度变慢

首先我会写一些关于我的测试表的信息。这是 books 表,有 665647 行数据。下面您可以看到它的外观。

在此输入图像描述

我对价格相同的书籍进行了 10 次相同的查询

select * from books where price = 10
Run Code Online (Sandbox Code Playgroud)

所有 10 个查询的执行时间为 9 秒 663 毫秒。

之后我创建了索引,您可以在这里看到: 在此输入图像描述

我尝试再次运行相同的 10 个查询。它们的执行时间为 21 秒 996 毫秒。

show index from books;
Run Code Online (Sandbox Code Playgroud)

为我显示了非常有线的数据。可能的值只有一个!

在此输入图像描述

我做错了什么?我确信索引可以使我们的查询更快,而不是更慢。

我发现这个主题:MySQL索引减慢查询速度 ,但说实话,我不太理解这一点,尤其是我的表格书中的基数列,此时价格字段有两个可能的值10和30仍然show index from books;显示1 在此输入图像描述

@Edit1 SHOW CREATE TABLE 书籍

结果:

    CREATE TABLE `books` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `isbn` bigint unsigned NOT NULL,
  `price` double(8,2) …
Run Code Online (Sandbox Code Playgroud)

mysql indexing

-1
推荐指数
1
解决办法
902
查看次数