PHPackages                             tgerbet/babelfish - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. tgerbet/babelfish

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

tgerbet/babelfish
=================

A file programming language detector

0.1.0(7y ago)241[3 PRs](https://github.com/LeSuisse/babelfish/pulls)MITPHPPHP ^7.2

Since Jan 5Pushed 3y ago1 watchersCompare

[ Source](https://github.com/LeSuisse/babelfish)[ Packagist](https://packagist.org/packages/tgerbet/babelfish)[ RSS](/packages/tgerbet-babelfish/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (4)Versions (5)Used By (0)

Babelfish [![Latest Stable Version](https://camo.githubusercontent.com/2157f034e7f6713c954a5b1357c8768bc6ac42c1a3bc5eaae2ce19a9c7f86ae3/68747470733a2f2f706f7365722e707567782e6f72672f746765726265742f626162656c666973682f762f737461626c65)](https://packagist.org/packages/tgerbet/babelfish) [![Build Status](https://github.com/LeSuisse/babelfish/workflows/CI/badge.svg)](https://github.com/LeSuisse/babelfish/actions?query=workflow%3ACI) [![Type Coverage](https://camo.githubusercontent.com/f6ec4de8af004251b022ae01b3ebd2ed18f1f78c8a410ea4531ae4d6d0eb5e20/68747470733a2f2f73686570686572642e6465762f6769746875622f6c657375697373652f626162656c666973682f636f7665726167652e737667)](https://shepherd.dev/github/lesuisse/babelfish)
================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#babelfish---)

Babelfish is a file programming language detector based on [github/linguist](https://github.com/github/linguist) and [src-d/enry](https://github.com/src-d/enry).

Examples
--------

[](#examples)

```
$source_file = new ContentFile('Babelfish.php', \file_get_contents(__DIR__ . '/src/Babelfish/Babelfish.php'));
$language = Babelfish::getWithDefaultStrategies()->getLanguage($source_file);
if ($language !== null) {
    echo 'Language detected: ' . $language->getName();
}
```

How Babelfish works?
--------------------

[](#how-babelfish-works)

The language is determined by using an ordered set of strategies. Each strategy will either identify the precise language or reduce the number of likely languages for the next strategy. The default set of strategies is:

- [Vim or Emacs modeline](src/Babelfish/Strategy/Modeline.php)
- [commonly used filename](src/Babelfish/Strategy/Filename.php)
- [shell shebang](src/Babelfish/Strategy/Shebang.php)
- [file extension](src/Babelfish/Strategy/Extension.php)
- [XML header](src/Babelfish/Strategy/XML.php)
- [heuristics](src/Babelfish/Strategy/Heuristic.php)
- [naïve Bayesian classification](src/Babelfish/Strategy/Classifier.php)

See also [How Linguist works](https://github.com/github/linguist/#how-linguist-works).

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2685d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/12e4b975e2d996ef171a606a35995208e39274ec14e4e6ec3974e1b4b165bb7f?d=identicon)[tgerbet](/maintainers/tgerbet)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (82 commits)")[![LeSuisse](https://avatars.githubusercontent.com/u/737767?v=4)](https://github.com/LeSuisse "LeSuisse (72 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (67 commits)")[![dependabot-support](https://avatars.githubusercontent.com/u/112581971?v=4)](https://github.com/dependabot-support "dependabot-support (2 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tgerbet-babelfish/health.svg)

```
[![Health](https://phpackages.com/badges/tgerbet-babelfish/health.svg)](https://phpackages.com/packages/tgerbet-babelfish)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
