Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zhukmax/waymark
Router for php7.1+ projects
https://github.com/zhukmax/waymark
php7 router routing waymark
Last synced: 5 days ago
JSON representation
Router for php7.1+ projects
- Host: GitHub
- URL: https://github.com/zhukmax/waymark
- Owner: ZhukMax
- License: apache-2.0
- Created: 2020-01-14T10:48:51.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-07-26T13:28:25.000Z (over 4 years ago)
- Last Synced: 2023-07-16T08:41:20.608Z (over 1 year ago)
- Topics: php7, router, routing, waymark
- Language: PHP
- Homepage:
- Size: 57.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Waymark
[![Latest Version on Packagist][ico-version]][link-packagist]
[![Software License][ico-license]](license.md)
[![Total Downloads][ico-downloads]][link-downloads]Waymark is a router for php7.1+ projects like API.
## Install
Using composer:
```console
$ composer require zhukmax/waymark
```## Using
If you need Template engine in your project you can use your favorite like I use Twig in example, but if you need only json/csv responces then just use Waymark without any Template engine.
```php
$twig,
'namespace' => '\\ProjectName\\API\\Controllers',
'routes' => dirname(__FILE__).'/routes.json'
]))
->get('/api/users', IndexController::class, 'actionGetAll', 'json')
->output();
```
Json-file with routes example:
```json
{
"get": {
"/users": [
"NameOfControllerWithoutControllerSuffix",
"NameOfAction",
"html"
],
"/users/{id:int}": [
"NameOfControllerWithoutControllerSuffix",
"NameOfAction",
"html"
]
}
}
```
You can use Request static methods if you need $_GET/$_POST/$_FILES data in your action-method. The methods have basic data-filters for *intiger*, *email*, *boolean*, *array*, *files*, *images*.
Parameter in route can be only string (`{name:str}`) or integer (`{id:int}`).
```php
$date,
'page'=> $page
];
}public function tst(string $date, int $page)
{
return $this->tpl->render('index.twig', [
'date' => $date,
'page' => $page
]);
}
}
```## License
The Apache License Version 2.0. You can find text of License in the [License File](license.md).
[ico-version]: https://img.shields.io/packagist/v/zhukmax/waymark.svg
[ico-license]: https://img.shields.io/badge/license-Apache%202-brightgreen.svg
[ico-downloads]: https://img.shields.io/packagist/dt/zhukmax/waymark.svg[link-packagist]: https://packagist.org/packages/zhukmax/waymark
[link-downloads]: https://packagist.org/packages/zhukmax/waymark