Skip to content

Commit a3eb56a

Browse files
miladrahimiMilad Rahimi
authored andcommitted
re-implement the package
1 parent 02ed5c0 commit a3eb56a

17 files changed

+1482
-4
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
/.idea
1+
/.idea
2+
/vendor
3+
/composer.lock
4+
/tests/index.php

composer.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "miladrahimi/phprouter",
3-
"description": "URL router for PHP projects",
4-
"keywords": ["Router", "URL Router", "Routing", "URL Routing", "URL", "Route"],
3+
"description": "HTTP URL Router for PHP Projects",
4+
"keywords": ["Router", "URL Router", "HTTP Router", "Routing", "URL", "HTTP", "Route"],
55
"homepage": "https://github.com/miladrahimi/phprouter",
66
"type": "library",
77
"license": "MIT",
@@ -18,7 +18,11 @@
1818
"source": "https://github.com/miladrahimi/phprouter/issues"
1919
},
2020
"require": {
21-
"php": ">=7.0"
21+
"php": ">=7.0",
22+
"zendframework/zend-diactoros": "^1.7"
23+
},
24+
"require-dev": {
25+
"phpunit/phpunit": "^6"
2226
},
2327
"autoload": {
2428
"psr-4": {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: Milad Rahimi <[email protected]>
5+
* Date: 7/9/2018 AD
6+
* Time: 14:39
7+
*/
8+
9+
namespace MiladRahimi\Router\Enums;
10+
11+
class HttpMethods
12+
{
13+
const GET = 'GET';
14+
const POST = 'POST';
15+
const PUT = 'PUT';
16+
const PATCH = 'PATCH';
17+
const DELETE = 'DELETE';
18+
const OPTIONS = 'OPTIONS';
19+
const HEAD = 'HEAD';
20+
const CONNECT = 'CONNECT';
21+
const TRACE = 'TRACE';
22+
23+
/**
24+
* Standardize the http method
25+
*
26+
* @param string $method
27+
* @return string
28+
*/
29+
public static function custom(string $method): string
30+
{
31+
return strtoupper($method);
32+
}
33+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: Milad Rahimi <[email protected]>
5+
* Date: 6/23/2018 AD
6+
* Time: 01:38
7+
*/
8+
9+
namespace MiladRahimi\Router\Enums;
10+
11+
class RouteAttributes
12+
{
13+
const URI = 'uri';
14+
const METHOD = 'method';
15+
const CONTROLLER = 'controller';
16+
const MIDDLEWARE = 'middleware';
17+
const DOMAIN = 'domain';
18+
const PREFIX = 'prefix';
19+
const NAME = 'name';
20+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: Milad Rahimi <[email protected]>
5+
* Date: 7/8/2018 AD
6+
* Time: 22:30
7+
*/
8+
9+
namespace MiladRahimi\Router\Exceptions;
10+
11+
use Exception;
12+
13+
class InvalidControllerException extends Exception
14+
{
15+
// Nada
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: Milad Rahimi <[email protected]>
5+
* Date: 6/23/2018 AD
6+
* Time: 01:44
7+
*/
8+
9+
namespace MiladRahimi\Router\Exceptions;
10+
11+
use Exception;
12+
13+
class InvalidMiddlewareException extends Exception
14+
{
15+
// Nada
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: Milad Rahimi <[email protected]>
5+
* Date: 7/8/2018 AD
6+
* Time: 23:11
7+
*/
8+
9+
namespace MiladRahimi\Router\Exceptions;
10+
11+
use Exception;
12+
13+
class RouteNotFoundException extends Exception
14+
{
15+
// Nada
16+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: Milad Rahimi <[email protected]>
5+
* Date: 6/23/2018 AD
6+
* Time: 01:31
7+
*/
8+
9+
namespace MiladRahimi\Router;
10+
11+
use Closure;
12+
use Psr\Http\Message\ResponseInterface;
13+
use Psr\Http\Message\ServerRequestInterface;
14+
15+
interface Middleware
16+
{
17+
/**
18+
* Handle user request
19+
*
20+
* @param ServerRequestInterface $request
21+
* @param Closure $next
22+
* @return ResponseInterface
23+
*/
24+
public function handle(ServerRequestInterface $request, Closure $next);
25+
}

0 commit comments

Comments
 (0)