Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
xiayongfeng committed Mar 16, 2015
0 parents commit e519629
Show file tree
Hide file tree
Showing 7 changed files with 425 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Created by .ignore support plugin (hsz.mobi)
### Composer template
composer.phar
vendor/

# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock

.idea/
20 changes: 20 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "youngsterxyf/rss-world",
"description": "A rss aggregation service based on Slim and Vue.js",
"keywords": ["microframework","rest","router"],
"homepage": "http://github.com/youngsterxyf/rss-world",
"license": "MIT",
"authors": [
{
"name": "youngsterxyf",
"email": "[email protected]",
"homepage": "http://youngsterxyf.github.io"
}
],
"require": {
"php": ">=5.3.0",
"monolog/monolog": "1.*",
"slim/slim": "2.*",
"rmccue/requests": ">=1.0"
}
}
226 changes: 226 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions protected/Helpers/CodeStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* Created by PhpStorm.
* User: xiayongfeng
* Date: 2015/3/16
* Time: 15:38
*/

namespace RSSWorld\Helpers;

class CodeStatus
{

const OK = 1000; // 成功
const PARAMETER_NOT_EXISTED = 1001; // 缺少必要的请求参数
const RESOURCE_NOT_ACCESSIBLE = 1002; // 资源不可访问
const NOT_VALID_RESOURCE = 1003; // 无效资源

public static $statusCode = array(
self::OK => '成功',
self::PARAMETER_NOT_EXISTED => '缺少必要的请求参数',
self::RESOURCE_NOT_ACCESSIBLE => '资源不可访问',
);
}
33 changes: 33 additions & 0 deletions protected/Helpers/ResponseUtils.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/**
* Created by PhpStorm.
* User: xiayongfeng
* Date: 2015/3/16
* Time: 15:30
*/

namespace RSSWorld\Helpers;

class ResponseUtils
{

public static function responseError($errCode)
{
echo json_encode(array(
'code' => $errCode,
'message' => CodeStatus::$statusCode[$errCode],
));

return true;
}

public static function responseJSON($data)
{
echo json_encode(array(
'code' => CodeStatus::OK,
'data' => $data,
));

return true;
}
}
22 changes: 22 additions & 0 deletions protected/autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* Created by PhpStorm.
* User: xiayongfeng
* Date: 2015/3/16
* Time: 17:04
*/

// 注册应用自己的autoload
spl_autoload_register(function ($className) {
$prefix = 'RSSWorld\\';
$baseDir = __DIR__ . '/';
$len = strlen($prefix);
if (strncmp($prefix, $className, $len) !== 0) {
return;
}
$relativeClassName = substr($className, $len);
$targetFile = $baseDir . str_replace('\\', '/', $relativeClassName) . '.php';
if (file_exists($targetFile)) {
require $targetFile;
}
});
Loading

0 comments on commit e519629

Please sign in to comment.