Download the PHP package awaisjameel/laravel-address-parser without Composer

On this page you can find all versions of the php package awaisjameel/laravel-address-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-address-parser

Laravel Address Parser

Smart, opinionated parsing of single‑line US postal addresses into structured components for Laravel.

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Laravel Address Parser helps you take messy user‑submitted single line US addresses and split them into reliable fields: address1, address2 (unit), city, state, zip and optionally county. It applies pragmatic heuristics—street suffix detection, unit indicator extraction, normalization (whitespace + periods), and validation of state + ZIP formats—without depending on external APIs. Ideal for form ingestion, ETL pipelines, quick data cleanup, and pre‑validation before geocoding.

Not a USPS CASS certified normalizer. It doesn't validate that an address physically exists; it simply parses and validates format.


Table of Contents

  1. Features
  2. Requirements
  3. Installation
  4. Quick Start
  5. Usage Examples
  6. Facade, DI & Helper Patterns
  7. Parsing Logic & Heuristics
  8. County Parsing
  9. Validation Utilities
  10. Formatting Addresses
  11. Configuration
  12. Error Handling
  13. Edge Cases & Limitations
  14. Testing
  15. Performance
  16. Roadmap
  17. Contributing
  18. Security
  19. Support Us
  20. Credits
  21. License

Features


Requirements

Component Version
PHP ^8.2 (tested up to 8.5)
Laravel (illuminate/contracts) ^10, ^11, ^12 or ^13
Extension dependencies ext-mbstring

Installation

Install via Composer:

The package auto‑discovers. No manual provider registration required.

Optional: Publish Config

Currently the config file is a placeholder for future tuning (custom suffixes, unit indicators, etc.). You can publish it now:

Published file at config/address-parser.php:

No migrations or views are shipped (ignore earlier generic template tags).


Quick Start


Usage Examples

1. Basic Parsing (No Commas)

2. Comma‑Separated

3. With County (If Provided)

4. County Method Without County

5. Format Back to One Line

6. Validation Helpers


Facade, DI & Helper Patterns

Because all methods are static, you can call the class directly. A facade alias LaravelAddressParser is registered; if you prefer the facade style:

Dependency injection is not required, but you can wrap this in your own service if you want to enforce non‑static boundaries for test isolation.


Parsing Logic & Heuristics

  1. Normalize input: trim, collapse whitespace, remove trailing punctuation, strip periods after known abbreviations.
  2. Extract trailing STATE ZIP using regex. Validate both.
  3. Before the state/ZIP segment:
    • If no commas: locate rightmost known street suffix, everything after → city.
    • If commas: last comma part → city; remaining → address lines.
  4. Unit detection:
    • Detect explicit unit parts after street suffix (e.g. Apt 4B, #12).
    • Handles units embedded at end of address1 or separated by comma.
  5. Normalizes unit casing (except leading #).
  6. Returns structured array including a nullable county when parsed via county method.

Recognized street suffixes (subset): ST, AVE, RD, DR, LN, CT, CIR, BLVD, PKWY, TRAIL, HWY, WAY, PL, LOOP, TER, EXPY, etc.

Recognized unit indicators: APT, SUITE, STE, UNIT, FLOOR, ROOM, BLDG, #, LOT, SPACE, etc.


County Parsing

Use parseAddressStringWithCounty() for either format:

  1. Street, City, County, ST ZIP
  2. Street, City, ST ZIP (county omitted → county => null)

If fewer than 3 comma‑separated parts exist (excluding state/ZIP) an exception is thrown.


Validation Utilities

Method Purpose
isValidZipCode(string $zip) 5‑digit or ZIP+4 pattern 12345 / 12345-6789
isValidState(string $state) Valid two‑letter US state (inclusive of DC)
getValidStates() Returns internal list of state abbreviations

These do not consult external APIs; they are format checks only.


Formatting Addresses

formatAddress(array $components): string builds a single line string from parsed parts. Missing address2 is skipped; missing address1 results in City, ST ZIP only.


Configuration

Currently no runtime options are exposed. Future versions may allow:

Feel free to open an issue with your use case.


Error Handling

Parsing failures throw Awaisjameel\LaravelAddressParser\AddressParsingException with a human‑readable message. Common triggers:

Always wrap user‑submitted data:


Edge Cases & Limitations

Scenario Behavior
Missing street suffix & no commas Throws exception
City starting like a unit word (Florence, Sterling) Parsed as city (unit words must match exactly)
Excess whitespace Normalized
Periods after abbreviations (St.) Removed
Mixed case units (aPt 4b) Uppercased →APT 4B
Standalone #12 unit Preserved exactly
Non‑US addresses Likely rejected (state + ZIP fail)
Addresses without house number Usually rejected unless suffix detection passes heuristics
PO Boxes Parsed as street if suffix logic permits (e.g.PO BOX 123)

Not a full canonicalizer: it won't expand NW to Northwest, or validate delivery points.


Testing

Run the full test suite (Pest):

Or with coverage:

Static analysis:

Code style (Laravel Pint):


Performance

All operations are in‑memory string functions & a few regex matches. Suitable for real‑time form handling. For bulk ETL (hundreds of thousands of rows) you can batch process safely; memory footprint is minimal.

Micro‑optimizations (e.g. caching compiled regex) are intentionally deferred until a real hotspot is demonstrated.


Roadmap

Have a request? Open an issue.


Contributing

Contributions are welcome! Please:

  1. Fork & create a feature branch
  2. Add/adjust tests for new behavior
  3. Run: composer analyse, composer format, composer test
  4. Open a PR describing rationale & trade‑offs

For architectural changes, open an issue first for discussion.


Security

If you discover a security vulnerability (e.g. pathological regex input leading to DoS), please email the author or open a private advisory. Avoid posting exploits publicly until a fix is released.

This library does not execute external processes or perform network calls, and stores no secrets.


Support Us

If you find this package useful, consider supporting its development make sure to give a star on GitHub!


Credits


License

Released under the MIT License. See LICENSE.md.


FAQ

Does it validate an address actually exists?

No. It validates format only. For existence use USPS, Smarty, Google, etc.

Will it parse multi‑line addresses?

Only single‑line strings. Pre‑join lines ("address1 address2") before parsing, or use the county method if needed.

Why static methods?

Low ceremony; no state. You can wrap them if you prefer dependency injection.

Is the heuristics list exhaustive?

It covers common US street suffixes & unit indicators. You can extend in the future via config once exposed.

Can I disable normalization?

Not yet. Planned via config.


Example End‑to‑End Form Handling


Happy parsing! 📨


All versions of laravel-address-parser with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-mbstring Version *
spatie/laravel-package-tools Version ^1.92.7
illuminate/contracts Version ^10.0||^11.0||^12.0||^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package awaisjameel/laravel-address-parser contains the following files

Loading the files please wait ...