{"id":24678305,"url":"https://github.com/firstclasspostcodes/firstclasspostcodes-php","last_synced_at":"2025-03-21T18:23:37.604Z","repository":{"id":54416107,"uuid":"235794710","full_name":"firstclasspostcodes/firstclasspostcodes-php","owner":"firstclasspostcodes","description":"PHP library for the Firstclasspostcodes API","archived":false,"fork":false,"pushed_at":"2021-02-19T08:35:42.000Z","size":382,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-26T14:48:15.178Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://firstclasspostcodes.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/firstclasspostcodes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-23T12:54:36.000Z","updated_at":"2021-02-19T08:35:44.000Z","dependencies_parsed_at":"2022-08-13T15:00:43.366Z","dependency_job_id":null,"html_url":"https://github.com/firstclasspostcodes/firstclasspostcodes-php","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstclasspostcodes%2Ffirstclasspostcodes-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstclasspostcodes%2Ffirstclasspostcodes-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstclasspostcodes%2Ffirstclasspostcodes-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstclasspostcodes%2Ffirstclasspostcodes-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/firstclasspostcodes","download_url":"https://codeload.github.com/firstclasspostcodes/firstclasspostcodes-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244845424,"owners_count":20519959,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2025-01-26T13:16:35.780Z","updated_at":"2025-03-21T18:23:37.579Z","avatar_url":"https://github.com/firstclasspostcodes.png","language":"PHP","readme":"![Cover](/.github/images/cover.png)\n\n# Firstclasspostcodes\nThe Firstclasspostcodes PHP library provides convenient access to the Firstclasspostcodes API from applications written in the PHP language. It includes pre-defined methods and helpers to help you easily integrate the library into any application.\n\nThe library also provides other features. For example:\n\n* Easy configuration path for fast setup and use.\n* Helpers for listing and formatting addresses.\n* Built-in methods for easily interacting with the Firstclasspostcodes API.\n\n## Documentation\nSee [PHP API docs](https://docs.firstclasspostcodes.com/php/getting-started) for detailed usage and examples.\n\n## Installation\n\nYou can install the bindings via [Composer](http://getcomposer.org/). Run the following command:\n\n```bash\ncomposer require firstclasspostcodes/firstclasspostcodes\n```\n\nTo use the bindings, use Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading):\n\n```php\nrequire_once('vendor/autoload.php');\n```\n\n### Manual Installation\n\nIf you do not wish to use Composer, you can download the [latest release](https://github.com/firstclasspostcodes/firstclasspostcodes-php/releases). Then, to use the bindings, include the `init.php` file.\n\n```php\nrequire_once('/path/to/firstclasspostcodes-php/init.php');\n```\n\n## Requirements\n\nPHP 5.6.0 and later.\n\n## Usage\nThe library needs to be configured with your API key, which is available on the [dashboard](https://dashboard.firstclasspostcodes.com).\n\n```php\n$API_KEY = getenv('API_KEY');\n\n$client = new \\Firstclasspostcodes\\Client(['apiKey' =\u003e $API_KEY ]);\n\n$data = $client-\u003egetPostcode('AB30 1FR');\n\necho json_encode($data, JSON_PRETTY_PRINT);\n```\n\n## Configuration\nThe library can be configured with several options depending on the requirements of your setup:\n\n```php\n$client = new \\Firstclasspostcodes\\Client([\n  # The API Key to be used when sending requests to the \n  # Firstclasspostcodes API\n  'apiKey' =\u003e '3454tyrgdfsew23',\n\n  # The host to send API requests to. This is typically changed\n  # to use the mock service for testing purposes\n  'host' =\u003e \"api.firstclasspostcodes.com\",\n\n  # The default content type is json, but can be changed to \"geo+json\"\n  # to return responses as GeoJSON content type\n  'content' =\u003e \"json\",\n\n  # Typically, always HTTPS, but useful to change for testing\n  # purposes\n  'protocol' =\u003e \"https\",\n\n  # The base path is \"/data\", but useful to change for testing\n  # purposes\n  'basePath' =\u003e \"/data\",\n\n  # The default request timeout for the library.\n  'timeout'=\u003e 30,\n)\n```\n\n## Events\nYou can subscribe to events using an initialized client, passing a function as a handler:\n\n```php\n$client = new \\Firstclasspostcodes\\Client(['apiKey' =\u003e 'dea24tgf' ]);\n\n$client-\u003eon('request', function ($request) {\n  echo json_encode($request, JSON_PRETTY_PRINT);\n});\n```\n\n| Event name | Description |\n|:-----|:-----|\n| `request` | Triggered before a request is sent. The request object to be sent is passed to the event handler. |\n| `response` | Triggered with the parsed JSON response body upon a successful request. |\n| `error` | Triggered with a client error when the request fails. |\n| `operation:{name}` | Triggered by an operation with the parameter object. |\n\n**Note:** `{name}` is replaced with the operation name of the method, as defined inside the OpenAPI specification.\n\n## Integration / Testing\nWe provide a mock service of our API as a docker container [available here](https://github.com/firstclasspostcodes/firstclasspostcodes-mock). Once the container is running, the library can be easily configured to use it:\n\n```php\n$client = new \\Firstclasspostcodes\\Client([\n  'apiKey' =\u003e getenv('MOCK_API_KEY'),\n  'protocol' =\u003e 'http',\n  'host' =\u003e getenv('MOCK_API_HOST'),\n  'basePath' =\u003e '/',\n]);\n\n$client-\u003egetPostcode('AB30 1FR');\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirstclasspostcodes%2Ffirstclasspostcodes-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffirstclasspostcodes%2Ffirstclasspostcodes-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirstclasspostcodes%2Ffirstclasspostcodes-php/lists"}