带有Laravel Unix套接字的MAMP [英] MAMP with Laravel Unix Socket
问题描述
我正在laravel应用程序的本地开发服务器上使用MAMP,并且试图弄清楚如何安全地设置服务器,因此不必在数据库连接mysql数组中使用以下内容,因为只能在开发服务器上使用时使用.当我将行添加到mysql数组中时,它可以工作,但是如果我在生产服务器上,则不会使用.有什么想法吗?
I'm working with MAMP on my local development server on my laravel application and I'm trying to figure out how I can safely setup my server so I don't have to use the following into the database connections mysql array because that should only be used when I'm on my development server. It works when I add the line into the mysql array however that isn't used if I was on a production server. Any ideas?
'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock',
.env.development.php
.env.development.php
<?php
return [
'DB_HOST' => '127.0.0.1',
'DB_USERNAME' => 'root',
'DB_PASSWORD' => '1234',
'DB_NAME' => 'mytable'
];
app/config/database.php
app/config/database.php
'connections' => array(
'mysql' => array(
'driver' => 'mysql',
'host' => getenv('DB_HOST'),
'database' => getenv('DB_NAME'),
'username' => getenv('DB_USERNAME'),
'password' => getenv('DB_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
推荐答案
检查bootstrap/start.php
中的环境检测部分.您应该将计算机的名称添加到具有local
键的阵列中. (如果您不知道计算机的名称,请在终端上运行hostname
.如果这很愚蠢,则Google如何更改它.这很简单.)然后将数据库配置复制并粘贴到app/config/local/database.php
.如果文件不存在,请创建它.
Check the environment detection part in the bootstrap/start.php
. You should add your machine's name to the array that has local
key. (If you don't know your machine's name, run hostname
in terminal. If it's something stupid, Google how to change it. It's pretty simple.) Then copy and paste your database configurations to app/config/local/database.php
. Create the file if it doesn't exists.
这篇关于带有Laravel Unix套接字的MAMP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!