Installation

The GetCandy API a REST API for your online store, making it easy to consume with any front end imaginable

Requirements

  • Laravel 5.7
  • Elasticsearch 6.*

Install via composer

For a new project, we need to pull in the correct version of Laravel

$ composer create-project laravel/laravel="5.7.*" my-webstore

API Installation

Once we're in the project root, install via composer.

$ composer require getcandy/candy-api

Once done, publish the config.

$ php artisan vendor:publish --tag=config

Migrations and Traits

Before we can use GetCandy we need to add the HasCandy trait to our user…

<?
  namespace App;

  use GetCandy\Api\Core\Traits\HasCandy;

  class User extends Authenticatable
  {
      use HasCandy;
      // ...
  }

Now we are ready to install, run the install command:

php artisan candy:install

Candy Install

Initialise the search index

php artisan candy:search:index

This will create the search index and get everything set up so we can start adding/searching products.

Authentication

GetCandy uses Passport to deal with authentication, we just need to tell Laravel we want to use it for API authentication, so in config/auth.php the guards should look like this:

'guards' => [
  'web' => [
    'driver' => 'session',
    'provider' => 'users',
  ],
  'api' => [
    'driver' => 'passport',
    'provider' => 'users',
  ],
],

Link up storage

Make sure that you link up your storage directory if you are using the default asset storage.

$ php artisan storage:link

Hub Installation

Make sure you're in the project root and run

$ composer require getcandy/candy-hub

Once done, publish the assets

$ php artisan vendor:publish --tag=public

That'be able to visit the hub by going to /hub and log in, there you will see the dashboard

GetCandy Hub