Download the PHP package yarri/link-finder without Composer

On this page you can find all versions of the php package yarri/link-finder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package link-finder

LinkFinder

Tests Downloads Codacy Badge

LinkFinder detects URLs and email addresses in plain text or HTML and wraps them in <a> tags. In HTML documents it only linkifies text that is not already linked.

Installation

Basic usage

Pass plain text to process(). URLs and email addresses are detected automatically.

HTML entities in the input are escaped by default, so plain text containing <, >, or & is safe to pass directly:

Extra attributes can be set on the generated <a> elements via the attrs and mailto_attrs options:

Processing HTML

Use processHtml() when the input is an HTML document. LinkFinder will skip content inside existing <a>, <script>, <style>, <textarea>, and <head> tags, and will only linkify bare URLs and emails in the visible text.

processHtml() is equivalent to calling process($html, ["escape_html_entities" => false]).

By default, URLs inside headline elements (<h1> through <h6>) are left alone. To linkify them as well:

Options reference

All options can be passed to the constructor or as the second argument of process() / processHtml(). Options passed to a method override the constructor defaults for that call only.

Option Type Default Description
attrs array [] HTML attributes added to every link <a> element.
mailto_attrs array [] HTML attributes added to every mailto <a> element.
escape_html_entities bool true Escape <, >, &, " in the input before processing. Disable when the input is already HTML.
avoid_headlines bool true Skip linkification inside <h1><h6> elements when processing HTML.
prefer_https bool true Use https:// when no protocol is specified (e.g. www.example.com). Can also be set globally via the LINK_FINDER_PREFER_HTTPS constant before the class is loaded.
secured_websites array [] When prefer_https is false, list domains that should still get https://. Populated automatically from $_SERVER["HTTP_HOST"] when the current request is over HTTPS.
shorten_long_urls bool true Truncate the visible link text for long URLs. The href is never shortened.
shortened_url_max_length int 65 Maximum character length of the visible link text before truncation.
href_callback callable identity Transform the URL before it is written into the href attribute. See Callbacks.
mailto_callback callable "mailto:$email" Transform an email address before it is written into the href attribute. See Callbacks.
link_template string <a %attrs%>%url%</a> Template for link elements. See Custom templates.
mailto_template string <a %attrs%>%address%</a> Template for mailto elements. See Custom templates.
utf8 bool true Treat the input as UTF-8.

prefer_https and secured_websites

When prefer_https is true (the default), all bare URLs get https://. When it is false, you can still mark specific domains as secured:

When prefer_https is false and secured_websites is not set, LinkFinder automatically adds the current $_SERVER["HTTP_HOST"] (and its www. variant) if the request is served over HTTPS.

Long URL shortening

The visible link text is truncated at 65 characters by default. The href always contains the full URL.

Callbacks

href_callback

Runs on every detected URL just before it is written into the href attribute. Use it to route all external links through a redirect proxy, or to rewrite URLs in any other way.

The callback can also be set after construction:

Default: function($url){ return $url; }

mailto_callback

Runs on every detected email address before it is written into the href attribute. Use it to point email links at a webmail compose page instead of a mailto: URI.

The callback can also be set after construction:

Default: function($email){ return "mailto:$email"; }

Custom templates

The link_template and mailto_template options let you replace the entire <a> element with your own markup. The placeholder %attrs% is replaced with all rendered HTML attributes; %url% and %address% are replaced with the visible link text.

Testing

LinkFinder is tested automatically via GitHub Actions across PHP 5.6 to PHP 8.5.

Tests use the atk14/tester wrapper for phpunit/phpunit.

Install development dependencies:

Run the test suite:

License

LinkFinder is free software distributed under the terms of the MIT license.


All versions of link-finder with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package yarri/link-finder contains the following files

Loading the files please wait ...