PHPackages                             spfalz/tnsparser - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. spfalz/tnsparser

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

spfalz/tnsparser
================

Class for parsing Oracle TNS files (tnsnames.ora).

1.0.1(8y ago)126BSD-2-Clause-FreeBSDPHPPHP &gt;=5.3.0||^7.0

Since Jun 3Pushed 8y ago1 watchersCompare

[ Source](https://github.com/SieGeL2k16/TNSParser)[ Packagist](https://packagist.org/packages/spfalz/tnsparser)[ Docs](https://github.com/SieGeL2k16/TNSParser)[ RSS](/packages/spfalz-tnsparser/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (3)Used By (0)

README for tnsparser.class
==========================

[](#readme-for-tnsparserclass)

##### Last updated on 02-Jun-2016

[](#last-updated-on-02-jun-2016)

Introduction
------------

[](#introduction)

This class was build to easily parse the Oracle TNS files, mainly for my OIS2 application to have some kind of automatic detection of TNS names in place. It is licensed under the BSD, so do what you want with it, but please keep the copyright notice intact, thank you!

The class takes an tnsnames.ora file, parses it down to all components and returns an associative array with all parsed data, indexed by the TNS name.

As many components inside a TNS name could be specified multiple times, the returned array values are in fact arrays, too. Here's an example how an resulting array may look like:

```
Array
(
    [ORADEV] => Array
        (
            [PROTOCOL] => Array
                (
                    [0] => TCP
                )

            [HOST] => Array
                (
                    [0] => 192.168.255.2
                )

            [PORT] => Array
                (
                    [0] => 1521
                )

            [SERVER] => Array
                (
                    [0] => DEDICATED
                )

            [SERVICE_NAME] => Array
                (
                    [0] => ORADEV.LOCAL
                )
        )
)

```

This is the parsing result of the following original TNS entry:

```
ORADEV =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.255.2)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ORADEV.LOCAL)
    )
  )

```

The distribution provides an example taken from Oracle docs with multiple host specifications, so you can see exactly how this all works.

Usage
-----

[](#usage)

Usage is rather simple, create a new instance from the class and call the public method "ParseTNS()" with the path to your oracle tnsnames.ora file, i.e.:

```
$TNS = new TNSParser;
$rc = $TNS->ParseTNS('/opt/oracle/product/11.2/network/admin/tnsnames.ora');
print_r($rc);

```

In case of an error the method throws an exception, so you should use a try/catch block to react on errors.

Final words
-----------

[](#final-words)

I've successfully tested this class with a number of different and rather complex TNSnames files, however no software is really bugfree, so if you find a bug or have an idea how to improve this class, either do it on your own or feel free to contact me on my homepage, which could be found under the following URL:

Nothing more to say, I doubt that anyone really reads this file until the end, so keep up coding :D

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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 ~14 days

Total

2

Last Release

2934d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1295248?v=4)[Rich Siegel](/maintainers/SieGeL)[@siegel](https://github.com/siegel)

---

Top Contributors

[![SieGeL2k16](https://avatars.githubusercontent.com/u/18546281?v=4)](https://github.com/SieGeL2k16 "SieGeL2k16 (8 commits)")

---

Tags

oracle-databasephp-librarytns-parsertnsnamesoracleclasstnstnsnames.ora

### Embed Badge

![Health badge](/badges/spfalz-tnsparser/health.svg)

```
[![Health](https://phpackages.com/badges/spfalz-tnsparser/health.svg)](https://phpackages.com/packages/spfalz-tnsparser)
```

###  Alternatives

[nette/robot-loader

🍀 Nette RobotLoader: high performance and comfortable autoloader that will search and autoload classes within your application.

89454.3M347](/packages/nette-robot-loader)[classpreloader/classpreloader

Helps class loading performance by generating a single PHP file containing all of the autoloaded files for a specific use case

37642.7M32](/packages/classpreloader-classpreloader)[yzen.dev/plain-to-class

Class-transformer to transform your dataset into a structured object

162101.6k6](/packages/yzendev-plain-to-class)[ph-7/qrcode-generator-php-class

Light QRCode PHP class (library). QR Code Generator using vCard 4.0 and the Google Chart AP

10415.7k2](/packages/ph-7-qrcode-generator-php-class)[classpreloader/console

Helps class loading performance by generating a single PHP file containing all of the autoloaded files for a specific use case

10241.8k5](/packages/classpreloader-console)[feature-ninja/cva

Class variance authority implementation in php

1817.0k3](/packages/feature-ninja-cva)

PHPackages © 2026

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