Skip to content

Commit 3d5e018

Browse files
author
Helperhaps
committedAug 1, 2016
add autoload to support source code installation
1 parent 3fea757 commit 3d5e018

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
 

‎README.md

+11
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@
2626

2727
- 执行 `$ php composer.phar install``$ composer install` 进行安装。
2828

29+
#### 直接下载源码安装
30+
31+
> 直接下载源代码也是一种安装 SDK 的方法,不过因为有版本更新的维护问题,所以这种安装方式**十分不推荐**,但由于种种原因导致无法使用 Composer,所以我们也提供了这种情况下的备选方案。
32+
33+
- 下载源代码包,解压到项目中
34+
- 在项目中引入 autoload:
35+
36+
```php
37+
require 'path_to_sdk/autoload.php';
38+
```
39+
2940
## Usage
3041

3142
- [Init API](doc/api.md#init-api)

‎autoload.php

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
function classLoader($class)
3+
{
4+
$path = str_replace('\\', DIRECTORY_SEPARATOR, $class);
5+
$file = __DIR__ . '/src/' . $path . '.php';
6+
if (file_exists($file)) {
7+
require_once $file;
8+
}
9+
}
10+
spl_autoload_register('classLoader');

0 commit comments

Comments
 (0)