PHPackages                             rnr1721/le7-links - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. rnr1721/le7-links

ActiveLibrary

rnr1721/le7-links
=================

PSR LinkInterface implementation for le7 MVC framework or any PHP8 PSR project

1.0.7(2y ago)0571MITPHPPHP &gt;=8.1

Since May 25Pushed 2y ago1 watchersCompare

[ Source](https://github.com/rnr1721/le7-links)[ Packagist](https://packagist.org/packages/rnr1721/le7-links)[ RSS](/packages/rnr1721-le7-links/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (9)Used By (1)

le7-links
=========

[](#le7-links)

PSR LinkInterface implementation for le7 MVC framework or any PHP8 PSR project This is not "clean" implementation, this is combination of EnvolvedLinkInterface, UriInterface and own ULinkInterface.

Requirements
------------

[](#requirements)

- PHP 8.1
- Composer

Installation
------------

[](#installation)

```
composer require rnr1721/le7-links
```

Testing
-------

[](#testing)

```
composer test
```

Usage
-----

[](#usage)

### Link

[](#link)

The Link class represents a LinkInterface, UriInterface and own ULinkInterface with additional functionality for manipulating URIs and rendering HTML anchor tags.

First, import the Link class:

```
use Core\Links\Link;
```

Create an instance of the Link class by providing the URI, link relation types, and additional attributes:

```
$link = new Link('https://example.com/page1', ['rel1'], ['attribute1' => 'value1']);
```

#### Retrieving URI Components

[](#retrieving-uri-components)

You can retrieve different components of the URI using the following methods:

```
$scheme = $link->getScheme();
$authority = $link->getAuthority();
$userInfo = $link->getUserInfo();
$host = $link->getHost();
$port = $link->getPort();
$path = $link->getPath();
$query = $link->getQuery();
$fragment = $link->getFragment();
```

#### Modifying URI Components

[](#modifying-uri-components)

You can create a modified version of the link by using the following methods:

```
$newLink = $link->withScheme('https');
$newLink = $link->withUserInfo('username', 'password');
$newLink = $link->withHost('example.com');
$newLink = $link->withPort(8080);
$newLink = $link->withPath('/new-path');
$newLink = $link->withQuery('param1=value1&param2=value2');
$newLink = $link->withFragment('section1');
```

#### Rendering HTML Anchor Tags

[](#rendering-html-anchor-tags)

To render the link as an HTML anchor tag, use the render method:

```
$html = $link->render();
```

The render method returns a string containing the HTML anchor tag.

#### Link Attributes

[](#link-attributes)

You can retrieve and modify the link's relation types and additional attributes using the following methods:

```
$rels = $link->getRels();
$hasRel = $link->hasRel('rel1');
$attributes = $link->getAttributes();
$href = $link->getHref();
$isTemplated = $link->isTemplated();
$attributeValue = $link->getAttribute('attribute1');

```

You can create a modified version of the link with updated relation types and attributes using the following methods:

```
$newLink = $link->withHref('https://example.com/page2');
$newLink = $link->withRel('rel2', 'rel3');
$newLink = $link->withoutRel('rel1');
$newLink = $link->withAttribute('attribute2', 'value2');
$newLink = $link->withoutAttribute('attribute1');
```

#### String Conversion

[](#string-conversion)

You can obtain the string representation of the link using the magic \_\_toString method:

```
$string = (string)$link;
```

### LinkProvider

[](#linkprovider)

The LinkProvider class is an implementation of the EvolvableLinkProviderInterface from the PSR-Link library. It is used to store and manage links.

First, import the LinkProvider class:

```
use Core\Links\LinkProvider;
```

Create an instance of the LinkProvider class:

```
$linkProvider = new LinkProvider();
```

#### Adding Links

[](#adding-links)

To add a link to the provider, use the withLink method:

```
use Core\Links\Link;

$link = new Link('https://example.com/page1', ['rel1'], ['attribute1' => 'value1']);
$linkProvider = $linkProvider->withLink($link);
```

You can chain multiple withLink calls to add multiple links:

```
$link1 = new Link('https://example.com/page1', ['rel1'], ['attribute1' => 'value1']);
$link2 = new Link('https://example.com/page2', ['rel2'], ['attribute2' => 'value2']);

$linkProvider = $linkProvider->withLink($link1)
                           ->withLink($link2);
```

#### Retrieving Links

[](#retrieving-links)

To retrieve all the links in the provider, use the getLinks method:

```
$links = $linkProvider->getLinks();
```

The getLinks method returns an array of LinkInterface objects.

#### Removing Links

[](#removing-links)

To remove a link from the provider, use the withoutLink method:

```
$linkProvider = $linkProvider->withoutLink($link);
```

#### Filtering Links

[](#filtering-links)

To retrieve links based on their relationship, use the getLinksByRel method:

```
$filteredLinks = $linkProvider->getLinksByRel('rel1');
```

The getLinksByRel method returns an array of LinkInterface objects that have the specified relationship.

#### Adding Multiple Links

[](#adding-multiple-links)

To add multiple links at once, use the withLinks method:

```
$links = [
    new Link('https://example.com/page1', ['rel1'], ['attribute1' => 'value1']),
    new Link('https://example.com/page2', ['rel2'], ['attribute2' => 'value2']),
];

$linkProvider = $linkProvider->withLinks($links);
```

#### Removing Multiple Links

[](#removing-multiple-links)

To remove multiple links at once, use the withoutLinks method:

```
$linkProvider = $linkProvider->withoutLinks($links);
```

The withoutLinks method takes an array of LinkInterface objects and removes them from the provider.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

8

Last Release

1075d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b056f4160d8f9302378726a35860b42bfa67c29760bb55fcacddfde2bfa6f6ac?d=identicon)[rnr1721](/maintainers/rnr1721)

---

Top Contributors

[![rnr1721](https://avatars.githubusercontent.com/u/122087344?v=4)](https://github.com/rnr1721 "rnr1721 (1 commits)")

---

Tags

psr13componentlinksle7le7-framework

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rnr1721-le7-links/health.svg)

```
[![Health](https://phpackages.com/badges/rnr1721-le7-links/health.svg)](https://phpackages.com/packages/rnr1721-le7-links)
```

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.3k86.3M2.2k](/packages/symfony-symfony)[kompo/kompo

Laravel &amp; Vue.js FullStack Components for Rapid Application Development

11812.4k21](/packages/kompo-kompo)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
