All Projects → gothinkster → Laravel Realworld Example App

gothinkster / Laravel Realworld Example App

Licence: mit
Exemplary real world backend API built with Laravel

Projects that are alternatives of or similar to Laravel Realworld Example App

Cakephp Realworld Example App
Stars: ✭ 103 (-89.2%)
Mutual labels:  rest-api, demo-app, realworld, backend
laravel-realworld-example-app
Exemplary RealWorld backend API built with Laravel PHP framework.
Stars: ✭ 34 (-96.44%)
Mutual labels:  crud, backend, demo-app, realworld
Golang Gin Realworld Example App
Exemplary real world application built with Golang + Gin
Stars: ✭ 1,780 (+86.58%)
Mutual labels:  realworld, crud, jwt
Sleepingowladmin
🦉 Administrative interface builder for Laravel (Laravel admin)
Stars: ✭ 671 (-29.66%)
Mutual labels:  laravel, crud, backend
Node Typescript Koa Rest
REST API boilerplate using NodeJS and KOA2, typescript. Logging and JWT as middlewares. TypeORM with class-validator, SQL CRUD. Docker included. Swagger docs, actions CI and valuable README
Stars: ✭ 739 (-22.54%)
Mutual labels:  rest-api, crud, jwt
Laravel Api Starter
laravel5.5 + dingo/api + JWT
Stars: ✭ 85 (-91.09%)
Mutual labels:  rest-api, laravel, jwt
Haskell Yesod Realworld Example App
Exemplary real world application built with Haskell + Yesod
Stars: ✭ 134 (-85.95%)
Mutual labels:  rest-api, crud, jwt
Yii2 Angular Boilerplate
Yii2 REST API + Angular10 Boilerplate (Frontend/Backend)
Stars: ✭ 194 (-79.66%)
Mutual labels:  rest-api, jwt, backend
lumen-realworld-example-app
Exemplary real world backend API built with Lumen + MongoDB
Stars: ✭ 50 (-94.76%)
Mutual labels:  crud, demo-app, realworld
Dj Rest Auth
Authentication for Django Rest Framework
Stars: ✭ 491 (-48.53%)
Mutual labels:  rest-api, jwt
Notykt
📒 NotyKT is a complete 💎Kotlin-stack (Backend + Android) 📱 application built to demonstrate the use of Modern development tools with best practices implementation🦸.
Stars: ✭ 543 (-43.08%)
Mutual labels:  rest-api, backend
Beauty Vuejs Boilerplate
❤️ Real world base Vue.js app. Access/refresh tokens auth, api services, http client, vuex modules
Stars: ✭ 583 (-38.89%)
Mutual labels:  realworld, jwt
Laravel Orion
The simplest way to create REST API with Laravel
Stars: ✭ 481 (-49.58%)
Mutual labels:  rest-api, laravel
Cerberus
A demonstration of a completely stateless and RESTful token-based authorization system using JSON Web Tokens (JWT) and Spring Security.
Stars: ✭ 482 (-49.48%)
Mutual labels:  rest-api, jwt
Full Stack Fastapi Postgresql
Full stack, modern web application generator. Using FastAPI, PostgreSQL as database, Docker, automatic HTTPS and more.
Stars: ✭ 7,635 (+700.31%)
Mutual labels:  jwt, backend
Vuetify Admin Dashboard
A Crud Admin panel made from Vue js and Vuetify
Stars: ✭ 481 (-49.58%)
Mutual labels:  rest-api, crud
Laravel Vue Boilerplate
🐘 A Laravel 6 SPA boilerplate with a users CRUD using Vue.js 2.6, GraphQL, Bootstrap 4, TypeScript, Sass, and Pug.
Stars: ✭ 472 (-50.52%)
Mutual labels:  laravel, jwt
Osu Web
the browser-facing portion of osu!
Stars: ✭ 610 (-36.06%)
Mutual labels:  laravel, backend
Elixir Phoenix Realworld Example App
Exemplary real world application built with Elixir + Phoenix
Stars: ✭ 764 (-19.92%)
Mutual labels:  realworld, backend
Angular5.2 Laravel5.6
Angular 5.2 and Laravel 5.6 Authentication and CRUD
Stars: ✭ 17 (-98.22%)
Mutual labels:  laravel, crud

Laravel Example App

Build Status Gitter GitHub stars GitHub license

Example Laravel codebase containing real world examples (CRUD, auth, advanced patterns and more) that adheres to the RealWorld spec and API.

This repo is functionality complete — PRs and issues welcome!


Getting started

Installation

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

Alternative installation is possible without local dependencies relying on Docker.

Clone the repository

git clone [email protected]:gothinkster/laravel-realworld-example-app.git

Switch to the repo folder

cd laravel-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

php artisan key:generate

Generate a new JWT authentication secret key

php artisan jwt:generate

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

php artisan migrate

Start the local development server

php artisan serve

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

TL;DR command list

git clone [email protected]:gothinkster/laravel-realworld-example-app.git
cd laravel-realworld-example-app
composer install
cp .env.example .env
php artisan key:generate
php artisan jwt:generate 

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

php artisan migrate
php artisan serve

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.

Open the DummyDataSeeder and set the property values as per your requirement

database/seeds/DummyDataSeeder.php

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

Docker

To install with Docker, run following commands:

git clone [email protected]:gothinkster/laravel-realworld-example-app.git
cd laravel-realworld-example-app
cp .env.example.docker .env
docker run -v $(pwd):/app composer install
cd ./docker
docker-compose up -d
docker-compose exec php php artisan key:generate
docker-compose exec php php artisan jwt:generate
docker-compose exec php php artisan migrate
docker-compose exec php php artisan db:seed
docker-compose exec php php artisan serve --host=0.0.0.0

The api can be accessed at http://localhost:8000/api.

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

  • jwt-auth - For authentication using JSON Web Tokens
  • laravel-cors - For handling Cross-Origin Resource Sharing (CORS)

Folders

  • app - Contains all the Eloquent models
  • app/Http/Controllers/Api - Contains all the api controllers
  • app/Http/Middleware - Contains the JWT auth middleware
  • app/Http/Requests/Api - Contains all the api form requests
  • 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/Paginate - Contains the pagination class used to paginate the result
  • app/RealWorld/Slug - Contains the files implementing slugs to articles
  • app/RealWorld/Transformers - Contains all the data transformers
  • 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 api.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 laravel development server

php artisan serve

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 default configuration allows requests from http://localhost:3000 and http://localhost:4200 to help speed up your frontend testing. 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].