Skip to main content

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

Release files for php-framework-detector 0.2.16

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for php-framework-detector 0.2.16
File Size Uploaded
php_framework_detector-0.2.16.tar.gz 64.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for php-framework-detector 0.2.16
File Interpreter ABI Platform
php_framework_detector-0.2.16-py3-none-any.whl Python 3 none any Details

Total release size: 100.9 kB

Release files / php_framework_detector-0.2.16.tar.gz

Download URL php_framework_detector-0.2.16.tar.gz
Size 64.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7fa4d1e8c7d8d126c081e24dfe184bfa4d17eaabff3c43b68d3d1270b2f16899
BLAKE2b-256 checksum
How to use checksums
794253d7cf44d3a0a4b9da2fa94184695de59a2c41cf436ba853a06aaa6c1ca5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.3

Release files / php_framework_detector-0.2.16-py3-none-any.whl

Download URL php_framework_detector-0.2.16-py3-none-any.whl
Size 36.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f158a61adb1104c888b8c80ba2b16423e3222d49cf55376cc548ffdeea0d59f8
BLAKE2b-256 checksum
How to use checksums
9fcdc485b8889066bdd242b87801e303f08dfe4b2d60be8f5f98c74cc45ee9e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.3

Release history Release notifications | RSS feed

This release

0.2.16 This release

2 release files

0.2.15

2 release files

0.2.14

2 release files

0.2.13

2 release files

0.2.12

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page