PHP code example of nextras / link-factory
1. Go to this page and download the library: Download nextras/link-factory library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nextras / link-factory example snippets
use Nextras\Application\LinkFactory;
class Example
{
/** @var LinkFactory */
private $linkFactory;
public function __construct(LinkFactory $linkFactory)
{
$this->linkFactory = $linkFactory;
}
public function doSomething()
{
// relative link with optional fragment (#comments) and parameters
$link = $this->linkFactory->link('Products:view#comments', ['id' => 123]);
// absolute link starts with '//'
$link = $this->linkFactory->link('//Homepage:default');
}
}