TrapScan backend uses Laravel 8.
You can setup a dev environment using Docker with Laravel Sail.
- Install instructions can be found on the docker website: https://www.docker.com/products/docker-desktop
- Start the Docker Desktop program
- Go through their setup to ensure it's working correctly
- You don't need a docker desktop account ( You can skip the last step )
https://www.virtualmetric.com/blog/how-to-enable-hardware-virtualization
Restart Docker Desktop once the linux kernel is installed
https://docs.docker.com/desktop/windows/wsl/
- SSH:
git clone [email protected]:KurtisPapple/TrapScan-Backend.git
- HTTP:
git clone https://github.com/KurtisPapple/TrapScan-Backend.git
If you're struggling with this you can try use the GitHub Desktop program https://desktop.github.com/
Or clone the repo through VSCode
- Copy the .env.example file to .env
- Update values for your local instance
- https://www.sitepoint.com/how-to-install-php-on-windows/
- https://windows.php.net/download/
- https://getcomposer.org/
- Install WSL2 if you haven't (https://aka.ms/wslkernel)
- Open Windows Terminal in your WSL tab (Ctrl + Shift + 3)
- Setup Git SSH Keys
ssh-keygen
cat ~/.ssh/id_rsa.pub
- Copy this output
- Open your Profile settings in GitHub (where you'd change your password)
- SSH Keys tab
- New SSH Key
- Paste in your key and give it a title
sudo apt-get update
- Reclone the repo inside WSL
sudo apt install php
sudo apt install unzip
- Install PHP extensions. This depends on the version of PHP you installed. The following packages are needed for PHP8
sudo apt install php8.0-gd php8.0-dom php8.0mbstring
- Verify the install with
php --version
- Install composer with Command-line installation ( https://getcomposer.org/ )
- Verify the install with
composer --verion
- Setup docker for use with WSL (https://stackoverflow.com/questions/61592709/docker-not-running-on-ubuntu-wsl-cannot-connect-to-the-docker-daemon-at-unix)
https://laravel.com/docs/8.x/sail
- Open the project in VSCode
- Install any recommenced plugins
- mbstring, json,
- Open a terminal ( https://www.microsoft.com/store/productId/9N0DX20HK701 )
cd trapscan-backend
Or whatever directory you chosephp artisan sail:install
composer install
./vendor/bin/sail up
- Edit ~/.bashrc to add the sail alias
nano ~/.bashrc
- Add
alias sail='bash vendor/bin/sail'
into this file source ~/.bashrc
sail artisan migrate:fresh --seed
http://localhost will be the main app http://localhost:8090 has a phpmyadmin instance (credentials can be found in your .env)
You can load data from any TrapNZ projects you have access to by suppliing your username and password in your .env
GET http://localhost/scrape
TRAP_NZ_USERNAME=your-user-name
TRAP_NZ_PASSWORD=your-password
This will pull all traps and projects you have access to. It will not grab notes or trapline data
To get this additional data you'll need to download the csv trap reports from TrapScan and post the file to the upload route.
Field name "file" is expected. There's a very loose Postman collection available through Dylan or Kurtis.
POST http://localhost/scrape/upload
Headings expected: "Project","ID","Trap line","Trap type","Trap sub type","Date installed","Retired","Sensor ID","Sensor provider","Status","Total kills","Lat","Lon","Notes"
Laravel has the most extensive and thorough documentation and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
If you don't feel like reading, Laracasts can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.