All Projects → elcobvg → lumen-realworld-example-app

elcobvg / lumen-realworld-example-app

Licence: other
Exemplary real world backend API built with Lumen + MongoDB

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to lumen-realworld-example-app

Laravel Realworld Example App
Exemplary real world backend API built with Laravel
Stars: ✭ 954 (+1808%)
Mutual labels:  crud, demo-app, realworld
laravel-realworld-example-app
Exemplary RealWorld backend API built with Laravel PHP framework.
Stars: ✭ 34 (-32%)
Mutual labels:  crud, demo-app, realworld
lumen-start-app
Boilerplate for laravel/lumen framework https://github.com/laravel/lumen, ready to be used with https://github.com/ionghitun/react-start-app or https://github.com/ionghitun/next-start-app
Stars: ✭ 41 (-18%)
Mutual labels:  lumen, lumen-framework
lumen-api-starter
A starter project to develop API with Lumen 8.*
Stars: ✭ 42 (-16%)
Mutual labels:  lumen, lumen-framework
Cakephp Realworld Example App
Stars: ✭ 103 (+106%)
Mutual labels:  demo-app, realworld
rust-realworld-example-app
Example Rust codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld API spec.
Stars: ✭ 19 (-62%)
Mutual labels:  crud, realworld
servant-beam-realworld-example-app
Exemplary fullstack Medium.com clone powered by Servant and Beam
Stars: ✭ 33 (-34%)
Mutual labels:  crud, realworld
Golang Gin Realworld Example App
Exemplary real world application built with Golang + Gin
Stars: ✭ 1,780 (+3460%)
Mutual labels:  crud, realworld
avo
Ruby on Rails application building framework
Stars: ✭ 907 (+1714%)
Mutual labels:  crud
.NET-Core-Learning-Journey
Some of the projects i made when starting to learn .NET Core
Stars: ✭ 37 (-26%)
Mutual labels:  crud
laravel-lumen-docker
Laravel/Lumen Docker Scaffold
Stars: ✭ 72 (+44%)
Mutual labels:  lumen-framework
cache
Laravel & Lumen Cache Service | File and Redis cache system
Stars: ✭ 19 (-62%)
Mutual labels:  lumen
laravel-crud-generator
Generate a CRUD scaffold with validation rules like a breeze.
Stars: ✭ 137 (+174%)
Mutual labels:  crud
CSJsonDB
A C# package that performs basic CRUD ( Create, Read, Update, Delete ) operations on a Json file, used for sample minimalistic DBs.
Stars: ✭ 75 (+50%)
Mutual labels:  crud
louislam-crud
An easy-to-use CRUD library for you to create a back-end system or RESTful API in a few minutes.
Stars: ✭ 18 (-64%)
Mutual labels:  crud
signature
HMAC and RSA signature for Laravel and Lumen
Stars: ✭ 26 (-48%)
Mutual labels:  lumen
paper-wallet
stellar.github.io/paper-wallet/
Stars: ✭ 41 (-18%)
Mutual labels:  lumen
actix sqlx mysql user crud
A user crud written in Rust, designed to connect to a MySQL database with full integration test coverage.
Stars: ✭ 78 (+56%)
Mutual labels:  crud
vue-js-crud-laravel
Simple CRUD operations using Laravel and Vue.js
Stars: ✭ 27 (-46%)
Mutual labels:  crud
ui
Laravel Livewire & Bootstrap 5 UI & CRUD starter kit.
Stars: ✭ 82 (+64%)
Mutual labels:  crud

RealWorld Example App

Lumen + MongoDB codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.

Demo    RealWorld

This codebase was created to demonstrate a fully functional REST API built with Lumen + MongoDB, including CRUD operations, authentication, routing, pagination, and more.

It borrows heavily from the excellent Laravel implementation by SandeeshS.

For more information on how this works with other frontends/backends, head over to the RealWorld repo.

Hope you'll find this example helpful. Pull requests are welcome!


Getting started

Installation

Please check the official Lumen installation guide for server requirements before you start. Official Documentation

Clone the repository

git clone [email protected]:elcobvg/lumen-realworld-example-app.git

Switch to the repo folder

cd lumen-realworld-example-app

Install all the dependencies using composer

composer install

Copy the example env file and make the required configuration changes in the .env file

cp .env.example .env

Generate a new application key

Since Lumen doesn't have the php artisan key:generate command, there's a custom route http://localhost:8000/appKey to help you generate an application key.

Generate a new JWT authentication secret key

php artisan jwt:secret

Run the database migrations (Set the database connection in .env before migrating)

php artisan migrate

Start the local development server

php -S localhost:8000 -t public

You can now access the server at http://localhost:8000

TL;DR command list

git clone git@elcobvg/lumen-realworld-example-app.git
cd lumen-realworld-example-app
composer install
cp .env.example .env
php artisan key:generate
php artisan jwt:secret 

Make sure you set the correct database connection information before running the migrations Environment variables

php artisan migrate
php -S localhost:8000 -t public

Database seeding

Populate the database with seed data with relationships which includes users, articles, comments, tags, favorites and follows. This can help you to quickly start testing the api or couple a frontend and start using it with ready content.

Run the database seeder and you're done

php artisan db:seed

Note : It's recommended to have a clean database before seeding. You can refresh your migrations at any point to clean the database by running the following command

php artisan migrate:refresh

API Specification

This application adheres to the api specifications set by the Thinkster team. This helps mix and match any backend with any other frontend without conflicts.

Full API Spec

More information regarding the project can be found here https://github.com/gothinkster/realworld


Code overview

Dependencies

  • laravel-mongodb - MongoDB based Eloquent model and Query builder
  • jwt-auth - For authentication using JSON Web Tokens
  • laravel-cors - For handling Cross-Origin Resource Sharing (CORS)

Folders

  • app/Models - Contains all the Eloquent models
  • app/Http/Controllers - Contains all the api controllers
  • app/Http/Middleware - Contains the JWT auth middleware
  • app/Providers - Contains the JWT auth service provider
  • app/RealWorld/Favorite - Contains the files implementing the favorite feature
  • app/RealWorld/Filters - Contains the query filters used for filtering api requests
  • app/RealWorld/Follow - Contains the files implementing the follow feature
  • app/RealWorld/Paginator - Contains the pagination class used to paginate the result
  • app/RealWorld/Slug - Contains the files implementing slugs to articles
  • config - Contains all the application configuration files
  • database/factories - Contains the model factory for all the models
  • database/migrations - Contains all the database migrations
  • database/seeds - Contains the database seeder
  • routes - Contains all the api routes defined in web.php file
  • tests - Contains all the application tests
  • tests/Feature/Api - Contains all the api tests

Environment variables

  • .env - Environment variables can be set in this file

Note : You can quickly set the database information and other variables in this file and have the application fully working.


Testing API

Run the Lumen development server

php -S localhost:8000 -t public

The api can now be accessed at

http://localhost:8000/api

Request headers

Required Key Value
Yes Content-Type application/json
Yes X-Requested-With XMLHttpRequest
Optional Authorization Token {JWT}

Refer the api specification for more info.


Authentication

This applications uses JSON Web Token (JWT) to handle authentication. The token is passed with each request using the Authorization header with Token scheme. The JWT authentication middleware handles the validation and authentication of the token. Please check the following sources to learn more about JWT.


Cross-Origin Resource Sharing (CORS)

This applications has CORS enabled by default on all API endpoints. The CORS allowed origins can be changed by setting them in the config file. Please check the following sources to learn more about CORS.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].