DcfParser is a PHP & Laravel Package to parse Debian Control Files.
Example DCF contents:
Section: unknown
Priority: optional
Maintainer: Josip Rodin <[email protected]>
Build-Depends: debhelper (>=10)
Standards-Version: 4.0.0
Homepage: <insert the upstream URL, if relevant>
Package: gentoo
Architecture: any
Depends: nothing
Description: The format for the package description is a short brief summary on the first line
(after the Description field). The following lines should be used as a longer, more detailed description.
Each line of the long description must be preceded by a space, and blank lines in the long description must contain a single ‘.’
.
following the preceding space.
Lastline: last
Parsing result:
["source"]=>
string(6) "gentoo"
["section"]=>
string(7) "unknown"
["priority"]=>
string(8) "optional"
["maintainer"]=>
string(31) "Josip Rodin <[email protected]>"
["build-depends"]=>
string(16) "debhelper (>=10)"
["standards-version"]=>
string(5) "4.0.0"
["homepage"]=>
string(38) "<insert the upstream URL, if relevant>"
["package"]=>
string(6) "gentoo"
["architecture"]=>
string(3) "any"
["depends"]=>
string(7) "nothing"
["description"]=>
string(353) "The format for the package description is a short brief summary on the first line (after the Description field). The following lines should be used as a longer, more detailed description. Each line of the long description must be preceded by a space, and blank lines in the long description must contain a single ‘.’ . following the preceding space."
["lastline"]=>
string(3) "last"
}
- Git
- Composer
composer require makowskid/dcfparser
composer install
- make sure everything is OK by running the tests
phpunit
In Laravel:
\DcfParser::parseFile('test.txt');
Generic:
$parser = new \makowskid\DcfParser\DcfParser();
$parser->parseFile('test.txt');
To run the tests, run the following command from the project folder.
bash
$ ./vendor/bin/phpunit
or
$ composer test
- Dawid Makowski
- Alin Purcaru - thanks for inspiration on StackOverflow
The MIT License (MIT). See the License File for more information.