1

So when I use localhost I am using the cmd to run artisan commands. However when I upload my app on a server how can I run those kinds of commands? I searched but eventually got confused and I don't know what to do. Thanks in advance.

2
  • Have you run into any problem? Commented Jun 4, 2016 at 9:19
  • You have to ssh in to your server with a tools like putty.org Commented Jun 4, 2016 at 9:20

2 Answers 2

1

I found this code, to run artisan commands form route or controller

//Setup route example
Route::get('/myapp/install/{key?}',  array('as' => 'install', function($key = null)
{
    if($key == "appSetup_key"){
    try {
      echo '<br>init migrate:install...';
      Artisan::call('migrate:install');
      echo 'done migrate:install';

      echo '<br>init with Sentry tables migrations...';
      Artisan::call('migrate', [
        '--package'=>'cartalyst/sentry'
        ]);
      echo 'done with Sentry';
      echo '<br>init with app tables migrations...';
      Artisan::call('migrate', [
        '--path'     => "app/database/migrations"
        ]);
      echo '<br>done with app tables migrations';
      echo '<br>init with Sentry tables seader...';
      Artisan::call('db:seed');
      echo '<br>done with Sentry tables seader';
    } catch (Exception $e) {
      Response::make($e->getMessage(), 500);
    }
  }else{
    App::abort(404);
  }
}
}));

From here : http://laravel-tricks.com/tricks/run-artisan-commands-form-route-or-controller

If you have full server access you can simply ssh you server run all commands, here are some links to ssh server

https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server-in-ubuntu

https://mediatemple.net/community/products/dv/204404604/using-ssh-in-putty-

Sign up to request clarification or add additional context in comments.

Comments

0

Some host do not allow php access so Artisan::call cause error. in such of this servers only way is cron jobs : https://laravel.com/docs/5.6/scheduling

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.