PHP code example of makowskid / dcfparser

1. Go to this page and download the library: Download makowskid/dcfparser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

makowskid / dcfparser example snippets


$parser = new \makowskid\DcfParser\DcfParser();
$data = $parser->parseFile('/path/to/control');
// ['source' => 'gentoo', 'section' => 'games', ...]

$data = $parser->parseString("Source: gentoo\nSection: games\n");

$stanzas = $parser->parseFileAll('/path/to/control');
// or
$stanzas = $parser->parseStringAll($content);

// Returns: [['source' => 'gentoo', ...], ['package' => 'gentoo', ...]]

\DcfParser::parseFile('/path/to/control');
\DcfParser::parseString($content);
\DcfParser::parseFileAll('/path/to/control');
\DcfParser::parseStringAll($content);

[
    'source' => 'gentoo',
    'section' => 'games',
    'priority' => 'optional',
    'maintainer' => 'Josip Rodin <[email protected]>',
    'build-depends' => 'debhelper (>=10)',
    'homepage' => 'https://packages.debian.org/gentoo',
]