Installing GetCandy from scratch

This is a guide to get you up and running with GetCandy. I’m going to assume you know a thing or two about Laravel and setting up third-party packages.

For this, I’ll be using Valet+ for my development machine, but you’re free to use whatever you want

Initial Steps

So initially we want to install Laravel 5.7 and then pull in the API, we’ll worry about the Hub later.

$ laravel new online-store

Once that’s installed, we can then install the API.

$ cd online-store && composer require "getcandy/candy-api":"0.2.*"

Once done, publish the config.

$ php artisan vendor:publish --tag=config

Remember to set up your database.

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;
  use Illuminate\Notifications\Notifiable;
  use Illuminate\Contracts\Auth\MustVerifyEmail;
  use Illuminate\Foundation\Auth\User as Authenticatable;

  class User extends Authenticatable
      use Notifiable, HasCandy;
      * The attributes that are mass assignable.
      * @var  array
      protected $fillable = [
          'name', 'email', 'password',
      * The attributes that should be hidden for arrays.
      * @var  array
      protected $hidden = [
          'password', 'remember_token',

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

php artisan candy:install

Candy Install


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',

Hooray! we have successfully installed GetCandy!

If you just want to use the API we’re all done, otherwise, we can also install the Hub to manage our store.

Installing the Hub

The Candy Hub provides a UI for you to manage all aspects of your store, it’s where you can care for your products, see your orders and build your categories, it’s a great tool and easy to install.

To get started, let's pull in the package:

composer require "getcandy/candy-hub":"0.2.*"

Once installed, we just need to publish the public resources, so we get some styling on the hub.

php artisan vendor:publish --tag=public

With that, just go to /hub and you should see the login screen.

GetCandy Login

Put the credentials you used when you went through the API installation and you should be able to log in. You will then be on the Dashboard page.

GetCandy Login

Wrapping up

So we’ve managed to get the API installed and the Hub up and running, we’ll leave it here for now, but we will look at products, categories etc in more detail in another post. For now just feel free to click around and get a feel for it.