Last active
March 9, 2017 15:16
-
-
Save tedslittlerobot/bda722213884b562bf94cd43a9af1bd9 to your computer and use it in GitHub Desktop.
Run Artisan Database Commands on Virtual Machine from Host Machine (RADCBMHM™)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HOST_DB_PORT=33060 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Providers; | |
use Illuminate\Support\ServiceProvider; | |
class AppServiceProvider extends ServiceProvider | |
{ | |
/** | |
* Bootstrap any application services. | |
* | |
* @return void | |
*/ | |
public function boot() | |
{ | |
$this->overrideDbPort(); | |
} | |
/** | |
* Register any application services. | |
* | |
* @return void | |
*/ | |
public function register() | |
{ | |
// | |
} | |
public function overrideDbPort() | |
{ | |
// When local, and in the console... | |
if ($this->app->isLocal() && $this->app->runningInConsole()) { | |
// Override the port so you can tunnel into homestead. | |
if ($port = config('database.host-port')) { | |
config()->set('database.connections.mysql.port', $port); | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return [ | |
'host-port' => env('HOST_DB_PORT'), | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment