2017 © Pedro Peláez
 

library common-autolink

Class that can convert urls into anchors

image

madlines/common-autolink

Class that can convert urls into anchors

  • Saturday, October 10, 2015
  • by XanderEmu
  • Repository
  • 1 Watchers
  • 1 Stars
  • 255 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 3 % Grown

The README.md

Madlines Common-AutoLink

It is a very simple lib that turns all urls in given input into anchors., (*1)

Installation

You can install it using composer:, (*2)

composer require madlines/common-autolink

Usage

<?php

use Madlines\Common\AutoLink\AutoLink;

$input = 'My string containing some urls like www.example.com or smth more fancy like https://www.example.com:8803/foo/bar?lorem=ipsum#dolor/sit/amet';
$output = AutoLink::parse($input);

And it shall return the following string:, (*3)

My string containing some urls like <a href="http://www.example.com" target="_blank">www.example.com</a> or smth more fancy like <a href="https://www.example.com:8803/foo/bar?lorem=ipsum#dolor/sit/amet" target="_blank">www.example.com:8803/foo/bar?lorem=ipsum#dolor/sit/amet</a>

For Symfony + Twig users

You can simply turn it into Twig extension if you'd like to:, (*4)

<?php

namespace MyApp\MyBundle\Twig;

use Madlines\Common\AutoLink\AutoLink;

class AutoLinkExtension extends \Twig_Extension
{
    const NAME = 'auto_link_extension';

    /**
     * @return array
     */
    public function getFilters()
    {
        return [
            new \Twig_SimpleFilter('auto_link', [$this, 'autoLink']),
        ];
    }

    /**
     * @param string $text
     * @return string
     */
    public function autoLink($text)
    {
        return AutoLink::parse($text)
    }

    /**
     * @return string
     */
    public function getName()
    {
        return self::NAME;
    }
}

service configuration in services.yml, (*5)

my.twig_extension.auto_link:
    class: MyApp\MyBundle\Twig\AutoLinkExtension
        public: false
        tags:
            - { name: twig.extension }

The Versions

10/10 2015

dev-master

9999999-dev

Class that can convert urls into anchors

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Aleksander Ciesiolkiewicz

24/08 2015

1.1

1.1.0.0

Class that can convert urls into anchors

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Aleksander Ciesiolkiewicz

11/07 2015

1.0

1.0.0.0

Class that can convert urls into anchors

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Aleksander Ciesiolkiewicz