GithubHelp home page GithubHelp logo

anthrax3 / cakephp-realworld-example-app Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gothinkster/cakephp-realworld-example-app

0.0 1.0 0.0 507 KB

License: Other

Shell 0.57% Batchfile 0.32% PHP 94.12% CSS 4.98%

cakephp-realworld-example-app's Introduction

CakePHP RealWorld Example App

Build Status GitHub stars GitHub license

Example CakePHP 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 cakephp installation guide for server requirements before you start. Official Documentation

Clone the repository

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

Switch to the repo folder

cd cakephp-realworld-example-app

Install all the dependencies using composer

composer install

Configure your database settings in the config/app.php file(See: Datasource/default)

vi config/app.php

Run the database migrations (Set the database connection in app.php)

bin/cake migrations migrate

Start the local development server

bin/cake server

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

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

bin/cake migrations seed

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

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

How it works


Code overview

Dependencies

Folders

  • src - Contains all the application logic.
  • config - Contains all the application configuration files.
  • src/Model/Entity - Contains all cakephp ORM entites.
  • src/Model/Table - Contains all cakephp ORM tables.
  • app/Service - Contains application services that represents root api endpoints.
  • app/Service/Action - Contains application endpoints logic logic.
  • app/Service/Renderer - Contains the final api response formatter.
  • app/config/Migrations - Contains all the database migrations.

Environment configuration

  • config/app.php - Configuration settings 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 cakephp development server

bin/cake server

The api can now be accessed at

http://localhost:8765/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 cakephp authenticate middleware configured for handling JWT authentication and 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. Please check the following sources to learn more about CORS.

cakephp-realworld-example-app's People

Contributors

alonski avatar ericsimons avatar esakkiraj avatar hiromi2424 avatar skie avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.