Skip to content

Commit 6feca0d

Browse files
committed
zentao nb base
0 parents  commit 6feca0d

Some content is hidden

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

97 files changed

+16420
-0
lines changed

.htaccess

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Options +FollowSymLinks +SymLinksIfOwnerMatch
2+
3+
# framework router settings.
4+
<IfModule mod_rewrite.c>
5+
RewriteEngine On
6+
RewriteBase /MS/zentaopms/www/redmine/
7+
RewriteCond %{REQUEST_FILENAME} !-d
8+
RewriteCond %{REQUEST_FILENAME} !-f
9+
RewriteRule ^ index.php [QSA,L]
10+
</IfModule>
11+
12+
# php settings.
13+
php_value post_max_size 50M
14+
php_flag file_uploads On
15+
php_value upload_max_filesize 50M
16+
php_value display_errors 1
17+
# for post vars limit.
18+
php_value max_input_vars 3000
19+
20+
FileEtag none

app/controllers/HomeController.php

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
/**
4+
* 演示控制器
5+
*
6+
* - 简单输出
7+
* - 输入验证
8+
* - jsonp输出
9+
*
10+
*/
11+
class HomeController extends Controller
12+
{
13+
/**
14+
* demo
15+
*
16+
* @return Slim\Http\Response
17+
*/
18+
public function index()
19+
{
20+
return $this->json(['app' => 'Rester', 'message' => 'Hello world!']);
21+
}
22+
23+
/**
24+
* 验证演示
25+
*
26+
* @return \Slim\Http\Response
27+
*/
28+
public function validateDemo()
29+
{
30+
$rules = [
31+
'username' => 'required',
32+
'password' => 'required|confirmed',
33+
'sex' => 'integer|in:1,0',
34+
];
35+
36+
$this->validate($this->request->post(), $rules);
37+
38+
//以下是验证通过的情况下
39+
return $this->json(['status' => 'validation passes.']);
40+
}
41+
42+
/**
43+
* jsonp 演示
44+
*
45+
* @return \Slim\Http\Response
46+
*/
47+
public function jsonpDemo()
48+
{
49+
$rules = [
50+
'callback' => 'required',
51+
];
52+
53+
$this->validate($this->request->get(), $rules);
54+
55+
$return = [
56+
'username' => 'Carlos',
57+
'age' => 24,
58+
'location' => 'Beijing, China',
59+
'chinese_name' => '安正超',
60+
'github' => 'https://github.com/overtrue'
61+
];
62+
63+
$callback = $this->request->get('callback');
64+
65+
return $this->jsonp($return, $callback);//callbak是可选的,如果不传,默认从GET取callback
66+
}
67+
}

app/models/Model.php

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
use Illuminate\Database\Eloquent\Model as Eloquent;
4+
5+
class Model extends Eloquent
6+
{
7+
/**
8+
* 重写paginate方法
9+
*
10+
* @param integer $integer
11+
* @param array $columns
12+
* @param boolean $justItems 是否只返回items
13+
*
14+
* @return mixed
15+
*/
16+
public static function paginate($perPage, $columns = array('*'), $offset = null)
17+
{
18+
if (empty($this)) {
19+
$model = new static;
20+
}
21+
22+
if (is_null($offset)) {
23+
$currentPage = empty($_GET['page']) ? 1 : abs($_GET['page']);
24+
}
25+
26+
$offset = ($currentPage - 1) * $perPage;
27+
28+
return $model->getQuery()->skip($offset)->select($columns)->take($perPage)->get();
29+
}
30+
}

app/models/User.php

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
use Illuminate\Database\Eloquent\Model;
4+
5+
class User extends Model
6+
{
7+
protected $table = 'user';
8+
protected $fillable = ['*'];
9+
public $timestamps = false;
10+
11+
}

composer.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"require": {
3+
"slim/slim": "^2.6"
4+
}
5+
}

composer.lock

+65
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

data/config/app.php

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
return [
4+
'debug' => true,
5+
];

data/config/database.php

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
/**
3+
* database.php
4+
*/
5+
return [
6+
'mysql' => [
7+
'driver' => 'mysql',
8+
'host' => '127.0.0.1',
9+
'database' => 'zentao',
10+
'username' => 'root',
11+
'password' => '',
12+
'charset' => 'utf8',
13+
'collation' => 'utf8_general_ci',
14+
'prefix' => 'zt_',
15+
],
16+
];

data/config/env.php

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
return [
4+
// 环境名 => [hostname1, hostname2, ...]
5+
'local' => ['overtrue'],
6+
'production' => ['*'],
7+
];

data/config/routes.php

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
//更多使用方法请阅读文档:
4+
//http://docs.slimframework.com/#Routing-Overview
5+
6+
$app->get('/', 'HomeController:index');
7+
8+
$app->group('/api', function() use ($app){
9+
$app->get('/articles', 'ArticleController:index');
10+
$app->get('/articles/:id', 'ArticleController:show');
11+
});

inc/Dispatcher.php

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace zentao\nb;
4+
5+
class Dispatcher extends \flight\core\Dispatcher {
6+
7+
}

0 commit comments

Comments
 (0)