https://github.com/zweifisch/zf
a micro php framework/router for both web and cli
https://github.com/zweifisch/zf
Last synced: 4 months ago
JSON representation
a micro php framework/router for both web and cli
- Host: GitHub
- URL: https://github.com/zweifisch/zf
- Owner: zweifisch
- Created: 2013-04-28T08:47:45.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-10-29T01:16:50.000Z (over 10 years ago)
- Last Synced: 2024-12-02T22:26:24.465Z (6 months ago)
- Language: PHP
- Homepage:
- Size: 886 KB
- Stars: 34
- Watchers: 7
- Forks: 16
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# zf [](https://travis-ci.org/zweifisch/zf)
a micro php framework for both web and cli
*requires php 5.6*
## a taste of zf
```php
get('/hello/:name', function($name, $times=1) {
return ['hello' => $name, 'times' => $times];
});$app->get('/', function() {
return $this->render('landing-page');
});$app->resource('post', 'user');
$app->run();
``````
$ php -S localhost:8000/index.php &> /tmp/server.log
$ curl localhost:8000/hello/foo?times=3
{"hello": "foo", "times': 3}
```### cli
```php
cmd('hello ', function($name, $times=1) {
return str_repeat("hello $name\n", $times);
})/**
* @param bool $showDate also print date
*/
$app->cmd('time', function($showDate=false) {
return date($showDate ? 'Y-m-d H:i:s' : 'H:i:s');
});$app->run();
``````sh
$ php cli.php
Usage:php cli.php hello
name your name
--times times to repeatphp cli.php time
--show-date also print date
``````sh
$ php cli.php hello --times=2 zf
hello zf
hello zf
```work in progress [documentation](http://zweifisch.github.io/zf-doc/getting_started.html)
## tests
to run tests
```sh
composer.phar install --dev
CONFIG_FILE=test/configs.php vendor/bin/phpunit -c test
```