surpaimb/candy-api

API 驱动的电子商务解决方案,由 getcandy/candy-api 开发的 Laravel 分支

维护者

详细信息

github.com/surpaimb/candy-api

源代码

安装: 8

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 114

类型:项目

v0.1.3 2018-10-27 05:57 UTC

This package is auto-updated.

Last update: 2024-09-16 03:46:37 UTC


README

请注意
虽然已经尽最大努力使此软件准备发布,但它是“现提供”的,目前仍处于早期 alpha 阶段,您使用它需自行承担风险。

这不是一款适合生产的软件

GetCandy 电子商务 API

以 Laravel 方式构建 API 驱动的在线商店。

需求

  • Laravel >= 5.5
  • Elasticsearch >= 6

服务器设置

我们认为使用带有 Elasticsearch 的 Valet+ 是启动的最简单方法。但实际情况由您决定:)

通过 composer 安装

您可以选择只安装 API 或 API 和 Hub。

仅 API

这将包含您通过 API 端点管理商店所需的一切。

composer require getcandy/candy-api

API 和 Hub(推荐)

这将安装 API 和 Hub,因此您有一个很好的界面来管理您的商店。

composer require getcandy/candy-hub

Laravel 5.6

GetCandy 支持包自动发现

Laravel 5.5

将三个必需的服务提供者添加到您的 config/app.php 文件中

'providers' => [
  // ...
  
  GetCandy\Api\Providers\ApiServiceProvider::class,
  GetCandy\Api\Providers\EventServiceProvider::class,
  
  // If you have installed the hub, add this one
  GetCandy\Hub\Providers\HubServiceProvider::class
],

发布配置/资源

API 需要发布一些配置项,而 Hub 需要发布一些资源(如果您使用它)

php artisan vendor:publish --tag=config

// If using the hub
php artisan vendor:publish --tag=public

设置您的用户

GetCandy 没有自己的用户模型,我们认为您可能有自己的模型,所以我们只使用一个特性

use GetCandy\Api\Traits\HasCandy;

class User extends Authenticatable
{
    use HasCandy;

API 使用 passport 进行身份验证,所以请确保您的 config/auth.php 配置使用此功能

这可能会在未来重构为其自己的 gate,这是非包时代的遗留问题...

'guards' => [
  // ...
  
  'api' => [
     'driver' => 'passport',
     'provider' => 'users',
   ]
]

启动并运行

API 需要一些 基本 数据才能启动,目前我们只创建了一个控制台命令来启动

php artisan candy:install

遵循安装步骤,您就可以登录并开始添加产品了!