Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ldrahnik/url-matcher
Url matcher.
https://github.com/ldrahnik/url-matcher
nette package php
Last synced: 10 days ago
JSON representation
Url matcher.
- Host: GitHub
- URL: https://github.com/ldrahnik/url-matcher
- Owner: ldrahnik
- License: other
- Created: 2015-03-29T14:29:58.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-10-17T19:27:21.000Z (over 7 years ago)
- Last Synced: 2024-12-14T02:16:29.368Z (about 1 month ago)
- Topics: nette, package, php
- Language: PHP
- Homepage:
- Size: 33.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
ldrahnik/url-matcher
======[![Build Status](https://travis-ci.org/ldrahnik/url-matcher.svg)](https://travis-ci.org/ldrahnik/url-matcher)
[![Latest stable](https://img.shields.io/packagist/v/ldrahnik/url-matcher.svg)](https://packagist.org/packages/ldrahnik/url-matcher)
[![Downloads total](https://img.shields.io/packagist/dt/ldrahnik/url-matcher.svg?style=flat-square)](https://packagist.org/packages/ldrahnik/url-matcher)Requirements
------------ldrahnik/url-matcher requires PHP 5.4 or higher.
- [Nette Framework](https://github.com/nette/nette)
Installation
------------Install url-matcher to your project using [Composer](http://getcomposer.org/):
```sh
$ composer require ldrahnik/url-matcher
```Usage
-----create url
```php
$patterns = [
'lang' => 'cz',
'presenter' => 'home',
'action' => 4
];
$mask = '[/]/';
$matcher = new Matcher($mask, $patterns);
$results = $matcher->parse();
/*array [
'home/4',
'cz/home/4',
];*/
```confirm url
```php
$mask = '[/][/]';
$matcher = new Matcher($mask);$result = $matcher->match('en/admin');
// true
```
Examples
------------```php
$mask = 'root///.latte';
$matcher = new UrlMatcher\Matcher($mask, [
'folder' => '*',
'subfolder' => 'foo',
'file' => '*'
]);
$mask = $matcher->parse();
// root/*/foo/*.latteforeach (glob($mask) as $filename) {
echo basename($filename);
}
```Configuration
-------------```php
$default = [
'separator_lft' => '<',
'separator_rgt' => '>',
'optional_lft' => '[',
'optional_rgt' => ']'
];
$matcher = new Matcher(..., ..., $default);
```