obtao / recombeebundle
A bundle to interact with symfony and recombee API
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 2
Type:symfony-bundle
Requires
- php: >=7.1.0
- guzzle/guzzle: ~3.9
- jms/serializer-bundle: ^1.2
- symfony/symfony: ~2.8
This package is auto-updated.
Last update: 2024-10-18 15:29:03 UTC
README
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require "obtao/recombeebundle:dev-master"
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles,
in the app/AppKernel.php
file of your project:
This bundle rely on JMS serializer as dependency, so if you are not using it yet, you have to add it too.
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new \Obtao\RecombeeBundle\ObtaoRecombeeBundle(), new \JMS\SerializerBundle\JMSSerializerBundle() // only if you are not using it yet ); // ... } // ... }
Step 3: Config the Bundle
// app/config.yml obtao_recombee: recombee_database_name: "your-database-name" recombee_secret_token: "your-api-key"
Step 4: Usage
Below example of usage in symfony controller to create a user and related properties.
Bundle provide 2 custom model (for user and item), feel free to modify according your needs.
BatchBuilder helper will extract all properties of such item to guess the best type for recombee API (need to implements HasSkuInterface)
<?php namespace AppBundle\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use \Obtao\RecombeeBundle as ObtaoRecombee; class DefaultController extends Controller { /** * @Route("/", name="homepage") */ public function indexAction() { // service to reach API $apiCaller = $this->get('obtao.recombee.api.caller'); // Helper to build batch of properties $batchBuilder = $this->get('obtao.recombee.batch.builder'); // reset database first (be careful !) : expected response "ok" $reset = var_dump($apiCaller->sendToApi(new ObtaoRecombee\Model\ResetDatase())); // create a new User $user = new ObtaoRecombee\Model\User(); $user->setSku(12345); $user->setNickName('JohnDoe'); $user->setOriginCountry('FR'); // use batch helper to build all properties for user above /** @var Batch $batch */ $batch = $batchBuilder->buildBatchOfProperties($user, ObtaoRecombee\Model\AddUserProperty::class); // send batch of properties to API : expected response batch of "ok" var_dump($apiCaller->sendToApi($batch)); // create user : expected response "ok" var_dump($apiCaller->sendToApi(new ObtaoRecombee\Model\SetUserValues($user))); die('that\'s all folks'); } }