darkside666 / ds-tools
该软件包最新版本(dev-main)没有提供许可信息。
dev-main
2022-08-17 11:30 UTC
Requires
- php: >=7.2
- ext-curl: *
- ext-json: *
- kevinlebrun/colors.php: ~1
- psr/log: ~1.0
This package is auto-updated.
Last update: 2024-09-17 15:49:23 UTC
README
此仓库包含各种有用的工具。其中一些工具相互依赖,但其他工具则完全独立。
安装
composer require darkside666/ds-tools
日志记录器
使用方法
// Create Logger instance
$logger = new dsTools\Logger();
// Multiple levels of logging - success, debug, info, notice, warning, error, critical, alert, emergency
$logger->notice('Download process started');
// Can use emergency() to stop program execution
try {
// ... something ...
} catch (\Exception $e) {
$logger->emergency($e->getMessage());
}
CKAN 下载器
使用方法
// Create Downloader instance
$downloader = new dsTools\CKAN\Downloader([
// CKAN API URL and key. For example, https://data.gov.lv/dati/api/3/
'api_url' => API_URL,
'api_key' => API_KEY,
// Folder where resources (files) will be downloaded
'download_folder' => TMP_FOLDER,
// Folder where files will be unzipped
'unzip_folder' => DATA_FOLDER,
]);
// This is how to download all resources (files) of particular CKAN package
$downloader->download('kadastra-informacijas-sistemas-atverti-telpiskie-dati');
// This is how to download particular resource (file) and unzip it
$files = $downloader->download('valsts-adresu-registra-informacijas-sistemas-atvertie-dati', 'aw_shp.zip', true);