{"id":37009437,"url":"https://github.com/knocklabs/knock-php","last_synced_at":"2026-01-14T00:53:38.835Z","repository":{"id":62550171,"uuid":"491286203","full_name":"knocklabs/knock-php","owner":"knocklabs","description":"Official PHP SDK for interacting with the Knock API.","archived":false,"fork":false,"pushed_at":"2025-06-11T16:46:59.000Z","size":54,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-09-24T06:09:43.223Z","etag":null,"topics":["knock","php"],"latest_commit_sha":null,"homepage":"","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/knocklabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-11T22:11:20.000Z","updated_at":"2025-06-11T16:47:03.000Z","dependencies_parsed_at":"2025-03-10T14:43:46.792Z","dependency_job_id":null,"html_url":"https://github.com/knocklabs/knock-php","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/knocklabs/knock-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knocklabs%2Fknock-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knocklabs%2Fknock-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knocklabs%2Fknock-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knocklabs%2Fknock-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knocklabs","download_url":"https://codeload.github.com/knocklabs/knock-php/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knocklabs%2Fknock-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28407483,"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":["knock","php"],"created_at":"2026-01-14T00:53:36.422Z","updated_at":"2026-01-14T00:53:38.130Z","avatar_url":"https://github.com/knocklabs.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Knock PHP library\n\n## Documentation\n\nSee the [documentation](https://docs.knock.app) for PHP usage examples.\n\n## Installation\n\n```bash\ncomposer require knocklabs/knock-php php-http/guzzle7-adapter\n```\n\n## Configuration\n\nTo use the library you must provide a secret API key, provided in the Knock dashboard.\n\n```php\nuse Knock\\KnockSdk\\Client;\n\n$client = new Client('sk_12345');\n```\n\n## Usage\n\n### Identifying users\n\n```php\n$client-\u003eusers()-\u003eidentify('jhammond', [\n    'name' =\u003e 'John Hammond',\n    'email' =\u003e 'jhammond@ingen.net',\n]);\n```\n\n### Sending notifies (triggering workflows)\n\n```php\n$client-\u003eworkflows()-\u003etrigger('dinosaurs-loose', [\n    // user id of who performed the action\n    'actor' =\u003e 'dnedry',\n    // list of user ids for who should receive the notification\n    'recipients' =\u003e ['jhammond', 'agrant', 'imalcolm', 'esattler'],\n    // data payload to send through\n    'data' =\u003e [\n        'type' =\u003e 'trex',\n        'priority' =\u003e 1,\n    ],\n    // an optional identifier for the tenant that the notifications belong to\n    'tenant' =\u003e 'jurassic-park',\n    // an optional key to provide to cancel a notify\n    'cancellation_key' =\u003e '21e958bb-2517-40bb-aaaa-d40acc26dac3',\n]);\n```\n\n### Retrieving users\n\n```php\n$client-\u003eusers()-\u003eget('jhammond');\n```\n\n### Deleting users\n\n```php\n$client-\u003eusers()-\u003edelete('jhammond');\n```\n\n### Preferences\n\n```php\n$client-\u003eusers()-\u003esetPreferences('jhammond', [\n    'channel_types' =\u003e [\n        'email' =\u003e true, \n        'sms' =\u003e false,\n    ],\n    'workflows' =\u003e [\n        'dinosaurs-loose' =\u003e [\n            'email' =\u003e false, \n            'in_app_feed': true,\n        ]\n    ]\n]);\n```\n\n### Getting and setting channel data\n\n```php\n$knock-\u003eusers()-\u003esetChannelData('jhammond', '5a88728a-3ecb-400d-ba6f-9c0956ab252f', [\n    'tokens' =\u003e [\n        $apnsToken\n    ],\n});\n\n$knock-\u003eusers()-\u003egetChannelData('jhammond', '5a88728a-3ecb-400d-ba6f-9c0956ab252f');\n```\n\n### Canceling workflows\n\n```php\n$client-\u003eworkflows()-\u003ecancel('dinosaurs-loose', [\n    'cancellation_key' =\u003e '21e958bb-2517-40bb-aaaa-d40acc26dac3'\n    // optionally you can specify recipients here\n    'recipients' =\u003e ['jhammond'],\n]);\n```\n\n### Signing JWTs\n\nYou can use the `firebase/php-jwt` package to [sign JWTs easily](https://github.com/firebase/php-jwt).\nYou will need to generate an environment specific signing key, which you can find in the Knock dashboard.\n\nIf you're using a signing token you will need to pass this to your client to perform authentication.\nYou can read more\nabout [client-side authentication here](https://docs.knock.app/client-integration/authenticating-users).\n\n```php\nuse Firebase\\JWT\\JWT;\n\n$privateKey = env('KNOCK_SIGNING_KEY');\n$encoded = JWT::encode(['sub' =\u003e 'jhammond'], $privateKey, 'RS256');\n```\n\n## Test\nTo run tests, first run `composer` in the terminal. Once compiled, you can run `phpunit tests/` to run the suite.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknocklabs%2Fknock-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknocklabs%2Fknock-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknocklabs%2Fknock-php/lists"}