简体   繁体   English

未找到数据库事务 - Lumen

[英]Database Transactions Not Found - Lumen

I've been writing tests in lumen but I need to move to a different machine so I've been trying to set it all up.我一直在用 lumen 编写测试,但我需要转移到另一台机器上,所以我一直在尝试设置它。 I copied over my tests but I get this error on all of them when I run them我复制了我的测试,但是当我运行它们时,我在所有这些测试中都出现了这个错误

 [Symfony\Component\Debug\Exception\FatalErrorException]
 Trait 'Laravel\Lumen\Testing\DatabaseTransactions' not found

I think I have lumen installed as I did the command composer require "laravel/installer".我想我已经安装了 lumen,因为命令 composer 需要“laravel/installer”。 Is there something I'm meant to do?有什么我想做的吗?

Edit: I looked at the version that was working on my old machine and this code was at the top of app.php in the bootstrap folder编辑:我查看了在我的旧机器上运行的版本,这段代码位于 bootstrap 文件夹中 app.php 的顶部

try {
(new Dotenv\Dotenv(__DIR__.'/../'))->load();
} catch (Dotenv\Exception\InvalidPathException $e) {
//
}

I inserted that at the top of app.php on my new machine and that error stopped appearing and I was now able to run a test.我将它插入到我的新机器上 app.php 的顶部,该错误不再出现,现在我可以运行测试了。 Unfortunately a new error occurs when I just have the default example test不幸的是,当我只有默认示例测试时会出现新错误

1) ExampleTest::testBasicExample
   Error: Call to undefined method ExampleTest::visit()

I'm guessing that I'm still missing something from lumen/laravel我猜我仍然缺少 lumen/laravel 的一些东西

That command is for the Laravel installer.该命令用于 Laravel 安装程序。 The command for the Lumen installer is: Lumen 安装程序的命令是:

composer require "laravel/lumen-installer"

However, even then, that only installs the installer.但是,即使这样,也只会安装安装程序。 You still need to run the command to create a new install (eg lumen new my-site ).您仍然需要运行命令来创建新安装(例如lumen new my-site )。

There's a lot of ambiguity as to what you're trying to do and what you've attempted.关于你正在尝试做什么和你已经尝试过什么,有很多模棱两可的地方。

Generally when installing your site on a new machine, you should just need to clone your repository (or copy your code over), and do a composer install .通常,在新机器上安装您的站点时,您只需要克隆您的存储库(或复制您的代码),然后执行composer install

Try the following:请尝试以下操作:

composer cache clean
composer update
composer dump-autoload

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM