{"id":36388793,"url":"https://github.com/peterfox/graphaware-reco-client-php","last_synced_at":"2026-01-14T01:31:18.495Z","repository":{"id":57038156,"uuid":"44457248","full_name":"peterfox/graphaware-reco-client-php","owner":"peterfox","description":"A configurable PHP library for fetching recommendations from a GraphAware Recommendation setup","archived":true,"fork":false,"pushed_at":"2015-10-18T00:37:17.000Z","size":156,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-13T09:38:00.025Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peterfox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-17T22:40:01.000Z","updated_at":"2024-01-21T13:57:02.000Z","dependencies_parsed_at":"2022-08-24T05:51:09.973Z","dependency_job_id":null,"html_url":"https://github.com/peterfox/graphaware-reco-client-php","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/peterfox/graphaware-reco-client-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterfox%2Fgraphaware-reco-client-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterfox%2Fgraphaware-reco-client-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterfox%2Fgraphaware-reco-client-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterfox%2Fgraphaware-reco-client-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peterfox","download_url":"https://codeload.github.com/peterfox/graphaware-reco-client-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterfox%2Fgraphaware-reco-client-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408293,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T00:40:43.272Z","status":"ssl_error","status_checked_at":"2026-01-14T00:40:42.636Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-11T15:07:54.348Z","updated_at":"2026-01-14T01:31:18.487Z","avatar_url":"https://github.com/peterfox.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"GraphAware-Reco client for PHP\n------------------------------\n\nThe client is designed to work in turning recommendations and scores from a GraphAware Recommendation endpoint into objects\nthat are easy to work with.\n\nThe current implementation uses Guzzle but can easily build your own to work with any HTTP client library.\n\nInstall\n=======\n\nUse composer to get the package\n\n```ssh\ncomposer require peterfox/graphaware-reco-client\n```\n\nBasic Setup\n===========\n\nA basic example can use the common implementations of the interfaces set out but it's easy to create your own or extend the common\nones to make it work with your own tweaks to the recommendations end point you've created.\n\n```php\nuse GraphAwareReco\\Bridge\\Guzzle\\Client;\nuse GraphAwareReco\\Bridge\\Guzzle\\RecommendationDescriptionBuilder;\nuse GraphAwareReco\\Domain\\Common\\RecommendationFactory;\nuse GraphAwareReco\\Domain\\Common\\RecommendationService;\nuse GraphAwareReco\\Domain\\Common\\JsonResponseParser;\nuse GuzzleHttp\\Client as Guzzle;\nuse GuzzleHttp\\Command\\Guzzle\\GuzzleClient;\n\n$service = new RecommendationService('http://localhost:7474/');\n\n$description = RecommendationDescriptionBuilder::getDescriptionFromService($service);\n\n$guzzle = new GuzzleClient(new Guzzle(), $description, ['defaults' =\u003e []]);\n\n$client = new Client($guzzle, new RecommendationFactory(), new JsonResponseParser());\n```\n\nYou can then just supply a parameter array to fetch a set of recommendations\n\n```php\n$recommendations = $client-\u003egetRecommendations(['id' =\u003e 1, 'limit' =\u003e 30]);\n```\n\nImplement your own service\n==========================\n\nYou can implement your own setup as needed, the common classes are mainly for examples and because they cover how most\ndevelopers would set up a recommendation endpoint for their service.\n\n###Create a recommendation service\n\nThe purpose of the RecommendationService interface is to simply state the uri for the endpoint and any arguments that\nyou'll use for to request your recommendations.\n\n```php\nuse GraphAwareReco\\Domain\\Model\\RecommendationService as RecommendationServiceInterface;\n\nclass RecommendationService implements RecommendationServiceInterface\n{\n    /**\n     * @var string\n     */\n    private $baseUrl;\n\n    /**\n     * @param string $baseUrl\n     */\n    public function __construct($baseUrl)\n    {\n        $this-\u003ebaseUrl = $baseUrl;\n    }\n\n    /**\n     * @return string\n     */\n    public function getBaseUrl()\n    {\n        return $this-\u003ebaseUrl;\n    }\n\n    /**\n     * @return array\n     */\n    public function getUriParameters()\n    {\n        return ['id' =\u003e 'string'];\n    }\n\n    /**\n     * @return array\n     */\n    public function getQueryParameters()\n    {\n        return ['limit' =\u003e 'string'];\n    }\n\n    /**\n     * @return string\n     */\n    public function getRecommendationPath()\n    {\n        return '/graphaware/recommendation/{id}';\n    }\n}\n```\n\n###Create a response parser\n\nOverall the response parser is simply used as a way of taking the json as an array and breaking it down into an array of recommendations.\nBy default most setups will just be an array of recommendations already so nothing happens in the common example but if\nyou need to change that you can.\n\n```php\nuse GraphAwareReco\\Domain\\Model\\JsonResponseParser as ResponseParserInterface;\n\nclass JsonResponseParser implements ResponseParserInterface\n{\n\n    /**\n     * @param array $result\n     * @return array\n     */\n    public function parse(array $result)\n    {\n        return $result;\n    }\n}\n```\n\n###Create a recommendation model\n\nYour models might differ from the common example as each recommendation might provide more details about the nodes it's\nrecommending, as such you can implement your own.\n\n```php\nuse GraphAwareReco\\Domain\\Model\\Recommendation as RecommendationInterface;\nuse GraphAwareReco\\Domain\\Model\\Score;\n\nclass Recommendation implements RecommendationInterface\n{\n    /**\n     * @var\n     */\n    private $identifier;\n    /**\n     * @var\n     */\n    private $uuid;\n    /**\n     * @var\n     */\n    private $score;\n\n    public function __construct($identifier, $uuid, $score)\n    {\n        $this-\u003eidentifier = $identifier;\n        $this-\u003euuid = $uuid;\n        $this-\u003escore = $score;\n    }\n\n    /**\n     * @return string\n     */\n    public function getUUID()\n    {\n        return $this-\u003euuid;\n    }\n\n    /**\n     * @return mixed\n     */\n    public function getItemIdentifier()\n    {\n        return $this-\u003eidentifier;\n    }\n\n    /**\n     * @return Score\n     */\n    public function getScore()\n    {\n        $this-\u003escore;\n    }\n}\n```\n\n###Create a recommendation factory\n\nIf you have made your own recommendation models you'll need to implement a factory for the client to initiate an instance\nof it using the date for each recommendation.\n\n```php\nuse GraphAwareReco\\Domain\\Common\\Recommendation as RecommendationImpl;\nuse GraphAwareReco\\Domain\\Model\\Recommendation;\nuse GraphAwareReco\\Domain\\Model\\RecommendationFactory as RecommendationFactoryInterface;\nuse GraphAwareReco\\Domain\\Model\\Score;\n\nclass RecommendationFactory implements RecommendationFactoryInterface\n{\n    /**\n     * @param array $data\n     * @return Recommendation\n     */\n    public function getRecommendation(array $data)\n    {\n        return new RecommendationImpl($data['id'], $data['uuid'], Score::fromArray($data['score']));\n    }\n}\n```\n\nTesting\n=======\n\nThere's some basic testing you can run for the library, namely PHPSpec and Behat. To run the behat tests you must also run\nthe tutu server to emulate a GraphAware Reco setup.\n\n###Run tutu\n```\ncd tutu \u0026\u0026 php -S localhost:7474 -t web -d date.timezone=UTC\n```\n\n###Run behat:\n```\nbin/behat\n```\n\n###Run phpspec:\n```\nbin/phpspec\n```\n\n[Peter Fox]:http://www.peterfox.me","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterfox%2Fgraphaware-reco-client-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeterfox%2Fgraphaware-reco-client-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterfox%2Fgraphaware-reco-client-php/lists"}