Download the PHP package asika/autolink without Composer
On this page you can find all versions of the php package asika/autolink. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download asika/autolink
More information about asika/autolink
Files in asika/autolink
Package autolink
Short Description Auto convert url to link anchor.
License MIT
Homepage https://github.com/asika32764/php-autolink
Informations about the package autolink
PHP Autolink Library
A library to auto convert URLs to links.
Table of Content
- PHP Autolink Library
- Table of Content
- Requirement
- Installation via Composer
- Getting Started
- Use Autolink Object
- Convert Text
- Add Attributes
- Convert Email
- Attributes Escaping
- Options
text_limit
auto_title
strip_scheme
escape
link_no_scheme
- Scheme
- Link Builder
Requirement
- Version 2.x require PHP 8.0 or higher.
- Version 1.x supports PHP 5.3 to 7.4
Installation via Composer
Add this to composer.json require block.
Getting Started
This is a quick start to convert URL to link:
Use Autolink Object
Create the object:
Create with options.
Convert Text
This is an example text:
We convert all URLs.
Output:
Add Attributes
All link will add this attributes:
Convert Email
Email url has no scheme, we use anoter method to convert them, and it will add mailto:
at begin of href
.
Output
Attributes Escaping
As htmlspecialchars()
in PHP 8.1 or higher will escape single quote as default,
Autolink will also escape single quote even in 8.0. Use this method to keep all escape
behavior same at any PHP versions:
If you want to change the escape behavior, set your custom escape handler:
Options
text_limit
We can set this option by constructor or setter:
The link text will be:
Use Your own limit handler by set a callback:
Or use \Asika\Autolink\LinkHelper::shorten()
Pretty handler:
Output:
auto_title
Use AutoTitle to force add title on anchor element.
Output:
strip_scheme
Strip Scheme on link text:
Output
escape
Auto escape URL, default is true
:
Output
link_no_scheme
Convert URL which no scheme. If you pass TRUE
to this option, Autolink will use
http
as default scheme, you can also provide your own default scheme.
Output
Scheme
You can add new scheme to convert URL begin with it, for example: vnc://example.com
Default schemes is http, https, ftp, ftps
.
Link Builder
If you don't want to use <a>
element as your link, you can set a callback to build link HTML.