Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b897fa5

Browse files
Rename library from devcoder-xyz/php-router to phpdevcommunity/php-router and update namespaces
1 parent 068e05a commit b897fa5

15 files changed

+111
-2158
lines changed

‎README.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
# PHP Router : A versatile and efficient PHP routing solution designed to streamline route management within PHP applications.
2-
3-
[![Latest Stable Version](http://poser.pugx.org/devcoder-xyz/php-router/v)](https://packagist.org/packages/devcoder-xyz/php-router) [![Total Downloads](http://poser.pugx.org/devcoder-xyz/php-router/downloads)](https://packagist.org/packages/devcoder-xyz/php-router) [![Latest Unstable Version](http://poser.pugx.org/devcoder-xyz/php-router/v/unstable)](https://packagist.org/packages/devcoder-xyz/php-router) [![License](http://poser.pugx.org/devcoder-xyz/php-router/license)](https://packagist.org/packages/devcoder-xyz/php-router) [![PHP Version Require](http://poser.pugx.org/devcoder-xyz/php-router/require/php)](https://packagist.org/packages/devcoder-xyz/php-router)
4-
5-
## Description
1+
# PHP Router
62

73
PHP Router is a simple and efficient routing library designed for PHP applications. It provides a straightforward way to define routes, handle HTTP requests, and generate URLs. Built with PSR-7 message implementation in mind, it seamlessly integrates with PHP applications.
84

@@ -13,7 +9,7 @@ You can install PHP Router via Composer. Just run:
139

1410
### Composer Require
1511
```
16-
composer require devcoder-xyz/php-router
12+
composer require phpdevcommunity/php-router
1713
```
1814

1915
## Requirements
@@ -81,13 +77,13 @@ class ArticleController {
8177
```php
8278
// Define your routes
8379
$routes = [
84-
new \DevCoder\Route('home_page', '/', [IndexController::class]),
85-
new \DevCoder\Route('api_articles_collection', '/api/articles', [ArticleController::class, 'getAll']),
86-
new \DevCoder\Route('api_articles', '/api/articles/{id}', [ArticleController::class, 'get']),
80+
new \PhpDevCommunity\Route('home_page', '/', [IndexController::class]),
81+
new \PhpDevCommunity\Route('api_articles_collection', '/api/articles', [ArticleController::class, 'getAll']),
82+
new \PhpDevCommunity\Route('api_articles', '/api/articles/{id}', [ArticleController::class, 'get']),
8783
];
8884

8985
// Initialize the router
90-
$router = new \DevCoder\Router($routes, 'http://localhost');
86+
$router = new \PhpDevCommunity\Router($routes, 'http://localhost');
9187

9288
try {
9389
// Match incoming request
@@ -106,10 +102,10 @@ try {
106102
}
107103
echo $controller(...array_values($attributes));
108104

109-
} catch (\DevCoder\Exception\MethodNotAllowed $exception) {
105+
} catch (\PhpDevCommunity\Exception\MethodNotAllowed $exception) {
110106
header("HTTP/1.0 405 Method Not Allowed");
111107
exit();
112-
} catch (\DevCoder\Exception\RouteNotFound $exception) {
108+
} catch (\PhpDevCommunity\Exception\RouteNotFound $exception) {
113109
header("HTTP/1.0 404 Not Found");
114110
exit();
115111
}
@@ -127,8 +123,8 @@ try {
127123
Routes can be defined using the `Route` class provided by PHP Router. You can specify HTTP methods, attribute constraints, and handler methods for each route.
128124

129125
```php
130-
$route = new \DevCoder\Route('api_articles_post', '/api/articles', [ArticleController::class, 'post'], ['POST']);
131-
$route = new \DevCoder\Route('api_articles_put', '/api/articles/{id}', [ArticleController::class, 'put'], ['PUT']);
126+
$route = new \PhpDevCommunity\Route('api_articles_post', '/api/articles', [ArticleController::class, 'post'], ['POST']);
127+
$route = new \PhpDevCommunity\Route('api_articles_put', '/api/articles/{id}', [ArticleController::class, 'put'], ['PUT']);
132128
```
133129
### Easier Route Definition with Static Methods
134130

@@ -364,5 +360,10 @@ echo $router->generateUri('home_page'); // /
364360
echo $router->generateUri('api_articles', ['id' => 1]); // /api/articles/1
365361
echo $router->generateUri('api_articles', ['id' => 1], true); // http://localhost/api/articles/1
366362
```
363+
## Contributing
364+
365+
Contributions are welcome! Feel free to open issues or submit pull requests to help improve the library.
366+
367+
## License
367368

368-
Ideal for small to medium-sized projects, PHP Router offers simplicity and efficiency in handling routing tasks for PHP applications.
369+
This library is open-source software licensed under the [MIT license](https://opensource.org/licenses/MIT).

‎composer.json

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
11
{
2-
"name": "devcoder-xyz/php-router",
2+
"name": "phpdevcommunity/php-router",
33
"description": "A versatile and efficient PHP routing solution designed to streamline route management within PHP applications.",
4-
"type": "package",
4+
"type": "library",
55
"autoload": {
66
"psr-4": {
7-
"DevCoder\\": "src",
8-
"Test\\DevCoder\\": "tests"
7+
"PhpDevCommunity\\": "src",
8+
"Test\\PhpDevCommunity\\": "tests"
99
}
1010
},
1111
"license": "MIT",
1212
"authors": [
1313
{
14-
"name": "F.Michel",
15-
"email": "dev@devcoder.xyz"
14+
"name": "F.Michel",
15+
"homepage": "https://www.phpdevcommunity.com"
1616
}
1717
],
18+
"minimum-stability": "alpha",
1819
"require": {
1920
"php": ">=7.4",
20-
"psr/http-message": "^1.0",
21+
"psr/http-message": "^1.0|^2.0",
2122
"psr/http-server-middleware": "^1.0",
2223
"psr/http-factory": "^1.0"
2324
},
2425
"require-dev": {
25-
"phpunit/phpunit": "^9.5"
26-
},
27-
"config": {
28-
"allow-plugins": {
29-
"dealerdirect/phpcodesniffer-composer-installer": false
30-
}
26+
"phpdevcommunity/unitester": "^0.1.0@alpha"
3127
}
3228
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /