danielsitek / php-random-avatar
一个简单的服务,用于对GET请求返回随机的头像图片。
dev-master
2017-07-19 20:16 UTC
Requires
- php: >=5.6
- silex/silex: ~2.0
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is not auto-updated.
Last update: 2024-09-29 04:49:22 UTC
README
README
简介
Php-Random-Avatar是一个简单的服务,它对GET请求返回随机的图片。这是一个小型的个人项目,仅为了乐趣、学习和在PHP中实验而构建。
用法
示例
文件:app.php
$avatar = new App\Avatar(); $router = new App\Router($avatar); $avatar->set_image_root( __DIR__ . '/images' ); $avatar->set_images_array( array( 'man' => array( '/man/001.png', '/man/002.png', '/man/003.png', '/man/004.png', '/man/005.png' ), 'woman' => array( '/woman/001.png', '/woman/002.png', '/woman/003.png', '/woman/004.png', '/woman/005.png' ) ) ); if ( in_array( @$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1'] ) ) { $router->run(); } else { $router->use_https()->run(); }
将此仓库克隆到您的服务器/localhost,并在浏览器中打开它。
在浏览器中,您可以这样请求头像图片
/以从任何类别获取随机图片。
/man以从“男性”类别获取随机图片。
/woman以从“女性”类别获取随机图片。
许可证
有关更多信息,请参阅https://open-source.org.cn/licenses/MIT或附带的MIT文件。