Skip to content

sgf-web-devs/web-devs-app-backend

Repository files navigation

SGF Web Devs mobile app backed

This project contains the backend services and admin panels for the SGF Web devs mobile app.

The backed is built using the Laravel framework. The framework also serves the admin app, which is made using Angular.

Requirements

Setup

Download Source Code

Let's get a copy of the project code!

Fork the Project Repository

Login to GitHub with your own account, then browse to the repo (Web Devs App Backend) and click the "Fork" button. This will copy the entire project to your account.

Clone your Fork of the Project Repository

This will download your fork of the repository to a sub-folder named "web-devs-app-backend" on your computer. Be sure to replace "<your-github-username" with your GitHub username.

git clone git@github.com:<your-github-username>/web-devs-app-backend.git web-devs-app-backend

Create a Branch

This will create a new branch based on the "master" branch (e.g. feat/2-endpoint-check-in). Any of your code changes will be contained in this branch.

git checkout -b feat/<feature-name-here> origin/master

Development Environment

Let's get the project working on your machine. You will run all of these commands inside the project folder.

Install Composer

Verify you have composer installed on your computer.

composer --version

If the command above returns an error, you can install composer locally to your project directory.

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

Install Laravel dependencies

php composer.phar install

Install Angular dependencies

npm install

or

yarn

Configure Laravel

  1. Copy contents of .env.example to .env

  2. Generate new application key (used for database encryption, etc)

    php artisan key:generate
  3. Generate a new secret key for JWT authentication (Used by the admin app)

    php artisan jwt:secret
  4. Configure a Database. You can safely choose SQLite if you are testing locally, but you must choose MySQL if you are deploying to production.

    • SQLite: Configure Laravel to use sqlite in .env file

      DB_CONNECTION=sqlite
      
    • MySQL: Setup a MySQL server, create an empty MySQL database, create a MySQL user, and update MySQL host, database, username, and password in the .env file.

      DB_CONNECTION=mysql
      DB_HOST=127.0.0.1
      DB_PORT=3306
      DB_DATABASE=homestead
      DB_USERNAME=homestead
      DB_PASSWORD=secret
      
  5. Run Laravel migrate to initialize database tables

    php artisan migrate
  6. Run Laravel database seed to initialize database with sample records

    php artisan db:seed
  7. Run Laravel tinker, then query all User records to verify records were created.

    php artisan tinker
    App\User::all();

Run Local Web Server

This will run backend Laravel app on localhost:8000. You will NOT need to access this port directly.

php artisan serve

This will run backend web interface via node/webpack on localhost:4200. You will browse to this port while developing and testing the web interface and API.

npm start

Development Workflow

Find an open issue and get to work! :) Comment in the issue to let people know you're working on it.

You will begin making changes to your local feature branch. Run git status to verify you are working in your feature branch. You should see a message that says On Branch <branch-name> If you need to switch to your branch, run git checkout <branch-name>.

Commit changes to your local feature branch.

git status
git commit -a

Push changes to your Fork on GitHub

git push

Browse to your branch on GitHub, make sure your commit(s) were pushed to GitHub, then click "Compare and Pull Request", type a Title and Description, then click "Create pull request".

Notes

Most of the app is a standard Laravel project. The only non standard (because there isn't a standard) is the Angular admin app. The root package.json file and .angular-cli.json are for the Angular project and their placement in the root directory allows us to run Angular commands without having to be in the Angular project folder. The rest of the Angular project is contained within resources/assets/angular and when the app is built, the output is copied to public/dist.

For the Laravel app to serve the Angular app, there is a catch all route in routes/web.php that returns public/dist/index.html. We still have the ability to use normal Laravel blade views. We just have to declare their routes before the catch all route.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published