Skip to content

Commit

Permalink
hello from mars
Browse files Browse the repository at this point in the history
  • Loading branch information
orvice committed Apr 12, 2016
0 parents commit b5087dc
Show file tree
Hide file tree
Showing 12 changed files with 234 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/vendor
composer.phar
composer.lock
.php_cs.cache
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 OzCat

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# framework
OzCat framework
39 changes: 39 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "pongtan/framework",
"description": "The Pongtan Framework.",
"authors": [
{
"name": "Xiaobin",
"email": "[email protected]"
}
],
"require": {
"slim/slim": "^3.0",
"illuminate/database": "*",
"slim/twig-view": "~2.0",
"slim/csrf": "0.5.*",
"monolog/monolog": "^1.18",
"smarty/smarty": "~3.1",
"mailgun/mailgun-php": "~1.7.2",
"predis/predis": "~1.0",
"phpmailer/phpmailer": "~5.2",
"illuminate/pagination": "~5.1",
"vlucas/phpdotenv": "~2.1",
"zeuxisoo/slim-whoops": "0.4.*",
"firebase/php-jwt": "~3.0",
"aws/aws-sdk-php": "3.*",
"gregwar/captcha": "1.*",
"desarrolla2/cache": "~2.0"
},
"autoload": {
"classmap": [

],
"files": [
"src/Pongtan/Support/helpers.php"
],
"psr-4": {
"Pongtan\\": "src/Pongtan"
}
}
}
57 changes: 57 additions & 0 deletions src/Pongtan/App.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace Pongtan;

use Pongtan\Services\Config;
use Dotenv\Dotenv;
use Illuminate\Database\Capsule\Manager as Capsule;

class App
{
protected $basePath;

public function __construct()
{
}

/**
* @param $path
*/
public function setBasePath($path)
{
$this->basePath = $path;
}

public function loadEnv()
{
$env = new Dotenv($this->basePath);
$env->load();
}

public function setDebug()
{
// debug
if (Config::get('debug') == "true") {
define("DEBUG", true);
}
}

public function setVersion($version)
{
$_ENV['version'] = $version;
}

public function setTimezone()
{
// config time zone
date_default_timezone_set(Config::get('timeZone'));
}

public function bootDb()
{
// Init Eloquent ORM Connection
$capsule = new Capsule;
$capsule->addConnection(Config::getDbConfig());
$capsule->bootEloquent();
}
}
10 changes: 10 additions & 0 deletions src/Pongtan/Cache/Factory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php


namespace Pongtan\Cache;


class Factory
{

}
10 changes: 10 additions & 0 deletions src/Pongtan/Cache/File.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php


namespace Pongtan\Cache;


class File
{

}
11 changes: 11 additions & 0 deletions src/Pongtan/Database/Model.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Pongtan\Database;


use Illuminate\Database\Eloquent\Model as EloquentModel;

class Model extends EloquentModel
{

}
38 changes: 38 additions & 0 deletions src/Pongtan/Http/Controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Pongtan\Http;

use Pongtan\View\Factory;

class Controller
{
public $view;

public $smarty;

public function construct__()
{

}

public function smarty()
{
$this->smarty = Factory::newSmarty();
return $this->smarty;
}

public function view()
{
return $this->smarty();
}

/**
* @param $response
* @param $res
* @return mixed
*/
public function echoJson($response, $res)
{
return $response->getBody()->write(json_encode($res));
}
}
19 changes: 19 additions & 0 deletions src/Pongtan/Services/Config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Pongtan\Services;


class Config
{
public static function get($key)
{
$key = getenv($key);
if ($key == 'true') {
return true;
}
if ($key == 'false') {
return false;
}
return $key;
}
}
1 change: 1 addition & 0 deletions src/Pongtan/Support/helpers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php
21 changes: 21 additions & 0 deletions src/Pongtan/View/Factory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace OzCat\View;

use Smarty;

class Factory
{
public static function newSmarty()
{
$smarty = new smarty(); //实例化smarty
$smarty->settemplatedir(BASE_PATH . '/resources/views/' . Config::get('theme') . '/'); //设置模板文件存放目录
$smarty->setcompiledir(BASE_PATH . '/storage/framework/smarty/compile/'); //设置生成文件存放目录
$smarty->setcachedir(BASE_PATH . '/storage/framework/smarty/cache/'); //设置缓存文件存放目录
// add config
$smarty->assign('config', Config::getPublicConfig());
$smarty->assign('user', Auth::getUser());
return $smarty;
}

}

0 comments on commit b5087dc

Please sign in to comment.