How to install env with laravel wizard to have two different database connections (local / remote)?

I am looking to install a project with multiple environments using Laravel3, but I do not understand the command to configure the environment.

I see here: http://laravel.com/docs/artisan/commands Command:

php artisan foo --env=local 

I have already successfully used artisan and bob, which I canโ€™t get under foo , I try to change the name of my project, but always the same conclusion: "Sorry, I can not find this task."

If I try: php artisan --env = local

This will return: "You forgot to specify the name of the task."

Can anybody help? Thank you for your time.

[edit] With answers now I can better understand and improve my question:

I have a project with folders created: http://d.pr/i/5nZS With that in mind, I need to configure my local env as development and production as production. So, can I do this with any change to the "php artisan --env = local" command or do I need to add "SetEnv LARAVEL_ENV development" to my public /.htaccess?

Thanks again.

+7
source share
4 answers

Here is how I solved my question:

At first I do not need the php artisan migrate --env=local , I just need to install my virtual host: SetEnv LARAVEL_ENV development .

Secondly, as William Cahill-Manley says, I need to work on application / paths.php, $ environments. I used it before, but wrong. In my case, I solve with this:

 $environments = array( 'development' => array('http://localhost/project*', '*project/*'), 'production' => array('http://project.com', 'http://*.project.com') ); 

My problem was that my code used to be like this:

 $environments = array( 'development' => array('http://localhost/project*', '*project*'), 'production' => array('http://project.com', 'http://*.project.com') ); 

And since the second element of the development array, the production server will always be in development. That is because the url on development is being http://project/ and on the production being http://project.com/ or http://user.project.com/

See, the project will be forced in all developments to be developed with an asterisk / wildcard.

+1
source

"Foo" is any command you want to run. For example. for migration:

 php artisan migrate --env=local 

Another thing you can do is add your computer name to this array

For example, if my local computer name is "Effinity.local", I could do

 $environments = array( 'local' => array('http://localhost*', 'Effinity.local'), ); 

Then you do not need to specify the environment, just:

 php artisan migrate 

Hope this helps.

+11
source

Foo is the name of the task, try to create this file in the task folder, there is another task that predetermines, for example, migration, etc.

 <?php class foo_task { public function run(){ echo 'this is foo'; } } ?> 

then when you run the command, it will run the code inside the launch function.

 php artisan foo --env=local 
0
source

I would recommend setting up a virtual host based on the name for your web application first:

 <VirtualHost *:80> ServerAdmin postmaster@localhost DocumentRoot "__PATH TO YOUR SERVER ROOT___/project/public/" ServerName project.dev ErrorLog "logs/project-error.log" CustomLog "logs/project-access.log" combined </VirtualHost> 

Then add the project.dev file to the hosts /private/etc/hosts as follows:

 127.0.0.1 project.dev 

Remember to clear the DNS cache again:

 $ dscacheutil -flushcache 

Then change the $ environments array found in [project root]/path.php (the [project root]/path.php application file you mentioned does not exist) back to what it was. The original * .dev character will pick up .dev at the end of your url.

 $environments = array( 'local' => array('http://localhost*', '*.dev'), ); 

Then create a directory in applications/config/ called local , put in a new directory a file called application.php . The configuration specified in this file will override the configuration set by the corresponding configuration files and the parameters / values โ€‹โ€‹specified in the local parent directory that you created.

0
source

All Articles