PHPackages                             alexpechkarev/laravel-places-autocomplete - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. alexpechkarev/laravel-places-autocomplete

ActiveLibrary[Templating &amp; Views](/categories/templating)

alexpechkarev/laravel-places-autocomplete
=========================================

Easily integrate the Places (New) Autocomplete - JavaScript library into Laravel Blade views. Provides a user-friendly way to search for and retrieve detailed address information in any web application.

1.0.2(10mo ago)1292↓33.3%MITJavaScriptPHP ^7.4|^8.0

Since Jun 22Pushed 10mo agoCompare

[ Source](https://github.com/alexpechkarev/laravel-places-autocomplete)[ Packagist](https://packagist.org/packages/alexpechkarev/laravel-places-autocomplete)[ RSS](/packages/alexpechkarev-laravel-places-autocomplete/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

Places Autocomplete for Laravel
===============================

[](#places-autocomplete-for-laravel)

[![GitHub Stars](https://camo.githubusercontent.com/29c214003ddf5081344eb2a5ad0ae0846b175e0d3a957533987f38adf6792c67/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f616c6578706563686b617265762f6c61726176656c2d706c616365732d6175746f636f6d706c6574652e7376673f7374796c653d666c61742d737175617265)](https://github.com/alexpechkarev/laravel-places-autocomplete/stargazers)[![Latest Version on Packagist](https://camo.githubusercontent.com/b815737fc3b4fefefcf10ecb87f8e290c84d95801d15ac8d3a82c6c9e10e4f2c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616c6578706563686b617265762f6c61726176656c2d706c616365732d6175746f636f6d706c6574652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/alexpechkarev/laravel-places-autocomplete)[![Total Downloads](https://camo.githubusercontent.com/08022059779ca1b2c0cf2351f96a1477034bfdf67c179aee0e7fff1da20e288f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616c6578706563686b617265762f6c61726176656c2d706c616365732d6175746f636f6d706c6574652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/alexpechkarev/laravel-places-autocomplete)[![GitHub License](https://camo.githubusercontent.com/648da93c92f884e5dbc39a66611cad55f4412395c6008addb5b669364d2f6687/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f616c6578706563686b617265762f6c61726176656c2d706c616365732d6175746f636f6d706c6574652e7376673f7374796c653d666c61742d737175617265)](https://github.com/alexpechkarev/laravel-places-autocomplete/blob/master/LICENSE)

A Laravel package that provides a simple Blade component to integrate the Google Places Autocomplete functionality into your application with minimal setup.

It handles API loading, session tokens for cost-effective usage, and fetching place details, allowing you to focus on building your application.

Features
--------

[](#features)

- **Simple Integration:** Add address autocomplete to any form with a single Blade component.
- **Cost-Effective:** Automatically handles session tokens to reduce Google API costs.
- **Customizable:** Configure the component's behavior through an options array.
- **Event-Driven:** Dispatches a custom event with the selected place data for easy handling in your frontend JavaScript.

Live Demo
---------

[](#live-demo)

See a comprehensive live demo of the underlying JavaScript library in action: [pacservice.pages.dev](https://pacservice.pages.dev/)

[![A video demonstrating the Places Autocomplete JavaScript component in action, showing address suggestions and selection.](places-autocomplete-js.gif)](places-autocomplete-js.gif)

Requirements
------------

[](#requirements)

- Laravel 9.x or higher
- A Google Maps API Key with the **Places API** enabled. You can get one from the [Google Cloud Console](https://console.cloud.google.com/google/maps-apis).

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require alexpechkarev/laravel-places-autocomplete
```

Configuration
-------------

[](#configuration)

1. Publish the configuration file. This will create a `config/places-autocomplete.php` file where you can set default options. The view file will be published to `resources/views/vendor/places-autocomplete` and the JavaScript files to `public/vendor/places-autocomplete/`.

```
php artisan vendor:publish --provider="PlacesAutocomplete\PlacesAutocompleteServiceProvider"
```

2. Add your Google Maps API key to your `.env` file. This is a required step.

```
// filepath: .env
GOOGLE_MAPS_API_KEY="YOUR_API_KEY_HERE"
```

Usage
-----

[](#usage)

### 1. Add the Component

[](#1-add-the-component)

Use the `` component in your Blade views. Because the component's root element has a dynamically generated ID, the recommended approach is to wrap it in your own `div` with a stable ID. This makes it easy to target with JavaScript.

```
// filepath: resources/views/your-form.blade.php

    Address

    {{-- Wrap the component in a div with a known ID --}}

    {{-- Other fields to be populated by JavaScript --}}

        City

        Postcode

```

### 2. Handle the Response

[](#2-handle-the-response)

When a user selects an address, the component dispatches a `pac-response` custom event on its root `div`. You can listen for this event to receive the place data.

Add the following JavaScript to your application.

```
// filepath: resources/js/app.js
document.addEventListener("DOMContentLoaded", function () {
  // Listen for the custom event emitted by the PlacesAutocomplete component
  document
    .getElementById("address-wrapper")
    .addEventListener("pac-response", function (event) {
      const placeDetails = event.detail;
      //console.log('Place Selected:', placeDetails);

      // Populate other fields based on the selected place details
      if (placeDetails.addressComponents) {
        placeDetails.addressComponents.forEach((component) => {
          if (component.types.includes("postal_town")) {
            document.getElementById("city").value = component.longText;
          }
          if (component.types.includes("postal_code")) {
            document.getElementById("postcode").value = component.longText;
          }
        });
      }
    });

  // Handle errors from the PlacesAutocomplete component
  document
    .getElementById("address-wrapper")
    .addEventListener("pac-error", function (event) {
      console.error("Autocomplete Error:", event.detail);
    });
});
```

Component Options
-----------------

[](#component-options)

You can customize the component by passing an `:options` array. These options are passed to the underlying [places-autocomplete-js](https://github.com/alexpechkarev/places-autocomplete-js) library.

OptionTypeDescription`placeholder`stringPlaceholder text for the input field.`debounce`integerDelay in milliseconds before sending a request (default: 100).`clear_input`booleanWhether to clear the input after selection.`language`stringThe language code for results (e.g., 'en-GB').For a full list of options, please refer to the [JavaScript library's documentation](https://github.com/alexpechkarev/places-autocomplete-js?tab=readme-ov-file#configuration).

**Note:** The `name` attribute of the generated `` is not currently configurable. The input's data will not be submitted with a standard form post; you must use JavaScript to handle the `pac-response` event and populate your form fields as shown in the example above.

Support
-------

[](#support)

If you encounter any issues or have questions, please [open an issue on GitHub](https://github.com/alexpechkarev/laravel-places-autocomplete/issues).

License
-------

[](#license)

This package is open-source software licensed under the [MIT license](https://github.com/alexpechkarev/laravel-places-autocomplete/blob/master/LICENSE).

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance54

Moderate activity, may be stable

Popularity16

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

324d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1cc8e1ca17a8158b131c60f92d5c5243073bfa762fb34b9263c0fbc15f072132?d=identicon)[alexpechkarev](/maintainers/alexpechkarev)

---

Top Contributors

[![alexpechkarev](https://avatars.githubusercontent.com/u/5559162?v=4)](https://github.com/alexpechkarev "alexpechkarev (6 commits)")

---

Tags

bladeblade-componentgoogle-mapsgoogle-places-apigoogle-places-autocompletejavascriptlaravellaravel-component-librarylaravel-packagelaravel-places-autocompletephpplaces-apiplaces-autocompletelaravelGoogle Places ApiGoogle Autocompleteaddress autocompleteBlade componentplaces autocompleteaddress search

### Embed Badge

![Health badge](/badges/alexpechkarev-laravel-places-autocomplete/health.svg)

```
[![Health](https://phpackages.com/badges/alexpechkarev-laravel-places-autocomplete/health.svg)](https://phpackages.com/packages/alexpechkarev-laravel-places-autocomplete)
```

###  Alternatives

[rcrowe/twigbridge

Adds the power of Twig to Laravel

9105.9M50](/packages/rcrowe-twigbridge)[tightenco/jigsaw

Simple static sites with Laravel's Blade.

2.2k438.5k29](/packages/tightenco-jigsaw)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[moonshine/moonshine

Laravel administration panel

1.3k217.1k59](/packages/moonshine-moonshine)[radic/blade-extensions

Laravel package providing additional Blade extensions: foreach (with $loop data like twig), break, continue, set,array (multiline), etc

271321.7k5](/packages/radic-blade-extensions)[anthonyedmonds/govuk-laravel

Use the GOV.UK Design System within the Laravel ecosystem, complete with Blade components and templates!

127.7k5](/packages/anthonyedmonds-govuk-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
