Skip to content

colycao/todo-laravel-dingo-api-swagger

Repository files navigation

「TODOリスト」LaravelでAPI実装

シンプルなAPIは、Laravelで構築されたToDoリストを管理する。

  • TODO(やること)を登録できる
  • 登録したTODOを変更できる
  • 登録したTODOを削除できる
  • 登録されているTODOを一覧で表示できる
  • 登録したTODOの完了状態をメモする

Requirements

PHP 7.3 or higher
Laravel 8.0 or higher

Installation

  1. Clone the repo locally:

    git clone git@github.com:colyii/clara-coly-todo.git
    cd clara-coly-todo
  2. Install dependencies

    composer install
  3. Copy the contents of .env.example to a .env file, or simply run this command:

    # Mac Linux
    cp .env.example .env
    # Windows
    copy .env.example .env
  4. Generate application key (if not already generated)

    php artisan key:generate
  5. Run database migrations

    php artisan migrate
  6. Run database seed

    php artisan db:seed
  7. Run the dev server (the output will give the address):

    php artisan serve --host=127.0.0.1 --port=8000

Running tests

./vendor/bin/pest --filter TodoTest

or

php artisan test

返回结果

// 成功
{
    "success": 1,
    "message": "TODOを表示しました。",
    "status_code": 200,
    "data": {
        "id": 4,
        ...
        "created_at": "2022-08-24 00:12:47",
        "updated_at": "2022-08-24 00:12:47",
        ...
    }
}

// 失败
{
    "success": 0,
    "message": "TODO情報が見つかりませんでした。",
    "status_code": 404
}

Demo

https://todo-laravel-dingo-api-swagger.herokuapp.com/

Pending

  • Add JWT
  • Add Docker