Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Php Console Highlighter

Php Console Highlighter Laravel Package

jakub-onderka/php-console-highlighter

Abandoned package for syntax-highlighting PHP code in the terminal using ANSI colors. Provides a Highlighter that outputs highlighted whole-file or snippet content for CLI display. Suggested alternative: php-parallel-lint/PHP-Console-Highlighter.

View on GitHub
Deep Wiki
Context7

PHP Console Highlighter adds syntax highlighting for PHP code in the terminal, making CLI output and debugging logs easier to read. You feed it PHP source (or a full file) and it returns ANSI-colored text using a configurable console color palette.

Note: This repository is abandoned. Suggested alternative: https://github.com/php-parallel-lint/PHP-Console-Highlighter

Features

  • Highlights entire PHP files for console display
  • Uses ANSI colors via php-console-color
  • Simple API: instantiate Highlighter and render with getWholeFile()
  • Designed for CLI tools, linters, and debugging output
Frequently asked questions about Php Console Highlighter
Is this package compatible with Laravel 10 and PHP 8.2+?
No, this package is abandoned and officially supports PHP 5.4–7.2. PHP 8.x features like enums, attributes, or match expressions may break syntax highlighting. Test thoroughly or use a fork/alternative like php-parallel-lint/PHP-Console-Highlighter.
How do I integrate this into a Laravel Artisan command for colored code output?
Instantiate the `Highlighter` class in your command, pass it PHP code (e.g., from a file or string), and use `getWholeFile()` to render ANSI-colored output. Example: `$highlighter->getWholeFile(file_get_contents($filePath))`. Works seamlessly in CLI tools.
Can I use this to highlight code in Laravel exception pages or debugbar?
Yes, replace plain-text code dumps in exception handlers or debugbar with highlighted snippets. Inject the highlighter into your custom exception renderer or debugbar extension. Avoid production-facing HTTP responses due to ANSI overhead.
What’s the performance impact of highlighting large PHP files in Laravel?
Minimal for small files, but large files (e.g., `AppServiceProvider.php`) may add ~10–50ms latency. Avoid in high-throughput CLI tools or queue workers. Test in staging before production use, especially if abandoned code causes regressions.
Why is this package abandoned? Should I still use it?
Last updated in 2018 with no activity. Risks include PHP 8.x incompatibility and unpatched bugs. Use only for non-critical dev tools or fork it. The README suggests `php-parallel-lint/PHP-Console-Highlighter` as a maintained alternative.
Does this work with Laravel’s Tinker or REPL for interactive debugging?
Yes, highlight code snippets in Tinker or custom REPLs by piping output through the highlighter. Example: `echo $highlighter->getWholeFile($userInputCode);`. Enhances readability for dynamic code evaluation.
How do I configure custom colors for syntax highlighting in Laravel?
Extend the `ConsoleColor` class or pass a custom palette to the `Highlighter` constructor. Override methods like `getKeywordColor()` or `getStringColor()` in a child class. Document your changes if forking the package.
Are there alternatives to this package for Laravel syntax highlighting?
Yes, consider `php-parallel-lint/PHP-Console-Highlighter` (active fork) or Symfony’s `Style` component for ANSI escapes. For web-based highlighting, use JavaScript libraries like Prism.js via Blade. Evaluate trade-offs for CLI vs. web use cases.
Can I use this in Laravel’s Monolog for colored log entries?
Yes, create a custom Monolog processor or handler to wrap code snippets in `getWholeFile()`. Example: `echo $highlighter->getWholeFile($context['code'])` in log output. Ideal for development logs but avoid in production due to ANSI bloat.
What dependencies does this package require, and are they up-to-date?
Requires `ext-tokenizer` (enabled by default) and `jakub-onderka/php-console-color` (v0.2.x). Both are lightweight MIT-licensed, but `php-console-color` is also abandoned. Check for PHP 8.x compatibility if using this package long-term.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport