Skip to content

Instantly share code, notes, and snippets.

@jeremyvaught
Last active December 26, 2015 23:39
Show Gist options
  • Save jeremyvaught/7232590 to your computer and use it in GitHub Desktop.
Save jeremyvaught/7232590 to your computer and use it in GitHub Desktop.
check machine name for setting the environment in laravel

As per this blog post by Andrew Elkins I run this to set my local environment so artisan will know it without the --env=local tag on each command. For whatever reason, this result is not always the same on OSX

For example, with bootstrap/start.php I have

$env = $app->detectEnvironment(array(

	'local' => array('localhost*',
                     '*.dev', 
                     'Jeremys-MacBook-Air.local', 
                     'Jeremys-MacBook-Air-2.local'
                     ),

));

I keep the second one because occassionally between coffee shops and whatnot, my machine name occassionally changes. Also, all those options are probably overkill but occassionaly something slips it up and I'm baffled until I realize it's using my production settings.

#!/usr/bin/env php
# or type `hostname` in bash
<?php
var_dump(gethostname());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment