Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/zhukmax/waymark

Router for php7.1+ projects
https://github.com/zhukmax/waymark

php7 router routing waymark

Last synced: about 1 month ago
JSON representation

Router for php7.1+ projects

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