GithubHelp home page GithubHelp logo

laravel-api-exmple's Introduction

Laravel-api-example

インストール

  1. リポジトリをクローンする: git clone https://github.com/IESKA2KHobbyLink/Laravel-api-exmple.git
  2. 必要なパッケージをインストールする: composer install
  3. .env.example ファイルを.env にコピーして、データベースの認証情報を更新する
  4. MySQL は autocommit (自動コミットモード)を無効化する方は  autocommit を設定してください。
  5. アプリケーションキーを生成する: php artisan key:generate
  6. データベースマイグレーションを実行する: php artisan migrate
  7. 開発用サーバーを起動する: php artisan serve

Routings

GET /api/users: すべてのユーザーを取得する
GET /api/users/{id}: ユーザーをIDで取得する
POST /api/users: ユーザー制作
PUT /api/users/{id}: IDでユーザーの情報を更新
DELETE /api/users/{id}: IDでユーザー削除する

使い方

例:ブラウザで GET リクエストhttp://localhost:8000

{"Laravel":"10.12.0"}

GET リクエストはブラウザでできるけど POST PUT DELETE は Postman,CURL を使ってください。

例: Curl でPOST

curl -X POST -d "name=user01&[email protected]&password=password" http://localhost:8000/api/users/

戻り値

{
"name":"user01",
"email":"[email protected]",
"updated_at":"2023-05-31T04:47:37.000000Z",
"created_at":"2023-05-31T04:47:37.000000Z",
"id":1
}

IDで確認

curl http//localhost:8000/api/1

戻り値

{
"id":1,
"name":"user01",
"email":"[email protected]",
"email_verified_at":null,
"created_at":"2023-05-31T04:47:37.000000Z",
"updated_at":"2023-05-31T04:47:37.000000Z"
}

laravel-api-exmple's People

Contributors

ec-9624 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.