PHPackages                             guillermobt/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. guillermobt/babelfish

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

guillermobt/babelfish
=====================

A file programming language detector

08PHP

Since Mar 19Pushed 3y agoCompare

[ Source](https://github.com/guillermobt/babelfish)[ Packagist](https://packagist.org/packages/guillermobt/babelfish)[ RSS](/packages/guillermobt-babelfish/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)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

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity23

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/70d82bf8fc098891df8d6a171da1f227d0d8ed9bbcc93faca1ba137c6b5c3047?d=identicon)[guillermobt](/maintainers/guillermobt)

---

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)")[![guillermobt](https://avatars.githubusercontent.com/u/9293365?v=4)](https://github.com/guillermobt "guillermobt (2 commits)")

### Embed Badge

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

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

PHPackages © 2026

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