These instructions will help you in setup server and mobile application.

Introduction

The app is connected with Laravel 5.5 based CMS using REST APIs, the following documentation will guide you through the process to connect the app with your backend. This guide assumes you have some experience in setting up PHP based web applications and Laravel Framework 5.5.

Setting up the server

  1. Server Requirement

    The server on which you are going to deploy the backend must fulfill the following requirements:

    • PHP >= 7.0.0
    • Mysql 5.7
    • OpenSSL PHP Extension
    • PDO PHP Extension
    • Mbstring PHP Extension
    • Tokenizer PHP Extension
    • XML PHP Extension
  2. Deploying Backend

    Follow these steps:

    • Extract the bustracking.zip on your server
    • For example if your domain is http://bustracking.com then you will be able to access the backend as http://bustracking.com/bustracking/public
  3. Database

    In accompanied source code you will find a sql file named bustracking_multi_production.sql. Create the database and then import the file in your database.

  4. Cron Job

    In order to send pickup/drop reminder to parent when bus is near to location, you will need to setup a cron job on your server. Add the following line to your cron jobs list:

         * * * * * php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1
    
  5. Configuration

    All the major configuration values you will need to set in .env file which is present in root folder of the accompanied source code. Following are the most important values, you may set other values in .env as well if you have experience and requirment to do so:

  • App related:
    • APP_NAME: Title of your app
    • APP_URL: Url of your backend
  • Database related:
    • DB_HOST: Database host, usually it’s localhost
    • DB_PORT: Database port, incase of mysql it’s usually 3306
    • DB_DATABASE: Database Name
    • DB_USERNAME: Database username
    • DB_PASSWORD: Database password
  • Push Notification related:
    • FCM_SERVER_KEY
    • FCM_SENDER_ID
  • Email Related: Email integration is provided with Mailgun, Amazon SES, SMTP. For more details refer to https://laravel.com/docs/5.5/mail. If you are integrating with mailgun, you can simply set following values in .env
    • MAILGUN_DOMAIN
    • MAILGUN_SECRET

    If you need more configuration or advance setting, you can look for keys starting with MAIL_ in .env

  • Logo:
    • APP_LOGO: Enter the url of your logo, this logo will be displayed in backend panel
  • Firebase and Google Services:
    • FIREBASE_ISS: Sample value: https://securetoken.google.com/
    • FIREBASE_DATABASE_URI: Sample value: https://.firebaseio.com/
    • FIREBASE_API_KEY: Sample value: AIzaSyBQgDBgxgMLaf2Xp173VIhuKVzAw_vPXSCyY
    • FIREBASE_AUTH_DOMAIN: Sample value: .firebaseapp.com
    • FIREBASE_PROJECT_ID: Sample value:
    • FIREBASE_STORAGE_BUCKET: Sample value: .appspot.com
    • FIREBASE_SENDER_ID: Sample value: 164929791382

Mobile App

  1. Setup Firebase and Api keys

    • Login to http://console.firebase.google.com
    • Click on “Add project” to add new project -> provide project name as you like and hit Create Project.
    • Now you have to Register apps in this project. Click “Add app” -> choose platform Android
    • Each app has its unique ID known as “Package name” or “ApplicationId”. For more info on how to name one visit https://developer.android.com/studio/build/application-id
    • Enter package name as asked on firebase console(once for Parent’s app and Driver’s app. ps:-sequence doesnt matter).
    • Set a nickname(optional, but we’ll add total of three apps so..)
    • Enter your app signing certificate(Optional but important in order to make otp verification work. here is how to have one -> https://developers.google.com/android/guides/client-auth)
    • Click Register app. Upon succesful registration of app you’ll be provided with your configuration file(google-services.json) for that app.
    • Next click continue or skip to proceed and Repeat this step 1 more times to register app for Driver’s application
    • Upon registering 2 applications in your firebase project you should have 2 applicationIds and 2 configuration files(google-services.json).
    • Navigate to Database section from side menu and choose Real Time Database -> start in test mode -> Enter any dummy value so that the selection stays.
    • Next click on Storage and enable it.
    • Now for api keys visit https://console.cloud.google.com/cloud-resource-manager
    • Select the project you just created in firebase
    • Navigate to “Api and Services” section and click “ENABLE APIS AND SERVICES”
    • Now Search and Enable 3 apis -> maps sdk for android, places sdk for android and directions api.
    • Go to credentails and copy “Android key” and “Browser key”
  2. Download/Setup Java and Android Studio

    • Download Java here: https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
    • Download Android Studio here: https://developer.android.com/studio/
    • Install and restart.
  3. Verify installation

    • Easy steps: https://www.java.com/en/download/help/path.xml
  4. Running project

    • Add configuration files(google-services.json) aquired from step 1 into respective project’s app folder.
    • Open Android studio -> Click on “Open an existing Android Studio project” to navigate and select project.
    • Open and edit app level build.gradle file (app/build.gradle)
    • Set respective applicationId also aquired from firebase console in step 1.
    • Enter Directions api key(Browser key) and Geo/Maps api key(Android key)
    • Lastly app’s name and colors can be changed by changing variables “app_name” and colorPrimary, colorPrimaryDark and colorAccent respectively.
    • Change application’s BASE_URL with your’s in file app/src/main/java/com/project/verbosetech/bustracker/network/ApiUtils.java
    • Android studio will be asking you to Sync project files since build.gradle is modified. Hit “Sync now”
    • Done, now you can build apk from build section in navigation menu.