简体   繁体   English

将Laravel项目与MAMP数据库链接

[英]Linking Laravel project with MAMP database

I am following a tutorial on creating a social network with Laravel v5.2. 我正在关注有关使用Laravel v5.2创建社交网络的教程。 However the person in the tutorial uses Vagrant/Homestead but for the life of me I could not get that working so I resorted to MAMP to view my site locally. 但是,本教程中的人使用的是Vagrant / Homestead,但由于我的一生,我无法正常工作,因此我求助于MAMP在本地查看我的网站。 But now I have hit another roadblock. 但是现在我遇到了另一个障碍。

I am trying to configure the ".env" file to connect to my MAMP database so that the migrations that have been written can be executed by I don't know how to go about this? 我正在尝试配置“ .env”文件以连接到我的MAMP数据库,这样我不知道如何执行已执行的迁移操作?

This is my ".env" file. 这是我的“ .env”文件。

APP_ENV=local
APP_DEBUG=true
APP_KEY=base64:7dP18Ga9X3wiFP6wQgUy6UsMu+RrgrU2QpkT4gyDUpI=
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=uniteDB
DB_USERNAME=root
DB_PASSWORD=root

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

"UniteDB" is the database I created in the MAMP PHPMy Admin but that did not work and I don't know where to go from here. “ UniteDB”是我在MAMP PHPMy Admin中创建的数据库,但是没有用,我也不知道从这里开始。 If I try run "PHP artisan migrate" on the command line within my project file it returns 如果我尝试在项目文件中的命令行上运行“ PHP artisan migration”,它将返回

"[Symfony\\Component\\Debug\\Exception\\FatalThrowableError] Parse error: syntax error, unexpected end of file, expecting function (T_FUNCTION)" “ [Symfony \\ Component \\ Debug \\ Exception \\ FatalThrowableError]解析错误:语法错误,文件意外结束,需要函数(T_FUNCTION)”

Any help would be greatly appreciated! 任何帮助将不胜感激! I am new to PHP/Laravel so I have no clue on how to get this to work. 我是PHP / Laravel的新手,所以我不知道如何使它工作。

Thanks. 谢谢。

It is just a syntactical error. 这只是一个语法错误。 Most decent IDEs will highlight or underline the error in your project files. 大多数像样的IDE都会突出显示或强调项目文件中的错误。 It is likely that the issue is in some of your migration files (based on the $table variable) but it could also be in any place that contains code being executed when migrating (eg: the Schema class). 问题可能出在您的某些迁移文件中(基于$ table变量),但也可能存在于任何包含迁移时正在执行的代码的位置(例如:Schema类)。

It sounds like you have a missing semicolon in your migration file. 听起来您的迁移文件中缺少分号。 show me your migration file if you cannot solve the problem 如果您不能解决问题,请告诉我您的迁移文件

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

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