Skip to main content

A modern, async PHP app library classifier.

Project description

PHP App Library Classifier

Analyze and classify PHP libraries used in any project directory with a modern, containerized tool. Outputs structured JSON for easy integration and analysis.

Features

  • Automatic library detection for PHP projects
  • Structured JSON output
  • Dockerized for easy use
  • No dependencies on host system
  • Fast and efficient analysis

Usage

CLI

php-app-lib-classifier /path/to/php/app [--json] [--verbose]
php-app-lib-classifier version
  • /path/to/php/app: Path to the PHP application to analyze.
  • --json: Output results in JSON format.
  • --verbose: Enable verbose logging.

Docker

docker run --rm -it -v /path/to/your/php/app:/var/www/html ghcr.io/wangyihang/php-app-lib-classifier:main /var/www/html --json
  • /path/to/your/php/app: Local path to your PHP application.
  • The output will be in JSON format.

Python API

Simple Function Interface (Recommended)

from php_app_lib_classifier import classify, ProjectType, ConfidenceLevel

# Get object result
result = classify("/path/to/php/app")
print(f"Project type: {result.project_type.value}")  # Enum value
print(f"Confidence: {result.get_confidence_level()[0].value}")  # Enum value

# Check specific types
if result.project_type == ProjectType.LIBRARY:
    print("This is a library project")

# Get JSON result
json_result = classify("/path/to/php/app", output_json=True)
print(json_result)

Class Interface

from php_app_lib_classifier import LibraryClassifier

result = LibraryClassifier.classify("/path/to/php/app", output_json=True)
print(result)
  • classify(path, output_json=False, verbose=False): Simple function interface to analyze PHP applications and return results
  • LibraryClassifier.classify(path, output_json=True): Class interface to analyze PHP applications and return results (optionally as JSON)

Requirements

  • Docker

Architecture

  • LibraryClassifier: Core logic for detecting and classifying PHP libraries
  • CLI Interface: Simple command-line usage via Docker
  • JSON Output: Structured results for downstream processing
  • Enum Types: Type-safe project types and confidence levels

Enum Types

The library provides Enum types for better type safety:

from php_app_lib_classifier import ProjectType, ConfidenceLevel, ConfidenceColor

# Project types
ProjectType.LIBRARY           # "Library"
ProjectType.WEB_APPLICATION   # "Web Application" 
ProjectType.HYBRID_UNCLEAR    # "Hybrid/Unclear"

# Confidence levels
ConfidenceLevel.HIGH          # "High"
ConfidenceLevel.MEDIUM        # "Medium"
ConfidenceLevel.LOW           # "Low"
  • Detection Strategies:
    • Composer dependency analysis
    • File and directory pattern matching
    • Content-based heuristics

Contributing

  • Fork & branch
  • Add features or tests
  • Ensure all tests pass (if applicable)
  • Submit a pull request

License

MIT License. See LICENSE.

Changelog

v0.2.0

  • Improved detection logic, structured output, and Docker usability

v0.1.0

  • Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

php_app_lib_classifier-0.1.2.tar.gz (26.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

php_app_lib_classifier-0.1.2-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

Details for the file php_app_lib_classifier-0.1.2.tar.gz.

File metadata

File hashes

Hashes for php_app_lib_classifier-0.1.2.tar.gz
Algorithm Hash digest
SHA256 334f8af781545eef221520e038b3ae90b80b4edb5a43ea9307a8a2bb6c9ae68b
MD5 4d319074b25deecd40cbee0bd5ba08a9
BLAKE2b-256 e9c7aad0723e6a77e727ace583b470931248f2fc622056dff447afa930ebae9c

See more details on using hashes here.

File details

Details for the file php_app_lib_classifier-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for php_app_lib_classifier-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 beba25fbc3a7b3226b7f2a167c7bcb67c6209012a8947e8ccde14947162eea00
MD5 27df77b600306adbdd69d3895e80a9be
BLAKE2b-256 53448286d01c438e30586c121f26947910cb3d70d890dd75d901dd3fd406e182

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page