PHP code example of julien-boudry / php-reference

1. Go to this page and download the library: Download julien-boudry/php-reference 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/ */

    

julien-boudry / php-reference example snippets




return [
    'namespace' => 'MyNamespace\\MyProject',
    'output' => __DIR__ . '/docs/api',
    'api' => 'HasTagApi', // 'HasTagApi' (default) or 'IsPubliclyAccessible'
    'index-file-name' => 'readme',
    'source-url-base' => 'https://github.com/username/repository/blob/main',
];

/**
 * This class will be documented.
 * @api
 */
class MyClass
{
    /**
     * This method will be documented.
     * @api
     */
    public function myMethod(): void
    {
    }
    
    // This method will NOT be documented (no @api tag)
    public function internalMethod(): void
    {
    }
}
bash
php vendor/bin/php-reference
bash
# Basic usage - generate docs for a namespace
php vendor/bin/php-reference MyNamespace\\MyProject

# With custom output directory
php vendor/bin/php-reference MyNamespace\\MyProject --output=./docs/api

# Include all public elements (not just @api tagged)
php vendor/bin/php-reference MyNamespace\\MyProject --api=IsPubliclyAccessible

# Append mode (don't clean output directory first)
php vendor/bin/php-reference MyNamespace\\MyProject --append

# With source code links
php vendor/bin/php-reference MyNamespace\\MyProject --source-url-base=https://github.com/user/repo/blob/main
yaml
# .github/workflows/docs.yml
- name: Generate API Documentation
  run: php vendor/bin/php-reference
bash
# Public API documentation (with @api tags)
php vendor/bin/php-reference --config=reference-public.php

# Complete documentation (all public elements)
php vendor/bin/php-reference --config=reference-complete.php
bash
php vendor/bin/php-reference MyNamespace\\MyProject --api=IsPubliclyAccessible