{"id":19845212,"url":"https://github.com/rapidwebltd/php-postcodes","last_synced_at":"2026-03-10T00:31:09.255Z","repository":{"id":56418546,"uuid":"79115768","full_name":"rapidwebltd/php-postcodes","owner":"rapidwebltd","description":"📬 This library handles various UK postcode related tasks","archived":false,"fork":false,"pushed_at":"2020-11-09T09:02:07.000Z","size":28,"stargazers_count":1,"open_issues_count":1,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-08-13T00:01:57.467Z","etag":null,"topics":["php-library","php-postcodes","postcode","postcode-lookup-service","postcode-validation","uk-postcode"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rapidwebltd.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":"2017-01-16T12:22:34.000Z","updated_at":"2018-04-16T12:26:42.000Z","dependencies_parsed_at":"2022-08-15T18:20:34.104Z","dependency_job_id":null,"html_url":"https://github.com/rapidwebltd/php-postcodes","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/rapidwebltd/php-postcodes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapidwebltd%2Fphp-postcodes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapidwebltd%2Fphp-postcodes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapidwebltd%2Fphp-postcodes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapidwebltd%2Fphp-postcodes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rapidwebltd","download_url":"https://codeload.github.com/rapidwebltd/php-postcodes/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapidwebltd%2Fphp-postcodes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30318376,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T20:05:46.299Z","status":"ssl_error","status_checked_at":"2026-03-09T19:57:04.425Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["php-library","php-postcodes","postcode","postcode-lookup-service","postcode-validation","uk-postcode"],"created_at":"2024-11-12T13:06:54.013Z","updated_at":"2026-03-10T00:31:09.233Z","avatar_url":"https://github.com/rapidwebltd.png","language":"PHP","readme":"# PHP Postcodes\n\n[![Build Status](https://travis-ci.org/rapidwebltd/php-postcodes.svg?branch=master)](https://travis-ci.org/rapidwebltd/php-postcodes)\n[![Coverage Status](https://coveralls.io/repos/github/rapidwebltd/php-postcodes/badge.svg?branch=master)](https://coveralls.io/github/rapidwebltd/php-postcodes?branch=master)\n[![StyleCI](https://styleci.io/repos/79115768/shield?branch=master)](https://styleci.io/repos/79115768)\n![Packagist](https://img.shields.io/packagist/dt/rapidwebltd/php-postcodes.svg)\n\nThis library handles various UK postcode related tasks.\n\n## Features\n\n* Address lookup by postcode\n* Postcode validation\n* Generate valid UK postcodes\n* Get a postcode's outward and inward codes\n\n## Installation\n\nTo install, just run the following composer command.\n\n`composer require rapidwebltd/php-postcodes`\n\n## Setup\n\n### Postcode Lookup Services\n\nUsing some of the data retrieval features provided by this library requires a postcode lookup service.\nIt currently supports the following postcode lookup services.\n\n* Ideal Postcodes - https://ideal-postcodes.co.uk\n* Postcode Anywhere (PCA Predict) - https://www.pcapredict.com/\n\nSign up at the respective website if you need to use these features.\n\nYou can then use the following code to get an appropriate postcode lookup service object.\n\n```php\n$postcodeLookupService = new \\RapidWeb\\Postcodes\\Objects\\IdealPostcodes('API_KEY');\n// OR\n$postcodeLookupService = new \\RapidWeb\\Postcodes\\Objects\\PostcodeAnywhere('API_KEY');\n```\n\n## Usage\n\n### Get addresses by postcode\n\nTo retrieve the addresses associated with a UK postcode, just pass it to the method shown below. \nYou will receive an array of address objects, appropriately split by their address lines and other details.\n\n```php\n$addresses = $postcodeLookupService-\u003egetAddressesByPostcode('ST163DP');\n```\n\n### Validate postcode\n\nYou can validate a UK postcode is correct using the `Validator` utility class. An example of \nhow to do so is shown below.\n\n```php\n$validated = \\RapidWeb\\Postcodes\\Utils\\Validator::validatePostcode('ST163DP');\n```\n\nPlease note that the postcode validation is case insensitive.\n\n### Generate postcode\n\nThis library allows you generate a random, valid UK postcode. This makes use of the\n`Generator` utility class, as shown below.\n\n```php\n$postcode = \\RapidWeb\\Postcodes\\Utils\\Generator::generatePostcode();\n```\n\n### Get outward and inward codes\n\n\u003e The first part of the Postcode eg PO1 is called the outward code as it identifies the town or district to which the letter is to be sent for further sorting. The second part of the postcode eg 1EB is called the inward code.\n\n```php\n$outwardCode = \\RapidWeb\\Postcodes\\Utils\\Tokenizer::outward('ST163JR'); // Returns ST16\n$inwardCode = \\RapidWeb\\Postcodes\\Utils\\Tokenizer::inward('ST163JR'); // Returns 3JR\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapidwebltd%2Fphp-postcodes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frapidwebltd%2Fphp-postcodes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapidwebltd%2Fphp-postcodes/lists"}