Skip to content
Url matcher.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
.gitignore
.travis.yml
LICENSE.md
README.md
composer.json

README.md

ldrahnik/url-matcher

Build Status Latest stable Downloads total

Requirements

ldrahnik/url-matcher requires PHP 5.4 or higher.

Installation

Install url-matcher to your project using Composer:

$ composer require ldrahnik/url-matcher

Usage

create url

	$patterns = [
		'lang' => 'cz',
		'presenter' => 'home',
		'action' => 4
	];
	$mask = '[<lang>/]<presenter>/<action>';
	$matcher = new Matcher($mask, $patterns);
	
    	$results = $matcher->parse();
    	/*array [
		 'home/4',
		 'cz/home/4',
	];*/

confirm url

	$mask = '[<lang>/]<presenter>[/<action>]';
	$matcher = new Matcher($mask);

	$result = $matcher->match('en/admin');
	// true

Examples

	$mask = 'root/<folder>/<subfolder>/<file>.latte';
	
	$matcher = new UrlMatcher\Matcher($mask, [
		'folder' => '*',
		'subfolder' => 'foo',
		'file' => '*'
	]);
	
	$mask = $matcher->parse();
	// root/*/foo/*.latte

	foreach (glob($mask) as $filename) {
		echo basename($filename);
	}

Configuration

	$default = [
		'separator_lft' => '<',		
		'separator_rgt' => '>',		
		'optional_lft' => '[',		
		'optional_rgt' => ']'
	];
	$matcher = new Matcher(..., ..., $default);
You can’t perform that action at this time.