Git Product home page Git Product logo

apiexample's Introduction

API example

A simple laravel API example to show CRUD operations

Installation

  • git clone https://github.com/kaikezhang/ApiExample.git ApiExample
  • cd ApiExample
  • composer install
  • cp .env.example .env
  • php artisan key:generate
  • Create a database and inform .env
  • php artisan migrate to create tables
  • php artisan serve to start the app on http://localhost:8000/ or config a web server to start the app

Step to replicate

  • laravel new ApiExample
  • create database and inform .env
  • php artisan make:model Task --migration
  • Edit migration file
  • php artisan migrate
  • Edit routes/api.php
  • Details can be found at this commit

Test with Postman

  • Create a task

    Post $domain/api/tasks insert a name field in body.

  • Show all tasks

    Get $domain/api/tasks

  • Delete a task

    Delete $domain/api/tasks/{id}

  • Update a task

    Put $domain/api/tasks/{id} insert name field in body and select x-www-form-urlencoded.

Add CORS

https://github.com/barryvdh/laravel-cors

apiexample's People

Contributors

kaikezhang avatar

Watchers

James Cloos avatar  avatar

Forkers

ilabutk

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.