Skip to main content

A modern, async PHP framework detector.

Project description

PHP Framework Detector

Detect PHP frameworks in any project directory with a modern, async Python tool. Supports 17+ frameworks, structured logging, and a user-friendly CLI.

Features

  • Async detection for high performance
  • 17+ frameworks supported
  • Structured logging (structlog)
  • Type safety (Pydantic)
  • Modern CLI (Rich)
  • Configurable & extensible

Supported Frameworks

Laravel, Symfony, CodeIgniter, CakePHP, Yii, ThinkPHP, Slim, Fuel, Phalcon, Laminas, Zend Framework, Drupal, Drush, Fat-Free, PHPixie, PopPHP, FastRoute

Installation

# Recommended (uv)
uv add php-framework-detector

# Or pip
pip install php-framework-detector

Usage

CLI

php-framework-detector /path/to/php/project [--json] [--all] [--verbose]
php-framework-detector list-frameworks
php-framework-detector version

Docker

docker run --rm -it -v /path/to/php/project:/var/www/html ghcr.io/wangyihang/php-framework-detector:main detect /var/www/html

Python API

import asyncio
from php_framework_detector import FrameworkDetectorFactory, DetectionConfig

async def main():
    config = DetectionConfig(timeout=30, max_file_size=1024*1024, verbose=True)
    result = await FrameworkDetectorFactory.detect_all_frameworks_async("/path/to/php/project", config)
    print(result)

asyncio.run(main())

Configuration Example

from php_framework_detector import DetectionConfig
config = DetectionConfig(
    check_composer=True,
    check_files=True,
    check_dependencies=True,
    max_file_size=1024*1024,
    timeout=30,
    verbose=False
)

Architecture

  • FrameworkDetector: Base class for detectors
  • FrameworkDetectorFactory: Detector management
  • DetectionConfig: Config model
  • DetectionResult: Structured results
  • Custom Exceptions: Error handling

Detection strategies:

  • File pattern matching
  • Composer dependency analysis
  • Content pattern matching
  • Priority-based scoring

Add a New Framework

  1. Create a detector in frameworks/:
from ..core.detector import FrameworkDetector
class MyFrameworkDetector(FrameworkDetector):
    name = "myframework"
    display_name = "My Framework"
    def detect(self):
        return self._check_path_patterns(["myframework.php"])
    async def _detect_async_impl(self):
        return 50 if await self._check_path_patterns_async(["myframework.php"]) else 0
  1. Register it in frameworks/__init__.py:
from .myframework import MyFrameworkDetector
FrameworkDetectorFactory.register_detector(MyFrameworkDetector)

Development

git clone https://github.com/your-username/php-framework-detector.git
cd php-framework-detector
uv sync
uv sync --extra dev
pytest
black .
isort .
mypy .
ruff check .

Testing

pytest
pytest --cov=php_framework_detector
pytest --asyncio-mode=auto

Contributing

  • Fork & branch
  • Add features/tests
  • Ensure all tests pass
  • Submit a pull request

License

MIT License. See LICENSE.

Changelog

v0.2.0

  • Refactored, async, structured logging, type safety, improved CLI, error handling, better detection

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_framework_detector-0.2.2.tar.gz (26.8 kB view details)

Uploaded Source

Built Distribution

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

php_framework_detector-0.2.2-py3-none-any.whl (30.6 kB view details)

Uploaded Python 3

File details

Details for the file php_framework_detector-0.2.2.tar.gz.

File metadata

File hashes

Hashes for php_framework_detector-0.2.2.tar.gz
Algorithm Hash digest
SHA256 6af640fc92f3b5bec3cb5623618afae3cd472a9b23daeebb316554656201ff1b
MD5 d9f2167c588a9b4701f0f912e3f11a42
BLAKE2b-256 6b4b6da252eb7497334683121cf95da32c70917c6e8ce59cb0d0b935d959c57d

See more details on using hashes here.

File details

Details for the file php_framework_detector-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for php_framework_detector-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2ae3488e4b788188527a5089a0ebe756b4f142d0c7a3c2697eb592f1eeb8c6a8
MD5 a40d5dcf1885c4b4f5f17f0ac3d4181d
BLAKE2b-256 55fe7939d8bc0341969a030c5d00d1fbb21f0ef7a593dbce2bc90ac88e1b5973

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