PHPackages                             jord-jd/php-hcl-parser - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. jord-jd/php-hcl-parser

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

jord-jd/php-hcl-parser
======================

PHP HCL Parser

v2.0.0(5mo ago)1433LGPL-3.0-onlyPHPPHP ^7.4 || ^8.0CI passing

Since Apr 10Pushed 1w agoCompare

[ Source](https://github.com/Jord-JD/php-hcl-parser)[ Packagist](https://packagist.org/packages/jord-jd/php-hcl-parser)[ GitHub Sponsors](https://github.com/DivineOmega)[ RSS](/packages/jord-jd-php-hcl-parser/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (5)Dependencies (1)Versions (5)Used By (0)

⚒🔀🐘 PHP HCL Parser
==================

[](#-php-hcl-parser)

[![Tests](https://github.com/Jord-JD/php-hcl-parser/actions/workflows/tests.yml/badge.svg)](https://github.com/Jord-JD/php-hcl-parser/actions/workflows/tests.yml)

HCL is a configuration language make by HashiCorp. HCL files are used by several HashiCorp products, including Terraform.

This library parses HCL configuration files into PHP objects.

> **Compatibility note:** The bundled `json2hcl` 0.0.6 converter supports legacy HCL syntax. Its upstream project is archived and does not provide ARM64 binaries, so this package is not suitable for modern HCL 2 syntax or ARM64 hosts.

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

[](#installation)

You can install the PHP HCL Parser library using Composer. Just run the following command from the root of your project.

```
composer require jord-jd/php-hcl-parser

```

Usage
-----

[](#usage)

To parse HCL into a PHP object, create a new `HCLParser` object, passing it the HCL (as a string), then call the `parse` method. See the example below.

```
$hcl = file_get_contents('example.tf');
$configObject = (new HCLParser($hcl))->parse();
```

Invalid HCL, converter failures, and invalid converter output throw `JordJD\HCLParser\Exceptions\HCLParseException`. Downloaded converter binaries are checked against pinned SHA-256 hashes before they are installed.

The resulting object will look similar to the following.

```
object(stdClass)#5 (2) {
  ["provider"]=>
  array(1) {
    [0]=>
    object(stdClass)#4 (1) {
      ["aws"]=>
      array(1) {
        [0]=>
        object(stdClass)#2 (3) {
          ["access_key"]=>
          string(17) "${var.access_key}"
          ["region"]=>
          string(13) "${var.region}"
          ["secret_key"]=>
          string(17) "${var.secret_key}"
        }
      }
    }
  }
  ["resource"]=>
  array(1) {
    [0]=>
    object(stdClass)#8 (1) {
      ["aws_instance"]=>
      array(1) {
        [0]=>
        object(stdClass)#7 (1) {
          ["example"]=>
          array(1) {
            [0]=>
            object(stdClass)#6 (2) {
              ["ami"]=>
              string(12) "ami-2757f631"
              ["instance_type"]=>
              string(8) "t2.micro"
            }
          }
        }
      }
    }
  }
}
```

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance87

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 91.4% 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 ~955 days

Total

4

Last Release

160d ago

Major Versions

v1.2.0 → v2.0.02026-02-14

### Community

Maintainers

![](https://www.gravatar.com/avatar/c580cdf7c14898fff179cdfc1085892091d5d2f49d917873a12365af9ac77c93?d=identicon)[Jord-JD](/maintainers/Jord-JD)

---

Top Contributors

[![Jord-JD](https://avatars.githubusercontent.com/u/650645?v=4)](https://github.com/Jord-JD "Jord-JD (32 commits)")[![Binternet](https://avatars.githubusercontent.com/u/438361?v=4)](https://github.com/Binternet "Binternet (3 commits)")

---

Tags

configurationhclparserphp-libraryphp-objectterraform

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jord-jd-php-hcl-parser/health.svg)

```
[![Health](https://phpackages.com/badges/jord-jd-php-hcl-parser/health.svg)](https://phpackages.com/packages/jord-jd-php-hcl-parser)
```

###  Alternatives

[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9843.5k](/packages/sauladam-shipment-tracker)[jstewmc/rtf

Read and write Rich Text Format (RTF) documents with PHP

45153.1k6](/packages/jstewmc-rtf)[tcds-io/php-jackson

A lightweight, flexible object serializer for PHP, inspired by FasterXML/jackson

113.2k10](/packages/tcds-io-php-jackson)

PHPackages © 2026

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