Skip to content

learnhubmk/api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LearnHub.mk API

Setup using Docker

  1. Install Docker and Docker Compose.
  • Be mindful of which terminal you are using.
  • Tags matching the terminal are provided inside the documentation.
  • [Windows Only] OS Terminal - the terminal native to Windows.
  • [WSL] WSL Terminal - the terminal inside the virtual machine.
  • [Linux / MacOS] OS Terminal - the terminal native to your operating system.
  1. [Windows Only] Install the Linux distro
wsl --install -d Ubuntu-22.04
  1. Enable Ubuntu from Docker Desktop enable ubuntu on docker desktop

  2. [Windows Only] Connect to the WSL Distro Terminal

 wsl --distribution Ubuntu-22.04
  1. [WSL / Linux / MacOS] Go to your home directory, create a folder for your projects (if you don't have one already) and get into it:
cd  ~
mkdir Projects
cd Projects
  1. [WSL / Linux / MacOS] Clone the repository
git clone [email protected]:learnhubmk/api.git
  1. [WSL / Linux / MacOS] Get into your project directory
 cd api
  1. [WSL / Linux / MacOS] Create an .env file by copying .env.docker.example
cp .env.docker.example .env
  1. [WSL / Linux / MacOS] Build up and start the Docker containers
docker compose up --build -d
  1. [WSL / Linux / MacOS] Enter the docker app docker container
docker exec -it LearnHub_app sh 
  1. [Docker Container] Install the Composer dependencies
composer install
  1. [Docker Container] Run all migrations and database seeders
php artisan migrate --seed
  1. [Docker Container] Generate the application key (APP_KEY)
php artisan key:generate
  1. [Docker Container] Generate the JWT secret key (JWT_SECRET)
php artisan jwt:secret
  1. Access the site using http://localhost:8000 in your browser

Additional useful links that you may want to know about:

Regular Setup

  1. Install PHP 8.3 or later

Currently, XAMPP contains PHP 8.2, and may not work.

  1. Install Composer 2.7.1 or later

  2. Clone the repository

git clone https://github.com/learnhubmkd/api.git
  1. Get into your project directory
cd api
  1. Create an .env file by copying .env.example
  • Windows:
xcopy .env.example .env /y /f
  • Linux/Mac:
cp .env.example .env
  • You can modify the .env file to test different configurations.
  1. Install composer dependencies
composer install
  1. Generate an application key (APP_KEY)
php artisan key:generate
  1. Generate the JWT secret key (JWT_SECRET)
php artisan jwt:secret
  1. Run all migrations and database seeders
php artisan migrate --seed
  1. Start the PHP server
php artisan serve
  1. Access the site using http://localhost:8000 in your browser

For the local emails that the API may send, you may want to use something like Mailtrap

For the database UI, you can use PHPMyAdmin, TablePlus, HeidiSQL, or MySQL Workbench.

Packages

PHPStan

  1. run php stan
./vendor/bin/phpstan analyse --memory-limit=2G
  1. run phpStan pro
./vendor/bin/phpstan --pro analyse --memory-limit=2G