Hi,
So I'm working to setup laravel on my local system for development. Following along the guides they note to set my development environment in the start.php file. So far everything makes sense, I'm on Windows so when I get my computer name it's "Monk". Therefore my environment setup looks like the following:
$env = $app->detectEnvironment(array(
'local' => array('Monk'),
));
I also have a folder under config called "Local". Everything works great when I die and dump App::Environment I'm told that the app is using the local environment. However I also get an error on every page... here's what I see:
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\sampleproject\laravel\vendor\laravel\framework
\src\Illuminate\Config\EnvironmentVariables.php on line 35
string(5) "local"
If I remove "Monk" from my detectEnvironment settings the error dissapears but it also goes back to "production".
Any ideas?
Did some more digging, I'll keep posting in case this helps anyone else. I added the following to my EvironmentVariable.php file:
echo(is_array($environment) ? 'Array' : 'not an Array');
echo(gettype($environment));
Which is telling me the key value pair being sent over is a string, not an array. I'm running php 5.4.25. Any thoughts as to why this might be coming back as a string and not an array?
Ok I've found something more definitive. If I name my environment any name but "local" it works according to the docs. So for example if I call my development environment "development" instead of "local" the error goes away. Here's my revised environment setup:
$env = $app->detectEnvironment(array(
'development' => 'Monk',
));
If I change "development" to local the error comes back. I can only guess the term local is in conflict with some setting in Xampp. Anyhow I hope this helps someone else who reads this, it sure was a head scratcher.
I think your issue was that you had local capitalized in the first example. I seem to recall having a similar issue. In you're working example, the environment is lower -cased. Windows can be difficult with shell commands as it does not support bash out of the box which is why you have to use something like Cygwin.
Have you considered using Vagrant to setup local virtual mahcines? These are excellent for setting up a dev env that is exactly the same as your prod server. Plus, using Vagrant, you can put your VagrantFile config into git and you can re-build a full local env with a single command. It can be a little tricky at first, but it has great docs and is very powerful once in place.
Checkout: http://www.vagrantup.com/
Here's a good starter for setting up Vagrant with Laravel: https://github.com/bryannielsen/Laravel4-Vagrant
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community