https://github.com/kb-web-development/lumen-api
Lumen framework v.11 sample API project calling instructors, students, courses and courses ratings resources
https://github.com/kb-web-development/lumen-api
Last synced: 3 months ago
JSON representation
Lumen framework v.11 sample API project calling instructors, students, courses and courses ratings resources
- Host: GitHub
- URL: https://github.com/kb-web-development/lumen-api
- Owner: KB-WEB-DEVELOPMENT
- License: mit
- Created: 2024-09-16T04:58:49.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-09-19T04:45:57.000Z (9 months ago)
- Last Synced: 2025-01-21T04:07:56.960Z (5 months ago)
- Language: PHP
- Size: 421 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
#### Lumen framework API sample project
[1. Introduction](#introduction)[2. REST API endpoints by user type](#rest-api-by-user-type)
[3. Database Schema](#database-schema)
[4. Installation](#installation)
[5. Dealing with authentication within Lumen framework](#authentication)
[6. Dependencies](#dependencies)
#### [1. Introduction](#introduction)
The API can access resources which relate to (1) instructors, (2) students, (3) courses and (4) courses ratings by students.
#### [2. REST API endpoints by user type](#rest-api-by-user-type)
**(1/4) REST API endpoints available to any unauthenticated user**
|URI|Method|Description|
|------|------|------|
|/api/v1/instructors|GET|retrieves all instructors|
|/api/v1/students|GET|retrieves all students|
|/api/v1/courses|GET|retrieves all courses|
|/api/v1/instructors/stats|GET|retrieves all instructors related stats|
|/api/v1/instructors/:instructorId|GET|retrieves instructor with instructor id :instructorId|
|/api/v1/students/:studentId|GET|retrieves student with student id :studentId|
|/api/v1/courses/:courseId|GET|retrieves course with course id :courseId|
|/api/v1/instructors/:instructorId/stats|GET|retrieves stats of the instructor with instructor id :instructorId|**(2/4) REST API endpoints available to any authenticated user with neither an instructor profile nor a student profile**
|URI|Method|Description|
|------|------|------|
|/api/v1/instructors/create|POST|creates a new instructor profile|
|/api/v1/students/create|POST|creates a new student profile|> Note: An authenticated user can have either one instructor profile or one student profile (not both).
**(3/4) REST API endpoints available to any authenticated user with an instructor profile**
|URI|Method|Description|
|------|------|------|
|/api/v1/instructors/update|PUT|lets the authenticated instructor update his/her instructor profile|
|/api/v1/instructors/delete|DELETE|lets the authenticated instructor delete his/her instructor profile|
|/api/v1/instructors/courses/create|POST|lets the authenticated instructor create a new course|
|/api/v1/instructors/courses/:courseId/update|PUT|lets the authenticated instructor update course with course id :courseId if he/she created it|
|/api/v1/instructors/courses/:courseId/delete|DELETE|lets the authenticated instructor delete course with course id :courseId if he/she created it|**(4/4) REST API endpoints available to any authenticated user with a student profile**
|URI|Method|Description|
|------|------|------|
|/api/v1/students/update|PUT|lets the authenticated student update his/her student profile|
|/api/v1/students/delete|DELETE|lets the authenticated student delete his/her student profile|
|/api/v1/students/courses/:courseId/rating/create|POST|lets the authenticated student rate course with course id :courseId|#### [3. Database Schema](#database-schema)

#### [4. Installation](#installation)
##### 1. Clone the repository
`git clone https://github.com/KB-WEB-DEVELOPMENT/lumen-api.git`
##### 2. cd into the project
`cd lumen-api`
##### 3. Install composer dependencies
`composer install`
##### 4. Install NPM dependencies
`npm install`
##### 5. Copy the .env file
`cp .env.example .env`
##### 6. Generate an app encryption key
`php artisan key:generate`
##### 7. Create an empty database for the application
Create an empty database for your project using the database tools you prefer (phpmyadmin, datagrip, or any other mysql client).
##### 8. In the .env file, add the database information to allow Laravel to connect to the database
In the .env file, fill in the **DB_HOST**, **DB_PORT**, **DB_DATABASE**, **DB_USERNAME**, and **DB_PASSWORD** keys to match the credentials of the database you just created.
##### 9. Migrate the database
`php artisan migrate`
##### 10. Run seeders
Available seeders: UserSeeder, InstructorSeeder, StudentSeeder, CourseSeeder, CourseRatingSeeder, DatabaseSeeder.
You can either run (a) specific one(s) or all of them at once with:
`php artisan db:seed --class=DatabaseSeeder`
This will create 2 instructors, 2 students (4 authenticable users in total), 2 courses and one course rating for each course (2 courses ratings in total).
##### During Development
##### 11. Compile assets`npm run dev`
`npm run watch`
##### 12. Local development serveTo run a local development server, you may run the following command. This will start a development server at **http://localhost:8000**
`php artisan serve`
##### [5. Dealing with authentication within Lumen framework](#authentication)
Lumen documentation on authentication is rather meagre but
the two links below are enough:https://lumen.laravel.com/docs/11.x/authentication
https://www.cloudways.com/blog/lumen-rest-api-authentication/
##### [6. Dependencies](#dependencies)
`vlucas/phpdoten`
`league/fractal`
`fzaninotto/fake`
`phpunit/phpunit`
`mockery/mockery`