PHP code example of martinsik / php-doc-parser

1. Go to this page and download the library: Download martinsik/php-doc-parser 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/ */

    

martinsik / php-doc-parser example snippets


use DocParser\Package;
use DocParser\Parser;

$package = new Package('en', 'php.net');
$tmpFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $package->getOrigFilename();
$package->download($tmpFile);
$unpackedDir = $package->unpack();

$result = $parser->processDir($unpackedDir, Parser::EXPORT_EXAMPLES);
// you can parse just a single file with: $parser->processFile('file.html');

foreach ($result->getResult() as $funcName => $funcData) {
    // Note that all function names used as keys are lowercase.
    // Proper function names are in parameter lists (see [sample bellow](https://github.com/martinsik/php-doc-parser#sample-output)).
    // eg.: $funcData['params'][0]['name']
    
    // Get all examples for this function.
    // $result->getExamples($funcName);
    
    // If you used Parser::IMPORT_EXAMPLES then examples are right in $funcData.
    // With Parser::SKIP_EXAMPLES they're not parsed at all.
}

// Remove all temporary files
$package->cleanup();