Download the PHP package dcarbone/tns-parser without Composer
On this page you can find all versions of the php package dcarbone/tns-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dcarbone/tns-parser
More information about dcarbone/tns-parser
Files in dcarbone/tns-parser
Package tns-parser
Short Description Oracle tnsnames.ora file / string parser written in PHP
License Apache-2.0
Homepage https://github.com/dcarbone/tns-parser
Informations about the package tns-parser
tns-parser
Oracle tnsnames.ora file / string parser written in PHP
Installation
This library is designed to be installed using Composer.
Require entry:
This readme assumes knowledge of Composer Autoloading.
Feature List
- Able to parse input from file or passed string
- Multi-line and comment agnostic
- Supports multi-entry items (such as multi-address entries)
- Allows searching
- Allows basic sorting based upon entry name
- Implements the follow interfaces:
- Able to export entries as:
- Original
- Alphabetized tnsnames.ora file
- JSON representation
Example Usage
Given the below TNS entries:
You would initialize an instance of the parser:
Then, if the above was contained within a file:
Or as just a string:
And that's it!
Searching
During input parsing, all properties for a given TNS entry are stored a multi-dimensional array to allow searching:
The search result is an array containing the NAMES of any matched entries. The above, in this case, would result in:
You can get as specific as you like:
You can then use the matched names to retrieve the entries:
... Or get a valid TNS entry version as a string:
Under the covers, the searching system uses preg_match, with the
following structure: '{%s}S'
by default, with %s being replaced by your input.
If you wish for a case-sensitive search, pass in true
as the 2nd parameter when executing search()
.
Sorting
For the moment, searching is limited to alphabetical by entry name, and utilizes ksort under the covers.
Suggestions?
For the moment this library serves my needs, however if anybody using this library would like to see some improvements / modifications made, please let me know!
Tests
Work in progress.