Skip to content

Commit 5af7700

Browse files
authored
Merge pull request #4 from kilingzhang/v2
接口更新 修复接口 添加docker镜像 # 后续添加新接口
2 parents fa0e8c8 + 61bdc0a commit 5af7700

File tree

125 files changed

+5576
-5240
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+5576
-5240
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea/
2+
composer.lock
3+
vendor
4+
NeteaseCloudMusicApiSdk

.htaccess

Lines changed: 0 additions & 6 deletions
This file was deleted.

.travis.yml

100644100755
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
language: php
2+
3+
os:
4+
- linux
5+
6+
services:
7+
- docker
8+
29
php:
3-
- 5.5
10+
- 7.1
11+
- 7.2
12+
- 7.3
13+
- 7.4
14+
- nightly
15+
416

17+
notifications:
18+
email: i@kilingzhang.com

Autoloader.php

Lines changed: 0 additions & 13 deletions
This file was deleted.

Config.php

Lines changed: 0 additions & 22 deletions
This file was deleted.

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM php:7.4-fpm-alpine
2+
3+
ADD . /var/www/html/NeteaseCloudMusicApi
4+
5+
RUN set -ex \
6+
&& sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
7+
&& apk add \
8+
nginx composer \
9+
&& cd /var/www/html/NeteaseCloudMusicApi \
10+
&& composer install \
11+
&& cp service.sh /opt/ \
12+
&& cp nginx.conf /etc/nginx/nginx.conf \
13+
&& cp i.music.163.com.fpm.conf /usr/local/etc/php-fpm.d \
14+
&& cp i.music.163.com.conf /etc/nginx/conf.d \
15+
&& chmod +x /opt/service.sh
16+
17+
18+
ENTRYPOINT ["/opt/service.sh"]

LICENSE

100644100755
File mode changed.

README.md

100644100755
Lines changed: 40 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -83,26 +83,31 @@
8383

8484
## 说明
8585

86-
>本接口依照RESTful规范设计(并不完全 - -|| ),依赖[PhpBoot](https://github.com/kilingzhang/phpboot)框架。所以下文会存在一些配置[PhpBoot](https://github.com/kilingzhang/phpboot)框架的操作。
86+
>本接口依照RESTful规范设计(并不完全 - -||
8787
8888
## 环境要求
8989

90-
- PHP 版本 >= 5.5.9
91-
- APC 扩展启用
9290

93-
```
94-
apc.enable=1
95-
```
96-
97-
- 如果启用了OPcache,应同时配置以下选项:
98-
99-
```
100-
opcache.save_comments=1
101-
opcache.load_comments=1
102-
```
103-
104-
105-
## 安装
91+
## 镜像安装
92+
93+
vi /etc/hosts
94+
95+
127.0.0.1 i.music.163.com
96+
97+
docker build -t kilingzhang/netease-cloud-music-api:dev .
98+
99+
docker stop php_container
100+
docker rm php_container
101+
102+
docker run -itd --name=php_container \
103+
-p 80:80 \
104+
kilingzhang/netease-cloud-music-api:dev
105+
106+
curl http://i.music.163.com
107+
108+
{"code":0,"message":"it`s work successfully","data":{"docs":"https:\/\/blog.kilingzhang.com\/NeteaseCloudMusicApi","github":"https:\/\/github.com\/kilingzhang\/NeteaseCloudMusicApi"}}
109+
110+
## 源码安装
106111

107112
1. 安装 composer (已安装可忽略)
108113

@@ -112,110 +117,30 @@
112117

113118
git clone https://github.com/kilingzhang/NeteaseCloudMusicApi.git
114119

115-
3. 安装[PhpBoot](https://github.com/kilingzhang/phpboot)依赖
116-
117-
cd NeteaseCloudMusicApi
118-
composer install
120+
3. 依赖安装
119121

122+
composer install
120123

121-
## 配置
122-
123-
1. WebServer 配置([PhpBoot](https://github.com/kilingzhang/phpboot))
124-
1. Nginx
125-
126-
server {
127-
listen 80;
128-
server_name example.com;
129-
index index.php;
130-
error_log /path/to/example.error.log;
131-
access_log /path/to/example.access.log;
132-
root /path/to/public;
133-
134-
location / {
135-
try_files $uri /index.php$is_args$args;
136-
}
137-
138-
location ~ \.php {
139-
try_files $uri =404;
140-
fastcgi_split_path_info ^(.+\.php)(/.+)$;
141-
include fastcgi_params;
142-
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
143-
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
144-
fastcgi_index index.php;
145-
fastcgi_pass 127.0.0.1:9000;
146-
}
147-
}
148-
149-
2. Apache
150-
>Apache 的配置稍微复杂,首先你需要启 mod_rewrite 模块,然后在 index.php 目录下添加 .htaccess 文件:
124+
4. nginx
125+
126+
server {
151127

152-
Options +FollowSymLinks
153-
RewriteEngine On
154-
155-
RewriteCond %{REQUEST_FILENAME} !-d
156-
RewriteCond %{REQUEST_FILENAME} !-f
157-
RewriteRule ^ index.php [L]
128+
listen 80;
129+
server_name i.music.163.com;
130+
root /var/www/html/NeteaseCloudMusicApi;
131+
index index.php;
158132

159-
>另外还需要修改虚拟主机的AllowOverride配置:
133+
location / {
134+
try_files $uri $uri/ /index.php?$query_string;
135+
}
160136

161-
AllowOverride All
162-
163-
>注:以上配置为[PhpBoot](https://github.com/kilingzhang/phpboot)框架需求的配置,由于 WebServer 版本的差异, 以上配置可能不能按预期工作,但这是使用多数 PHP 框架第一步需要解决的问题, 网上有会有很多解决方案,用好搜索引擎即可
164-
165-
2. 接口选项配置([PhpBoot](https://github.com/kilingzhang/phpboot))
166-
1. 配置文件 (`Config.php`)
167-
> [PhpBoot](https://github.com/kilingzhang/phpboot)的配置文件配置,如果熟悉此框架的可以略过自行配置,如果不熟悉的phper的可以直接使用默认的配置。
168-
169-
return [
170-
//App
171-
//换成自己服务器域名
172-
'host' => 'example.com',
173-
//DB
174-
'DB.connection'=> 'mysql:dbname=phpboot-example;host=127.0.0.1',
175-
'DB.username'=> 'root',
176-
'DB.password'=> '',
177-
'DB.options' => [],
178-
// 如果要将系统缓存改成文件方式, 取消下面的注释。默认系统缓存是 APC
179-
// 注意这里的系统缓存指路由、依赖注入方式等信息的缓存, 而不是业务接口返回数据的缓存。
180-
// 所以这里不要使用 redis 等远程缓存
181-
// \Doctrine\Common\Cache\Cache::class =>
182-
// \DI\object(\Doctrine\Common\Cache\FilesystemCache::class)->constructorParameter('directory', sys_get_temp_dir()),
183-
184-
//异常输出类
185-
\PhpBoot\Controller\ExceptionRenderer::class =>
186-
\DI\object(\Utils\ExceptionRenderer::class)
187-
];
188-
189-
2. 文档输出配置 (`index.php`)
190-
> [PhpBoot](https://github.com/kilingzhang/phpboot)的配置文件配置,如果熟悉此框架的可以略过自行配置,如果不熟悉的phper的可以直接使用默认的配置。
191-
192-
require_once "Autoloader.php";
193-
require_once "vendor/autoload.php";
194-
use PhpBoot\Docgen\Swagger\Swagger;
195-
use PhpBoot\Docgen\Swagger\SwaggerProvider;
196-
use PhpBoot\Application;
197-
use PhpBoot\Controller\Hooks\Cors;
198-
header("Content-Type: charset=utf-8");
199-
ini_set('date.timezone','Asia/Shanghai');
200-
201-
// 加载配置
202-
$app = \PhpBoot\Application::createByDefault(
203-
'Config.php'
204-
);
205-
206-
207-
//接口文档自动导出功能, 如果要关闭此功能, 只需注释掉这块代码{{
208-
SwaggerProvider::register($app, function(Swagger $swagger)use($app){
209-
$swagger->schemes = ['http'];
210-
$swagger->host = $app->get('host');
211-
$swagger->info->title = '网易云音乐API';
212-
$swagger->info->description = "网易云音乐API-PHPSDK";
213-
});
214-
//}}
215-
$app->loadRoutesFromPath( 'src/NeteaseCloudMusicApiSdk', 'NeteaseCloudMusicApiSdk');
216-
217-
//执行请求
218-
$app->dispatch();
137+
location ~ \.php$ {
138+
fastcgi_pass 127.0.0.1:5337;
139+
fastcgi_index index.php;
140+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
141+
include fastcgi_params;
142+
}
143+
}
219144

220145
## 使用文档
221146

composer.json

100644100755
Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,37 @@
11
{
22
"name": "kilingzhang/netease-cloud-music-api",
33
"type": "library",
4+
"version": "1.0.0",
45
"authors": [
56
{
67
"name": "kilingzhang",
7-
"email": "slight@kilingzhang.com",
8-
"homepage": "http://www.kilingzhang.com/",
8+
"email": "i@kilingzhang.com",
9+
"homepage": "https://blog.kilingzhang.com",
910
"role": "Developer"
1011
}
1112
],
1213
"homepage": "http://github.com/kilingzhang/neteaseCloudMusicApi",
1314
"require": {
14-
"caoym/phpboot": "^2.0.7"
15+
"ext-json": "*",
16+
"ext-openssl": "*"
17+
},
18+
"autoload": {
19+
"classmap": [
20+
"src/"
21+
]
22+
},
23+
"autoload-dev": {
24+
"classmap": [
25+
"tests/"
26+
],
27+
"files": [
28+
"src/Utils/Functions.php"
29+
]
1530
},
1631
"repositories": {
1732
"packagist": {
1833
"type": "composer",
19-
"url": "https://packagist.phpcomposer.com"
34+
"url": "https://mirrors.aliyun.com/composer"
2035
}
2136
},
2237
"description": "网易云音乐 PHP 版 API",
@@ -26,5 +41,8 @@
2641
"音乐",
2742
"网易云音乐PHP"
2843
],
29-
"license": "MIT"
44+
"license": "MIT",
45+
"require-dev": {
46+
"phpunit/phpunit": "^8.5"
47+
}
3048
}

0 commit comments

Comments
 (0)