这是我第一次尝试laravel,我知道这可能是愚蠢的,但我已经谷歌搜索了几个小时,无法解决它。
我刚试过这个创建并使用链接表的step by step guide
当我执行“构建链接列表”指令时,每个步骤都成功运行,使用thinker shell进行测试也成功运行,我也检查了phpmyadmin,并创建了“links”表并且有数据,
但是当我在浏览器中刷新页面时(就在开始下一步“显示链接提交表单”之前),它会显示“哎呀!”对我来说。
错误是
Illuminate \ Database \ QueryException(42S02)
SQLSTATE [42S02]:未找到基表或视图:1146表'homestead.links'不存在(SQL:select * fromlinks
)
正如我搜索过的,这个错误主要表现在表名不同的时候,但我没有更改表名。
database / migrations / {{datetime}} _ create_links_table.php:
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateLinksTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('links', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->string('url')->unique();
$table->text('description');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('links');
}
}
.env文件
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:5CLg58/Fa/FmylTmaUH6KA4kcVKBSKC4Iq7WtqCpB8E=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
已创建密码为secret的用户名宅基地
和Homestead.yaml:D
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/code
to: /home/vagrant/code
sites:
- map: links.local
to: /home/vagrant/code/links/public
databases:
- homestead
如果有人帮助我,我将不胜感激
答案 0 :(得分:1)
更改
192.168.10.10 put this into your .env file instead of 127.0.0.1