Laravel Homestead Vagrant Box Database Problems

后端 未结 7 2242
轮回少年
轮回少年 2020-12-30 17:11

I can\'t use the same database.php settings when browsing the local website in a browser (example.app:8000) and when using php artisan migrate.

If my database.php se

相关标签:
7条回答
  • 2020-12-30 17:43

    The way that I do this is set variables in the homestead.yml file. PhpDotenv doesn't populate the values if they exist so you can set the environment variables on the Homestead VM and config

    # homestead.yml
    
    variables:
     - key: APP_ENV
       value: local
     - key: DB_HOST
       value: 127.0.0.1
     - key: DB_PORT
       value: 3306
    
    # .env
    
    DB_HOST=192.168.10.10 # Homestead VM IP
    DB_PORT=33060         # Port which is forwarded to 3306 on the VM 
    

    --

    vagrant@homestead:~/Sites/example$ php artisan migrate

    Nothing to migrate.

    --

    Ben in ~/Sites/example on develop$ php artisan migrate

    Nothing to migrate.

    This obviously makes the assumption that all sites running on Homestead are using MySQL (or some database on 3306) and all databases are on the Homestead VM, as opposed to on the host, or at a 3rd party, say AWS etc.

    At the time of writing, homestead doesn't allow you to configure per site variables.

    0 讨论(0)
提交回复
热议问题