Search by

vstelmakh / url-highlight-symfony-bundle

vstelmakh

This package is abandoned and no longer maintained. The author suggests using the vstelmakh/url-highlight package instead.

Symfony bundle for url highlight library

Package info

github.com/vstelmakh/url-highlight-symfony-bundle

Type:symfony-bundle

pkg:composer/vstelmakh/url-highlight-symfony-bundle

Statistics

Installs: 4 592

Dependents: 0

Suggesters: 0

Stars: 2

Open Issues: 0

v3.0.0 2020-11-05 21:26 UTC

This package is auto-updated.

Last update: 2026-11-11 22:32:10 UTC


README

Warning

This package is no longer maintained and only supports URL Highlight v3. Use URL Highlight directly and follow its documentation.

Build status Packagist version PHP version License

Symfony bundle for URL Highlight library.
Supported Symfony versions: ^2.7, ^3, ^4, ^5.

Installation

Install the latest version with:

$ composer require vstelmakh/url-highlight-symfony-bundle

Setup

If your application is using Symfony Flex - you are ready to go, skip next steps.

Enable the bundle by adding it to the list of registered bundles in the config/bundles.php file of your project:

// config/bundles.php

return [
    // ...
    VStelmakh\UrlHighlightSymfonyBundle\UrlHighlightBundle::class => ['all' => true],
];

Usage

Bundle provide URL Highlight service which available via autowire or directly from container:

<?php

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use VStelmakh\UrlHighlight\UrlHighlight;

class ExampleController extends AbstractController
{
    public function autowire(UrlHighlight $urlHighlight)
    {
        // do your stuff
    }

    public function fromContainer()
    {
        /** @var UrlHighlight $urlHighlight */
        $urlHighlight = $this->container->get('vstelmakh.url_highlight');
    }
}

Additionally urls_to_html filter available in templates:

{{ 'Basic example http://example.com'|urls_to_html }}

{# output: Basic example <a href="http://example.com">http://example.com</a> #}

More details see usage in Twig URL Highlight repository.

Configuration

Works out of the box with default configuration:

url_highlight:
    validator: ~
    highlighter: ~
    encoder: ~

If you need to change configuration add desired options to your parameters.yaml or create separate config: config/packages/url_highlight.yaml.
More information about configuration options could be found in URL Highlight library.

Example to define validator to not match urls without scheme

  • Define validator service. Use bundled with URL Highlight library or create your own implementation of VStelmakh\UrlHighlight\Validator\ValidatorInterface:
# config/services.yaml
services:
    ...
    VStelmakh\UrlHighlight\Validator\Validator:
        arguments: [false]
  • Provide service id in url_highlight.yaml config
# config/packages/url_highlight.yaml
url_highlight:
    validator: VStelmakh\UrlHighlight\Validator\Validator

Credits

Volodymyr Stelmakh
Licensed under the MIT License. See LICENSE for more information.