Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need config file writing approuval #284

Draft
wants to merge 82 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
c60a124
Update AltoRouter.php to a new name EdgeAltoRouter.php
Acksop Feb 29, 2024
7520181
Rename AltoRouter.php to EdgeAltoRouter.php
Acksop Feb 29, 2024
031235d
Create indexWithConfigFile.php
Acksop Feb 29, 2024
34b0481
Update EdgeAltoRouter.php
Acksop Feb 29, 2024
3c441ec
Create route.config
Acksop Feb 29, 2024
9928e7f
Update index.php
Acksop Feb 29, 2024
91e9e61
Update indexWithConfigFile.php
Acksop Feb 29, 2024
ebcdf05
Update composer.json
Acksop Feb 29, 2024
9decd64
Update AltoRouterTest.php
Acksop Feb 29, 2024
9555101
reorganisation of examples
Acksop Feb 29, 2024
90fa490
Reorganization of examples
Acksop Feb 29, 2024
24ee859
Adding entry of config file into tests
Acksop Feb 29, 2024
5b0dde8
update README
Acksop Feb 29, 2024
04aadd0
Update README.md
Acksop Feb 29, 2024
7aa0526
Update phpunit.xml.dist
Acksop Feb 29, 2024
38cf2fb
Update phpcs.xml
Acksop Feb 29, 2024
51ef94d
Rename AltoRouterTest.php to EdgeAltoRouterTest.php
Acksop Feb 29, 2024
f45ae92
Update EdgeAltoRouter.php
Acksop Feb 29, 2024
ef73e76
Update README.md
Acksop Feb 29, 2024
7aeda1f
Update EdgeAltoRouter.php
Acksop Mar 1, 2024
688e55d
Update EdgeAltoRouter.php
Acksop Mar 1, 2024
189f9fa
Update php.yml
Acksop Mar 1, 2024
da01890
Update EdgeAltoRouter.php
Acksop Mar 1, 2024
fb616a3
Update EdgeAltoRouterTest.php
Acksop Mar 1, 2024
3f44842
Update EdgeAltoRouterTest.php
Acksop Mar 1, 2024
5af22a4
Update EdgeAltoRouter.php
Acksop Mar 1, 2024
3d2e167
Update EdgeAltoRouter.php
Acksop Mar 1, 2024
5782d2c
Update EdgeAltoRouter.php
Acksop Mar 1, 2024
3fa4bf0
Debugging EdgeAltoRouter.php
Acksop Mar 1, 2024
d8050a5
Debugging setRouteFromConfig in EdgeAltoRouter.php
Acksop Mar 1, 2024
4ee4eeb
Debugging YamlLikeFileConfig EdgeAltoRouter.php
Acksop Mar 1, 2024
170e531
fix route.config on exception of altorouter
Acksop Mar 1, 2024
459c575
Debugging regexpr EdgeAltoRouter.php
Acksop Mar 1, 2024
d00e867
debugging Yaml Array value
Acksop Mar 1, 2024
6544165
debugging regexpr
Acksop Mar 1, 2024
658840b
debugging regexpr
Acksop Mar 1, 2024
3102831
debug
Acksop Mar 1, 2024
6be6e55
Debugging setRouteFromConfig file
Acksop Mar 1, 2024
fc40f9b
debugging regexpr
Acksop Mar 1, 2024
e1d23cf
fix debug
Acksop Mar 1, 2024
ecaa42e
fix tests
Acksop Mar 1, 2024
660dcdf
fixing test
Acksop Mar 1, 2024
2e8461d
fixing tests
Acksop Mar 1, 2024
161daaf
testing
Acksop Mar 1, 2024
57e4020
testing
Acksop Mar 1, 2024
fe9e204
testing
Acksop Mar 1, 2024
b14f17e
testings
Acksop Mar 1, 2024
7f001e2
forget semicolons
Acksop Mar 1, 2024
23bb1ea
trim name value on EdgeAltoRouter
Acksop Mar 1, 2024
c95259d
final modification before draft push on fork
Acksop Mar 1, 2024
33ed5bf
Update README.md
Acksop Mar 1, 2024
9c76e7e
Update exception and remove a print_r on EdgeAltoRouter.php
Acksop Mar 1, 2024
65753fe
Update EdgeAltoRouter.php
Acksop Mar 1, 2024
61469cb
Update mb_encoding of EdgeAltoRouter.php
Acksop Mar 1, 2024
4e1cfea
Update EdgeAltoRouterTest.php
Acksop Mar 1, 2024
47925ce
Update EdgeAltoRouter.php
Acksop Mar 1, 2024
867635c
Re-create AltoRouter.php
Acksop Mar 2, 2024
e2fab18
Update EdgeAltoRouter.php to inherit from AltoRouter.php
Acksop Mar 2, 2024
6b40ef8
re-create AltoRouterTest.php
Acksop Mar 2, 2024
289d27c
Update EdgeAltoRouterTest.php to inherit from AltoRouter.php
Acksop Mar 2, 2024
66cac0f
Update phpunit.xml.dist
Acksop Mar 2, 2024
94e6eec
Update EdgeAltoRouter.php
Acksop Mar 2, 2024
4d19043
Update EdgeAltoRouter.php
Acksop Mar 2, 2024
f2c897e
Rename route.config to route.model
Acksop Mar 2, 2024
2026ae3
Update EdgeAltoRouterTest.php
Acksop Mar 2, 2024
d3d7275
Rename route.config to route.model
Acksop Mar 2, 2024
61001d8
Update index.php
Acksop Mar 2, 2024
7070bb4
reindexing examples
Acksop Mar 2, 2024
6bc5757
update composer.json and phpcs
Acksop Mar 2, 2024
5c0cb56
Update EdgeAltoRouterTest.php
Acksop Mar 2, 2024
7b5adc2
Update EdgeAltoRouterTest.php
Acksop Mar 2, 2024
1c13353
Fixing EdgeAltoRouter.php
Acksop Mar 2, 2024
522f041
Adding four config files on example to test implementation
Acksop Mar 2, 2024
f38397d
Update README.md
Acksop Mar 26, 2024
2700877
Update EdgeAltoRouter.php
Acksop May 19, 2024
e9fab58
Update EdgeAltoRouter.php
Acksop May 19, 2024
ab1314c
Update EdgeAltoRouter.php
Acksop May 19, 2024
2c14aaa
Update EdgeAltoRouterTest.php
Acksop May 19, 2024
9ca0feb
Update EdgeAltoRouterTest.php
Acksop May 19, 2024
3f29b7a
Update EdgeAltoRouterTest.php
Acksop May 19, 2024
1a56cbf
Update EdgeAltoRouterTest.php
Acksop May 19, 2024
789d4d2
Update README.md
Acksop May 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ '7.3', '8.0', '8.3' ]
php-versions: [ '8.0', '8.1', '8.2', '8.3' ]

steps:
- uses: actions/checkout@v2
Expand Down
140 changes: 140 additions & 0 deletions EdgeAltoRouter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<?php
/*
MIT License

Copyright (c) 2024 ROY Emmanuel <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

class EdgeAltoRouter extends AltoRouter
{

const USE_SPEED = 0; //Need less cpu but consumes more electric energy
const USE_MEMORY = 1; //Need more cpu but consumes less electric energy

/**
* Create router in one call from multiple type of configfile.
*
* @param array $routes
* @param string $basePath
* @param array $matchTypes
* @param string $configModelUrl
* @param int $usage
* @throws Exception
*/
public function __construct(array $routes = [], string $basePath = '', array $matchTypes = [], string $configModelUrl = __DIR__.DIRECTORY_SEPARATOR.'routes.model', int $usage = self::USE_MEMORY)
{
$this->addRoutes($routes);
$this->setBasePath($basePath);
$this->addMatchTypes($matchTypes);
if(file_exists($configModelUrl)){
$this->setRouteFromConfig($configModelUrl,$usage);
}
}

/**
* Load all routes in one call from a multiple type of config file.
*
* @param string $configUrl
* @param int $usage
* @throws Exception
*/
public function setRouteFromConfig($configUrl, $usage){
if(file_exists($configUrl)){
$path_parts = pathinfo($configUrl);
switch($path_parts['extension']){
case 'model':
$this->mappingRouteFromConfigModelFile($configUrl, $usage);
break;
case 'csv':
case 'json':
case 'yaml':
case 'yml':
default:
throw new RuntimeException('error : configfile type is not implemented yet');
}
}else{
throw new RuntimeException('error : configfile is not found');
}
}

/**
* Load all routes in one call from a .model config file.
*
* @link: .model is a filetype invention of Emmanuel ROY, initialy developed for SAND-framework --> https://github.com/Acksop/SAND-framework
*
* @param string $configUrl
* @param int $usage
* @throws Exception
*/
public function mappingRouteFromConfigModelFile($fileUrl, $usage){
if(file_exists($fileUrl)){
$file = file($fileUrl);
if($usage == self::USE_MEMORY){
$bigArray = array();
}
foreach ($file as $line_num => $line) {
//searching pattern parameters
if (preg_match("#[ ]*([a-zA-Z_+ ]*)[:][ ]*([a-zA-Z0-9:\/\\ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ_+\-'\"\{\,\ \}\(\)\[\]\|=>\#]*[ ]*)#", $line, $matches)) {
//searching array pattern
if (preg_match("#{.*}#", $matches[2])) {
if (preg_match_all("#(?<capture>((\[([0-9a-zA-ZÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ_\-=>'\" ]*,?)*\])|([0-9a-zA-Z\/\\ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ_+\-\[\]:\|\#]*)))#", $matches[2], $arrayMatches)) {
$array = array();
foreach ($arrayMatches['capture'] as $capturedValue) {
if(preg_match("#^\[((.*=>.*),?)*\]$#", $capturedValue)){
$capturedArrayIndex = array();
$capturedArray = array();
if (preg_match_all("#(?<capture>[0-9a-zA-Z:ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ_+\-]*)#", trim($capturedValue), $capturedArrayMatches)) {
foreach ($capturedArrayMatches['capture'] as $capturedArrayValue) {
if (trim($capturedArrayValue) !== ''){
$capturedArrayIndex[] = mb_convert_encoding( trim($capturedArrayValue), 'UTF-8', mb_detect_encoding( $capturedArrayValue, 'auto') );
}
}
if(count($capturedArrayIndex)%2 !== 0){
$capturedArray = 'error : some key of the array has no values';
throw new RuntimeException('error : some key of the array in configfile has no values');
}else{
for($i = 0; $i < count($capturedArrayIndex) ; $i = $i+2){
$capturedArray[mb_convert_encoding( trim($capturedArrayIndex[$i]), 'UTF-8', mb_detect_encoding( $capturedArrayIndex[$i], 'auto'))] = mb_convert_encoding( trim($capturedArrayIndex[$i+1]), 'UTF-8', mb_detect_encoding( $capturedArrayIndex[$i+1], 'auto'));
}
}
}
$array[] = $capturedArray;
}else if(preg_match("#^\[((.*),?)*\]$#", $capturedValue)){
$capturedArray = array();
if (preg_match_all("#(?<capture>[0-9a-zA-Z:ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ_+\-]*)#", trim($capturedValue), $capturedArrayMatches)) {
foreach ($capturedArrayMatches['capture'] as $capturedArrayValue) {
if (trim($capturedArrayValue) != ''){
$capturedArray[] = mb_convert_encoding( trim($capturedArrayValue), 'UTF-8', mb_detect_encoding( $capturedArrayValue, 'auto') );
}
}
}
$array[] = $capturedArray;
}else if ($capturedValue != '') {
$array[] = mb_convert_encoding( trim($capturedValue), 'UTF-8', mb_detect_encoding( $capturedValue, 'auto') );
}
}
$array[] = trim($matches[1]);
if($usage == self::USE_SPEED){
$this->map(...$array);
}else{
$bigArray[] = $array;
}
continue;
}
}
}
}
if($usage == self::USE_MEMORY){
$this->addRoutes($bigArray);
}
}else{
throw new RuntimeException('error : configfile is not found');
}
}
}
52 changes: 34 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
# AltoRouter ![PHP status](https://github.com/dannyvankooten/AltoRouter/workflows/PHP/badge.svg) [![Latest Stable Version](https://poser.pugx.org/altorouter/altorouter/v/stable.svg)](https://packagist.org/packages/altorouter/altorouter) [![License](https://poser.pugx.org/altorouter/altorouter/license.svg)](https://packagist.org/packages/altorouter/altorouter)
# EdgeAltoRouter ![PHP status](https://github.com/Acksop/EdgeAltoRouter/workflows/PHP/badge.svg)

AltoRouter is a small but powerful routing class, heavily inspired by [klein.php](https://github.com/chriso/klein.php/).
EdgeAltoRouter is a small but powerful routing class, forked from [dannyvankooten.php](https://github.com/dannyvankooten/AltoRouter/) with an important addition : a config model file.

```php
$router = new AltoRouter();

// map homepage
$router->map('GET', '/', function() {
require __DIR__ . '/views/home.php';
});

// dynamic named route
$router->map('GET|POST', '/users/[i:id]/', function($id) {
$user = .....
require __DIR__ . '/views/user/details.php';
}, 'user-details');

// echo URL to user-details page for ID 5
echo $router->generate('user-details', ['id' => 5]); // Output: "/users/5"
$router = new EdgeAltoRouter(configModelUrl : __DIR__ . DIRECTORY_SEPARATOR . 'route.config');
$router->setBasePath(BASE_PATH);

$match = $router->match();

/*
* $match may is like :
* [
* 'target' => 'home#index',
* 'params' => [],
* 'name' => 'home'
* ]
*/

if( is_array($match) && is_callable( $match['target'] ) ) {
call_user_func_array( $match['name'], $match['params'] );
} else {
// no route was matched
header( $_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found');
}


// echo URL to home at index
echo $router->generate('home'); // Output: "home#index"
```

## Features
Expand All @@ -27,10 +36,14 @@ echo $router->generate('user-details', ['id' => 5]); // Output: "/users/5"
* Reversed routing
* Flexible regular expression routing (inspired by [Sinatra](http://www.sinatrarb.com/))
* Custom regexes
* Support a config file who is like Yaml
* Configure your style of use : Memory or Speed

## Getting started

You need PHP >= 7.3 to use AltoRouter, although we highly recommend you [use an officially supported PHP version](https://secure.php.net/supported-versions.php) that is not EOL.
You need PHP >= 8.0 to use EdgeAltoRouter, although we highly recommend you [use an officially supported PHP version](https://secure.php.net/supported-versions.php) that is not EOL.

## Official Documentation of the forked AltoRouter

- [Install AltoRouter](https://dannyvankooten.github.io/AltoRouter//usage/install.html)
- [Rewrite all requests to AltoRouter](https://dannyvankooten.github.io/AltoRouter//usage/rewrite-requests.html)
Expand All @@ -43,13 +56,16 @@ You need PHP >= 7.3 to use AltoRouter, although we highly recommend you [use an
- [Koen Punt](https://github.com/koenpunt)
- [John Long](https://github.com/adduc)
- [Niahoo Osef](https://github.com/niahoo)
- [Emmanuel ROY](https://github.com/acksop)

## License

MIT License

Copyright (c) 2012 Danny van Kooten <[email protected]>

Addition/modification 2024 ROY Emmanuel <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
Expand Down
16 changes: 10 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "altorouter/altorouter",
"description": "A lightning fast router for PHP",
"keywords": ["router", "routing", "lightweight"],
"homepage": "https://github.com/dannyvankooten/AltoRouter",
"name": "edgealtorouter/edgealtorouter",
"description": "A lightning fast router for PHP with config file",
"keywords": ["router", "routing", "lightweight","configfile"],
"homepage": "https://github.com/Acksop/EdgeAltoRouter",
"license": "MIT",
"authors": [
{
Expand All @@ -17,17 +17,21 @@
{
"name": "niahoo",
"homepage": "https://github.com/niahoo"
},
{
"name": "Emmanuel ROY",
"homepage": "https://github.com/Acksop"
}
],
"require": {
"php": ">=7.3"
"php": ">=8.0.0"
},
"require-dev": {
"phpunit/phpunit": "9.6.*",
"squizlabs/php_codesniffer": "3.6.2"
},
"autoload": {
"classmap": ["AltoRouter.php"]
"classmap": ["AltoRouter.php","EdgeAltoRouter.php"]
},
"scripts": {
"test": "vendor/bin/phpunit"
Expand Down
6 changes: 3 additions & 3 deletions examples/basic/index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require __DIR__ . '/../../AltoRouter.php';
require __DIR__ . '/../../EdgeAltoRouter.php';

/**
* This can be useful if you're using PHP's built-in web server, to serve files like images or css
Expand All @@ -10,8 +10,8 @@
return;
}

$router = new AltoRouter();
$router->setBasePath('/AltoRouter/examples/basic');
$router = new EdgeAltoRouter();
$router->setBasePath('/EdgeAltoRouter/examples/basic');
$router->map('GET|POST', '/', 'home#index', 'home');
$router->map('GET', '/users/', ['c' => 'UserController', 'a' => 'ListAction']);
$router->map('GET', '/users/[i:id]', 'users#show', 'users_show');
Expand Down
3 changes: 3 additions & 0 deletions examples/configfile/csv/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
31 changes: 31 additions & 0 deletions examples/configfile/csv/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

require __DIR__ . '/../../EdgeAltoRouter.php';

/**
* This can be useful if you're using PHP's built-in web server, to serve files like images or css
* @link https://secure.php.net/manual/en/features.commandline.webserver.php
*/
if (file_exists($_SERVER['SCRIPT_FILENAME']) && pathinfo($_SERVER['SCRIPT_FILENAME'], PATHINFO_EXTENSION) !== 'php') {
return;
}

$router = new EdgeAltoRouter(configModelUrl: __DIR__.DIRECTORY_SEPARATOR."routes.csv");
$router->setBasePath('/EdgeAltoRouter/examples/basic');

// match current request
$match = $router->match();
?>
<h1>AltoRouter</h1>

<h3>Current request: </h3>
<pre>
Target: <?php var_dump($match['target']); ?>
Params: <?php var_dump($match['params']); ?>
Name: <?php var_dump($match['name']); ?>
</pre>

<h3>Try these requests: </h3>
<p><a href="<?php echo $router->generate('home'); ?>">GET <?php echo $router->generate('home'); ?></a></p>
<p><a href="<?php echo $router->generate('users_show', ['id' => 5]); ?>">GET <?php echo $router->generate('users_show', ['id' => 5]); ?></a></p>
<p><form action="<?php echo $router->generate('users_do', ['id' => 10, 'action' => 'update']); ?>" method="post"><button type="submit"><?php echo $router->generate('users_do', ['id' => 10, 'action' => 'update']); ?></button></form></p>
4 changes: 4 additions & 0 deletions examples/configfile/csv/route.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'GET|POST', '/', 'home#index','home'
'GET', '/users/', ['c' => 'UserController', 'a' => 'ListAction']
'GET', '/users/[i:id]', 'users#show','users_show'
'POST', '/users/[i:id]/[delete|update:action]', 'usersController#doAction','users_do'
3 changes: 3 additions & 0 deletions examples/configfile/json/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
31 changes: 31 additions & 0 deletions examples/configfile/json/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

require __DIR__ . '/../../EdgeAltoRouter.php';

/**
* This can be useful if you're using PHP's built-in web server, to serve files like images or css
* @link https://secure.php.net/manual/en/features.commandline.webserver.php
*/
if (file_exists($_SERVER['SCRIPT_FILENAME']) && pathinfo($_SERVER['SCRIPT_FILENAME'], PATHINFO_EXTENSION) !== 'php') {
return;
}

$router = new EdgeAltoRouter(configModelUrl: __DIR__.DIRECTORY_SEPARATOR."routes.json");
$router->setBasePath('/EdgeAltoRouter/examples/basic');

// match current request
$match = $router->match();
?>
<h1>AltoRouter</h1>

<h3>Current request: </h3>
<pre>
Target: <?php var_dump($match['target']); ?>
Params: <?php var_dump($match['params']); ?>
Name: <?php var_dump($match['name']); ?>
</pre>

<h3>Try these requests: </h3>
<p><a href="<?php echo $router->generate('home'); ?>">GET <?php echo $router->generate('home'); ?></a></p>
<p><a href="<?php echo $router->generate('users_show', ['id' => 5]); ?>">GET <?php echo $router->generate('users_show', ['id' => 5]); ?></a></p>
<p><form action="<?php echo $router->generate('users_do', ['id' => 10, 'action' => 'update']); ?>" method="post"><button type="submit"><?php echo $router->generate('users_do', ['id' => 10, 'action' => 'update']); ?></button></form></p>
24 changes: 24 additions & 0 deletions examples/configfile/json/route.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"routes": {
"home": [
"GET|POST",
"/",
"home#index"
],
"": [
"GET",
"/users/",
{ "c": "UserController", "a": "ListAction" }
],
"users_show": [
"GET",
"/users/[i:id]",
"users#show"
],
"users_do": [
"POST",
"/users/[i:id]/[delete|update:action]",
"usersController#doAction"
]
}
}
3 changes: 3 additions & 0 deletions examples/configfile/model/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
Loading