Skip to content

Commit

Permalink
Merge 1925e24 into 65b336b
Browse files Browse the repository at this point in the history
  • Loading branch information
rez1dent3 committed Jun 15, 2018
2 parents 65b336b + 1925e24 commit a5bce22
Show file tree
Hide file tree
Showing 40 changed files with 2,669 additions and 1,141 deletions.
10 changes: 0 additions & 10 deletions apigen.yaml

This file was deleted.

8 changes: 2 additions & 6 deletions composer.json
Expand Up @@ -14,8 +14,7 @@
}
],
"require": {
"psr/cache": "^1.0",
"bavix/slice": "^1.0"
"psr/cache": "^1.0"
},
"require-dev": {
"tedivm/stash": "^0.14",
Expand All @@ -33,10 +32,7 @@
"autoload": {
"psr-4": {
"Bavix\\": "src/"
},
"files": [
"libs/helper.php"
]
}
},
"autoload-dev": {
"psr-4": {
Expand Down
7 changes: 7 additions & 0 deletions demo/build.php
@@ -0,0 +1,7 @@
<?php

include_once \dirname(__DIR__) . '/vendor/autoload.php';

var_dump(\Bavix\Router\Server::url('/hello')); // https://cli/hello
var_dump(\Bavix\Router\Server::url('/hello', 'router.local'));
var_dump(\Bavix\Router\Server::url('/hello', 'router.local', 'cli')); // https://cli/hello
79 changes: 0 additions & 79 deletions demo/global.json

This file was deleted.

15 changes: 12 additions & 3 deletions demo/global.php
Expand Up @@ -4,10 +4,10 @@

'http' => [

'type' => 'http',
'type' => 'prefix',

'protocol' => 'http', // optional null
'host' => '(.+\.)?example.com', // optional null
'host' => 'router\.local', // optional null

'resolver' => [

Expand Down Expand Up @@ -55,6 +55,15 @@
'methods' => ['FETCH', 'GET']
],

'demo' => [
'type' => 'pattern',
'path' => ['/demo(/<word>)', ['word' => '\w+']],

'defaults' => [
'line' => __LINE__
]
],

],

'methods' => ['POST', 'GET']
Expand Down Expand Up @@ -82,7 +91,7 @@
'default' => [
'type' => 'pattern',
'path' => [
'/<any:\w+>',
'/<any>',
[
'any' => '.*'
]
Expand Down
72 changes: 0 additions & 72 deletions demo/global.xml

This file was deleted.

62 changes: 0 additions & 62 deletions demo/global.yaml

This file was deleted.

12 changes: 12 additions & 0 deletions demo/groups.php
@@ -0,0 +1,12 @@
<?php

include_once \dirname(__DIR__) . '/vendor/autoload.php';

$group = new \Bavix\Router\Group('/api', function (\Bavix\Router\GroupResolution $route) {
$route->get('/hello');
$route->resource('/users')->only([
'create', 'store', 'update', 'destroy'
]);
});

var_dump((new \Bavix\Router\Loader($group->toArray()))->simplify());
20 changes: 13 additions & 7 deletions demo/index.php
Expand Up @@ -12,11 +12,17 @@
$route = $router->getCurrentRoute();

var_dump(
\Bavix\Router\route($route),
$route->getAttributes(),
$route->getDefaults(),
$route->getHttp(),
$route->getPath(),
$route->getRegex(),
$route->getRegexPath()
['getExtends' => $route->getExtends()],
['getAttributes' => $route->getAttributes()],
['getGroups' => $route->getGroups()],
['getDefaults' => $route->getDefaults()],
['getMethods' => $route->getMethods()],
['getMethod' => $route->getMethod()],
['getProtocol' => $route->getProtocol()],
['getHost' => $route->getHost()],
['getPath' => $route->getPath()],
['getPattern' => $route->getPattern()],
['getPathPattern' => $route->getPathPattern()],
['getPathValue' => $route->getPathValue()],
['getName' => $route->getName()]
);
9 changes: 9 additions & 0 deletions demo/loader-v2.php
@@ -0,0 +1,9 @@
<?php

include_once dirname(__DIR__) . '/vendor/autoload.php';

$loader = new \Bavix\Router\Loader(require __DIR__ . '/global.php');

foreach ($loader->simplify() as $key => $route) {
var_dump([$key => $route]);
}
4 changes: 2 additions & 2 deletions demo/loader.php
Expand Up @@ -5,10 +5,10 @@
$driver = new \Stash\Driver\FileSystem();
$pool = new \Stash\Pool($driver);

//$loader = new \Bavix\SDK\FileLoader\PHPLoader(__DIR__ . '/global.php');
$loader = new \Bavix\SDK\FileLoader\PHPLoader(__DIR__ . '/global.php');
//$loader = new \Bavix\SDK\FileLoader\JSONLoader(__DIR__ . '/global.json');
//$loader = new \Bavix\SDK\FileLoader\YamlLoader(__DIR__ . '/global.yaml');
$loader = new \Bavix\SDK\FileLoader\XmlLoader(__DIR__ . '/global.xml');
//$loader = new \Bavix\SDK\FileLoader\XmlLoader(__DIR__ . '/global.xml');
$slice = $loader->asSlice();

$router = new \Bavix\Router\Router($slice, $pool);
Expand Down
4 changes: 4 additions & 0 deletions demo/pattern.php
@@ -0,0 +1,4 @@
<?php

include_once \dirname(__DIR__) . '/vendor/autoload.php';

0 comments on commit a5bce22

Please sign in to comment.