Setting Up a Local Development Environment (WIP) - ZTL-ARTCC/Current_Website GitHub Wiki

Local Development Environment

Welcome to the web team! In order to start development, you need to set up a local environment to work with. There are a few changes that need to be made to your code.

.env File

After cloning the repository, you won't have any environment variables defined. To fix this, you need to:

  • Copy .env.example to .env
  • You'll need to have a redirect setup on the VATSIM Development OAuth Organization. I've already created one with the proper URL, however. If you want to create your own redirect, check [url]
  • Set VATSIM_OAUTH_CLIENT to ???. This will be provided by the web team on request.
  • SetVATSIM_OAUTH_SECRET to ???. This will be provided by the web team on request.
  • The last variable to set is VATSIM_OAUTH_BASE to https://auth-dev.vatsim.net, since this is the OAuth URL for VATSIM development.
  • Finally, run php artisan key:generate in your console. This will generate a key and automatically populate it in the .env variable. To confirm this, check the APP_KEY value in your .env file.

RosterUpdate

When your database is created, it has no data in it. In order to populate it, you need to run php artisan RosterUpdate:UpdateRoster. However, at first, this will not work. This is because as a developer, you do not have access to the VATSIM development API. To bypass this, you need to do the following:

  • Goto Http > Controllers > Auth > LoginController.php
  • Find the vatusaAuth() function
  • Change the top of the function to look like below:
protected function vatusaAuth($resourceOwner, $accessToken) {
   $client = new Client();
   $resourceOwner->data->cid = "YOUR_ACTUAL_CID_HERE";
   $resourceOwner->data->personal->email = "[email protected]";
...
}
  • Change "YOUR_ACTUAL_CID_HERE" to be your CID.
  • Scroll down in that same function to:
        $userstatuscheck->fname = $res['fname'];
        $userstatuscheck->lname = $res['lname'];
        $userstatuscheck->email = $res['email'];
        $userstatuscheck->rating_id = $res['rating'];

and replace $res['email']; to $resourceOwner->data->personal->email;

Laratrust

In order to give yourself webmaster permissions, you need to uncomment some code.

  • First, go to routes > web.php
  • At the bottom of the file, uncomment the Laratrust route.
  • Change the CID to your actual CID
  • The function should look like this:
Route::get('/laratrust', function () {
    $user = App\User::find("YOUR_ACTUAL_CID_HERE");

    $user->attachRole('wm');
});
  • Start the application, and visit /laratrust
  • You won't see anything happen, but in the background you were given the wm role. You can now comment out the function again.