alto / language
Programming and document language metadata: extensions, aliases, filenames, and syntax markers.
Fund package maintenance!
Requires
- php: >=8.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^12.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Programming and document language metadata for PHP applications.
ALTO Language resolves programming and document languages from slugs, aliases, extensions, and exact filenames. It returns immutable metadata with syntax markers, relationships, and common formatting conventions without inspecting file contents.
use Alto\Language\Languages; $language = Languages::fromFilename('templates/home.html.twig'); echo $language?->name; // Twig echo $language?->type->value; // template
The package includes 62 lazily loaded definitions and has no runtime dependencies. Catalog tests check every slug, extension, alias, filename, and parent relationship for consistency.
Installation
Install ALTO Language with Composer:
composer require alto/language
ALTO Language requires PHP 8.4 or later. It does not require additional PHP extensions.
Quick Start
Use the Languages facade when the identifier type is known:
use Alto\Language\Languages; $php = Languages::get('php'); $rust = Languages::fromExtension('rs'); $python = Languages::fromAlias('py'); $make = Languages::fromFilename('/project/Makefile');
Each lookup returns a Language value object or null. Use Languages::resolve() only when the
identifier may be a slug, alias, extension, or filename.
Documentation
The documentation index lists these pages in site navigation order. The same documentation is published on altophp.com.
Contributing
Contributions of all kinds are welcome. Visit the project on GitHub to report a bug, suggest a feature, or open a pull request.
Before submitting code, run:
# Runs PHP CS Fixer, PHPStan, and PHPUnit
composer qa
Changes to public behavior should include tests and documentation.
Bundled definitions live in data/languages/. Add one file named after the
language slug; catalogue tests validate identifiers, filenames, and parent
relationships.
Support
ALTO Language is open source and independently maintained by Simon André. If it is useful to your work, you can support its continued development through GitHub Sponsors.
Sharing the package or starring it on GitHub also helps.
License
ALTO Language is released by ALTO PHP under the MIT License.