PHP code example of weiliu / open
1. Go to this page and download the library: Download weiliu/open library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
weiliu / open example snippets
use Weiliu\Open\Factory;
use Weiliu\Open\Chaty\Application as Chaty;
use Weiliu\Open\UrlShortener\Application as UrlShortener;
// 公共配置(可选)
$config = [
'log' => [
'default' => 'daily',
'channels' => [
'daily' => [
'driver' => 'daily',
'path' => '/data/logs/open.log',
'level' => 'debug',
'days' => 14,
],
],
],
];
# 自有服务
// 聊天机器人
Factory::chaty(env('CHATY_APPID'), env('CHATY_APPSECRET'), Chaty::PRODUCTION_ENV, $config);
// CPS 商品库
Factory::cps();
// 短链
Factory::urlShortener(env('URL_SHORTENER_APPID'), env('URL_SHORTENER_APPSECRET'), null, UrlShortener::PRODUCTION_ENV, $config);
# 其他服务
// 钉钉
Factory::dingTalk($config);
$config = [
'log' => [
'default' => 'slack',
'channels' => [
// 例如这个给作为服务端时的日志
// driver => slack 可以合并多渠道
'slack' => [
'driver' => 'stack',
'channels' => ['log', 'errorLog'],
],
'log' => [
'driver' => 'daily',
// 绝对路径
'path' => '/data/logs/test_chaty_server.log',
'level' => 'debug',
'days' => 14
],
'errorLog' => [
'driver' => 'daily',
// 绝对路径
'path' => '/data/logs/test_chaty_server_error.log',
'level' => 'error',
'days' => 14
],
// 例如这个给作为客户端时的日志
'clientLog' => [
'driver' => 'daily',
// 绝对路径
'path' => '/data/logs/test_chaty_client.log',
'level' => 'debug',
'days' => 14
],
]
],
];