コード例 #1
0
ファイル: Bootstrap.php プロジェクト: hopitio/framework
 function __construct()
 {
     static::$instance = $this;
     $env = getConfig('Enviroments/enviroment.config.php');
     $config = getConfig("Enviroments/{$env}.config.php");
     $config['enviroment'] = $env;
     //debug mode
     $debug = isset($_GET['debug']) ? 10 : $config['debugMode'];
     if ($debug) {
         ini_set('display_errors', 1);
         error_reporting(E_ALL);
     } else {
         ini_set('display_errors', 0);
         error_reporting(0);
     }
     //read rewritebase
     $htaccess = file_get_contents(BASE_DIR . '/Docroot/.htaccess');
     preg_match('@RewriteBase\\s*(.*)$@m', $htaccess, $matches);
     $this->rewriteBase = $matches[1];
     //create slim instance
     \Slim\Slim::registerAutoloader();
     $this->slim = new \Slim\Slim(array('cookies.encrypt' => true, 'cookies.lifetime' => 20 * 365 * 24 * 60 . ' minutes', 'cookies.path' => $this->rewriteBase, 'cookies.secure' => false, 'cookies.secret_key' => $config['cryptSecrect']));
     //config session
     $this->slim->add(new \Slim\Middleware\SessionCookie(array('expires' => 20 * 365 * 24 * 60 . ' minutes', 'path' => $this->rewriteBase, 'domain' => null, 'secure' => false, 'name' => 'slim_session', 'secret' => $config['cryptSecrect'])));
     //routing
     require_once BASE_DIR . '/routes.php';
     $this->appendRoute($routes);
     //database
     DB::config($config['db']['type'], $config['db']['host'], $config['db']['user'], $config['db']['pass'], $config['db']['name'], $debug);
     //run slim application
     $this->slim->run();
 }
コード例 #2
0
ファイル: App.php プロジェクト: dgee2/slim-plus
 private function __construct()
 {
     // Prepare app
     $this->slim = new \Slim\Slim(array('templates.path' => self::$templatePath));
     // Prepare view
     $this->slim->view(new \Slim\Views\Twig());
     $this->slim->view->parserOptions = array('charset' => 'utf-8', 'auto_reload' => true, 'strict_variables' => false, 'autoescape' => true);
     $this->slim->view->parserExtensions = array(new \Slim\Views\TwigExtension());
     if (self::$debug) {
         $this->slim->view->parserExtensions[] = new \Twig_Extension_Debug();
     }
     $this->slim->add(new \Slim\Middleware\SessionCookie());
 }
コード例 #3
0
ファイル: ResourceController.php プロジェクト: nogo/api
 public function enable(Slim $app)
 {
     $this->app = $app;
     $this->config = $this->app->config('api');
     $this->factory = new Factory($this->config['resources']);
     // Middleware
     $this->app->add(new Database());
     $this->app->add(new ApiMiddleware($this->config));
     // Routes
     $this->app->get($this->config['prefix'] . '/:resource/:id', [$this, 'getAction'])->conditions(['id' => '\\d+'])->name('resource_get');
     $this->app->get($this->config['prefix'] . '/:resource', [$this, 'listAction'])->name('resource_get_list');
     $this->app->put($this->config['prefix'] . '/:resource/:id', [$this, 'putAction'])->conditions(['id' => '\\d+'])->name('resource_put');
     $this->app->post($this->config['prefix'] . '/:resource', [$this, 'postAction'])->name('resource_post');
     $this->app->delete($this->config['prefix'] . '/:resource/:id', [$this, 'deleteAction'])->conditions(['id' => '\\d+'])->name('resource_delete');
 }
コード例 #4
0
 /**
  * Configure the middleware layers for your application
  *
  * @param Slim $app
  */
 public function configure(Slim $app)
 {
     $this->init($app->container);
     /** @var MiddlewareProvider $middleware */
     foreach ($this->middleware as $middleware) {
         $app->add($middleware);
     }
 }
コード例 #5
0
ファイル: Container.php プロジェクト: neophyt3/flaming-archer
 protected function configureApp(Slim $app, Container $c)
 {
     // Add Middleware
     $app->add($c['profileMiddleware']);
     $app->add($c['navigationMiddleware']);
     $app->add($c['authenticationMiddleware']);
     $app->add($c['sessionCookieMiddleware']);
     // Prepare view
     $app->view($c['twig']);
     $app->view->parserOptions = $this['config']['twig'];
     $app->view->parserExtensions = array($c['slimTwigExtension'], $c['twigExtensionDebug']);
     $config = $this['config'];
     // Dev mode settings
     $app->configureMode('development', function () use($app, $config) {
         $app->config(array('log.enabled' => true, 'log.level' => Log::DEBUG));
         $config['twig']['debug'] = true;
     });
 }
コード例 #6
0
 static function factory($filePath)
 {
     $storage = new YamlStorage($filePath);
     $slimApp = new Slim();
     $slimApp->add(new ContentTypes());
     $slimApp->config('debug', false);
     $instance = new static($slimApp, $storage);
     $slimApp->error(array($instance, 'error'));
     return $instance;
 }
コード例 #7
0
 protected function _slimApp()
 {
     $this['view'] = function () {
         // Configure Twig view for slim
         $view = new Twig();
         $view->parserOptions = array('charset' => 'utf-8', 'cache' => XHGUI_ROOT_DIR . '/cache', 'auto_reload' => true, 'strict_variables' => false, 'autoescape' => true);
         return $view;
     };
     $this['app'] = $this->share(function ($c) {
         $app = new Slim($c['config']);
         // Enable cookie based sessions
         $app->add(new SessionCookie(array('httponly' => true)));
         // Add renderer.
         $app->add(new Xhgui_Middleware_Render());
         $view = $c['view'];
         $view->parserExtensions = array(new Xhgui_Twig_Extension($app));
         $app->view($view);
         return $app;
     });
 }
コード例 #8
0
ファイル: Route.php プロジェクト: toshi-toshi/Tinitter
 /**
  * 渡されたslimインスタンスにルートを登録
  * @param \Slim\Slim $app
  */
 public static function registration(\Slim\Slim $app)
 {
     // SlimのCSRF対策プラグインを有効化
     $app->add(new \Slim\Extras\Middleware\CsrfGuard());
     // トップページ
     $app->get('/', '\\Tinitter\\Controller\\TimeLine:show');
     // 投稿一覧
     $app->get('/page/:page_num', '\\Tinitter\\Controller\\TimeLine:show');
     // 新規投稿系、保存
     $app->post('/post/commit', '\\Tinitter\\Controller\\Post:commit');
 }
コード例 #9
0
ファイル: Route.php プロジェクト: sxyr318/Tinitter
 public static function registration(\Slim\Slim $app)
 {
     // Slim縺ョCSRF蟇セ遲悶��繝ゥ繧ー繧、繝ウ繧呈怏蜉ケ蛹�
     $app->add(new \Slim\Extras\Middleware\CsrfGuard());
     // 繝医ャ繝励��繝シ繧ク
     $app->get('/', '\\Tinitter\\Controller\\TimeLine:show');
     // 謚慕ィソ荳�隕ァ
     $app->get('/page/:page_num', '\\Tinitter\\Controller\\TimeLine:show');
     // 譁ー隕乗兜遞ソ邉サ縲∽ソ晏ュ�
     $app->post('/post/commit', '\\Tinitter\\Controller\\Post:commit');
 }
コード例 #10
0
ファイル: Register.php プロジェクト: rivomanana/rv-slim-base
 /**
  * Add all middleware
  * @param Slim $application
  */
 public static function middleware(Slim $application)
 {
     if (sizeof(Config::get('app.middleware'))) {
         foreach (Config::get('app.middleware') as $middleware) {
             $middleware = explode('@', $middleware);
             $classMiddleware = $middleware[0];
             $add = isset($middleware[1]) ? new $classMiddleware(Config::get($middleware[1])) : new $classMiddleware();
             $application->add($add);
         }
     }
 }
コード例 #11
0
 /**
  * @inheritdoc
  */
 public function getSlimInstance()
 {
     $app = new Slim(array('debug' => false));
     $app->add(new JsonRequestMiddleware(['json_as_object' => true]));
     $app->post('/messages', function () use($app) {
         $json = $app->json_body;
         if (empty($json)) {
             $app->response->setBody('empty json');
         } else {
             $app->response->setBody('message:' . $json->message);
         }
     });
     $app->error(function (InvalidJsonFormatException $e) use($app) {
         $app->response->setBody('error:' . $e->getMessage());
     });
     return $app;
 }
コード例 #12
0
 /** @test */
 function it_should_persist_an_event_published_inside_an_slim_route()
 {
     /** @var \Hexagonal\Bridges\Doctrine2\DomainEvents\EventStoreRepository $store */
     $store = $this->entityManager->getRepository(StoredEvent::class);
     $publisher = new EventPublisher();
     $middleware = new StoreEventsMiddleware(new PersistEventsSubscriber($store, new StoredEventFactory(new JsonSerializer())), $publisher);
     $app = new Slim();
     $app->get('/', function () use($publisher) {
         $events = new SplObjectStorage();
         $events->attach(A::transferWasMadeEvent()->build());
         $publisher->publish($events);
     });
     $app->add($middleware);
     Environment::mock(['REQUEST_METHOD' => 'GET']);
     $app->run();
     $this->assertCount(1, $store->allEvents());
 }
コード例 #13
0
ファイル: Route.php プロジェクト: h-inuzuka/quiz
 public static function registration(\Slim\Slim $app)
 {
     $app->add(new \Slim\Extras\Middleware\CsrfGuard());
     //top
     $app->get('/', '\\Quiz\\Controller\\Top:show');
     //question
     $app->get('/questions', '\\Quiz\\Controller\\Question:show');
     $app->get('/questions/new', '\\Quiz\\Controller\\Question:createShow');
     $app->post('/questions/new', '\\Quiz\\Controller\\Question:createQuestion');
     $app->get('/questions/update', '\\Quiz\\Controller\\Question:updateShow');
     $app->post('/questions/update', '\\Quiz\\Controller\\Question:updateQuestion');
     //quiz
     $app->get('/quizzes', '\\Quiz\\Controller\\Quiz:show');
     $app->get('/quizzes/new', '\\Quiz\\Controller\\Quiz:createShow');
     $app->post('/quizzes/new', '\\Quiz\\Controller\\Quiz:createQuiz');
     //answer
     $app->post('/answer/start', '\\Quiz\\Controller\\Answer:answerStart');
     $app->post('/answer/end', '\\Quiz\\Controller\\Answer:answerEnd');
     //comment
     $app->post('/comment/create', '\\Quiz\\Controller\\Comment:createComment');
 }
コード例 #14
0
use Slim\Middleware\ContentTypes as ContentTypesMiddleware;
use NwWebsite\Controllers\Auth\Twitter as AuthTwitterController;
use NwWebsite\Controllers\Home as HomeController;
use NwWebsite\Controllers\Auth\Authentifier as AuthentifierController;
use NwWebsite\Controllers\Articles as ArticlesController;
$di = Di::getInstance();
if ($di->env === ENV_DEVELOPMENT) {
    $slimMode = 'development';
    $debug = true;
} else {
    $slimMode = 'production';
    $debug = true;
}
$app = new Slim(['mode' => $slimMode, 'debug' => $debug, 'view' => $di->layoutHtml]);
// Allow to decode json request body
$app->add(new ContentTypesMiddleware());
$app->get('/auth/login', function () use($app) {
    $app->render('auth/login');
});
$app->get('/auth/twitter/login', function () {
    AuthTwitterController::getInstance()->login();
});
$app->get('/auth/twitter/callback', function () {
    AuthTwitterController::getInstance()->callback();
});
$app->get('/auth/logout', function () {
    AuthentifierController::getInstance()->logout();
});
$app->get('/home', function () {
    HomeController::getInstance()->home();
});
コード例 #15
0
ファイル: index.php プロジェクト: neophyt3/sharemyideas
// Controllers
require_once "app/controller.php";
require_once "app/controllers/login.controller.php";
require_once "app/controllers/ideas.controller.php";
define('APPLICATION', 'Share My Ideas');
define('VERSION', '1.0.0');
define('EXT', '.twig');
use Slim\Slim;
use Slim\Extras\Views\Twig as TwigView;
use Strong\Strong;
use Slim\Extras\Middleware\StrongAuth;
$app = new Slim(array('view' => new TwigView()));
$dsn = sprintf('mysql:host=%s;dbname=%s', $db[$activeGroup]['hostname'], $db[$activeGroup]['database']);
// Authentication
$config = array('provider' => 'PDO', 'pdo' => new PDO($dsn, $db[$activeGroup]['username'], $db[$activeGroup]['password']), 'auth.type' => 'form', 'login.url' => '/login', 'security.urls' => array(array('path' => '/comment/'), array('path' => '/api/.+'), array('path' => '/account/')));
$app->add(new StrongAuth($config, new Strong($config)));
// Asset Management
TwigView::$twigExtensions = array('Twig_Extensions_Slim');
$c = new Application($app);
$loginController = new LoginController();
$ideasController = new IdeasController();
// routes
$c->app->get('/', array($ideasController, 'index'))->name('home');
$c->app->map('/login/', array($loginController, 'index'))->via('GET', 'POST')->name('login');
$c->app->map('/register/', array($loginController, 'signup'))->via('GET', 'POST')->name('signup');
$c->app->map('/account/', array($loginController, 'profile'))->via('GET', 'POST')->name('profile');
$c->app->map('/account/settings/', array($loginController, 'settings'))->via('GET', 'POST')->name('settings');
$c->app->map('/forgot/', array($loginController, 'forgot'))->via('GET', 'POST')->name('forgot_password');
$c->app->get('/logout/', array($loginController, 'logout'))->name('logout');
$c->app->get('/idea(/:id)', array($ideasController, 'idea'))->name('idea');
$c->app->post('/idea/save', array($ideasController, 'save'))->name('idea_save');
コード例 #16
0
ファイル: index.php プロジェクト: EpykOS/epykosLittleHelper
require_once "app/controllers/restaurant.controller.php";
// Models
require_once "app/models/BaseModel.php";
require_once "app/models/Idea.php";
define('APPLICATION', 'Share My Ideas');
define('VERSION', '1.0.0');
define('EXT', '.twig');
use Slim\Slim;
use Slim\Views\Twig as TwigView;
//use Cartalyst\Sentinel\Native\Facades\Sentinel;
use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Events\Dispatcher;
use Illuminate\Container\Container;
$app = new Slim(array('view' => new TwigView()));
// Asset Management
$app->view()->parserExtensions = array(new \Slim\Views\TwigExtension());
/* Content Type Middleware */
$app->add(new \Slim\Middleware\ContentTypes());
$capsule = new Capsule();
echo ENVIRONMENT;
$capsule->addConnection($db[ENVIRONMENT]);
$capsule->setEventDispatcher(new Dispatcher(new Container()));
// If you want to use the Eloquent ORM...
$capsule->bootEloquent();
/* DB methods accessible via Slim instance */
$capsule->setAsGlobal();
/* Sentry Auth */
class_alias('Cartalyst\\Sentinel\\Native\\Facades\\Sentinel', 'Sentinel');
// Include Routes
require_once "app/routes.php";
$app->run();
コード例 #17
0
<?php

/* init.php */
/* Load the composer autoloader into your application. */
require_once 'libs/const/const.php';
$classloader = (require_once "vendor/autoload.php");
$classloader->addPsr4('Libs\\MyClass\\', __DIR__ . "/libs/classes");
use Slim\Slim;
use JsonApiView;
use JsonApiMiddleware;
define("BASE_DIR", __DIR__ . "/");
/* Create Slim instance */
$app = new Slim();
/* Add json view */
$app->view(new JsonApiView());
$app->add(new JsonApiMiddleware());
コード例 #18
0
 private function loadMiddleware(Slim $app, $newInstanceClass)
 {
     $app->add($newInstanceClass);
 }
コード例 #19
0
use Slim\Views\TwigExtension;
use Noodlehaus\Config;
use RandomLib\Factory as RandomLib;
use Codecourse\User\User;
use Codecourse\Helpers\Hash;
use Codecourse\Mail\Mailer;
use Codecourse\Validation\Validator;
use Codecourse\BeforeMiddleware;
use Codecourse\CsrfMiddleware;
session_cache_limiter(false);
session_start();
ini_set('display_errors', 'On');
define('INC_ROOT', dirname(__DIR__));
require INC_ROOT . '/vendor/autoload.php';
$app = new Slim(['mode' => rtrim(file_get_contents(INC_ROOT . '/mode.php')), 'view' => new Twig(), 'templates.path' => INC_ROOT . '/app/views']);
$app->add(new Codecourse\Middleware\BeforeMiddleware());
$app->add(new Codecourse\Middleware\CsrfMiddleware());
$app->config = Config::load(INC_ROOT . "/app/config/{$app->mode}.php");
// $app->configureMode($app->config('mode'), function() use ($app){
//   $app->config =  Config::load(INC_ROOT . "/app/config/{$app->mode}");
// });
require 'database.php';
require 'filters.php';
require 'routes.php';
$app->container->set('user', function () {
    return new User();
});
$app->container->singleton('hash', function () use($app) {
    return new Hash($app->config);
});
$app->container->singleton('validation', function () use($app) {
コード例 #20
0
ファイル: index.php プロジェクト: onpaws/honeybadger-php
<?php

require 'vendor/autoload.php';
use Slim\Slim;
// Load our shared Honeybadger config.
$options = (include __DIR__ . '/../config.php');
// Create a Slim app with a few settings.
$app = new Slim(array('debug' => TRUE, 'mode' => 'examples'));
// Configure Honeybadger to integrate with our app.
$app->add(new Honeybadger\Slim(array('api_key' => $options['api_key'], 'http_open_timeout' => 15, 'http_read_timeout' => 15, 'debug' => TRUE, 'project_root' => realpath(__DIR__))));
// Make some routes:
$app->get('/', function () {
    echo sprintf('<a href="%s/%s">%s</a>', '/slim/fail', rand(0, 999999), 'trigger an error');
});
$app->get('/fail/:id', function ($id) {
    throw new Exception('bleh! ' . $id);
});
// Run the app.
$app->run();
コード例 #21
0
ファイル: bootstrap.php プロジェクト: blrik/bHome
use Assets\Middleware\CsrfMiddleware;
use Assets\Mail\Mailer;
use Assets\Translate\Translate;
use Assets\Twitter\TwitterClient;
use Assets\Twitter\TwitterClientOauth;
use Assets\Weather\Yandex;
use Assets\Weather\OWM;
use Assets\Instagram\InstagramClient;
use Assets\Instagram\InstagramClientOauth;
session_cache_limiter(false);
session_start();
ini_set('display_errors', 'On');
define('INC_ROOT', dirname(__DIR__));
require INC_ROOT . '/vendor/autoload.php';
$app = new Slim(['view' => new Twig(), 'templates.path' => INC_ROOT . '/app/views']);
$app->add(new AuthMiddleware());
$app->add(new CsrfMiddleware());
$app->container->singleton('config', function () use($app) {
    return new Config(__DIR__ . '/config.php');
});
//DATAbase
$capsule = new Capsule();
$capsule->addConnection(['driver' => $app->config->get('db.driver'), 'host' => $app->config->get('db.host'), 'database' => $app->config->get('db.database'), 'username' => $app->config->get('db.username'), 'password' => $app->config->get('db.password'), 'charset' => $app->config->get('db.charset'), 'collation' => $app->config->get('db.collation'), 'prefix' => $app->config->get('db.prefix')]);
$capsule->bootEloquent();
//*DATAbase
$app->container->set('user', function () {
    return new User();
});
$app->container->set('sandbox', function () {
    return new Sandbox();
});
コード例 #22
0
ファイル: index.php プロジェクト: nblakefriend/download
        //       $username = filter_var(strtolower($usr), FILTER_SANITIZE_STRING);
        //       $user_info = $dl->admin->user_lookup($username); // Query the user info from the DB
        //       // Check if the user session id from the db matches the saved session id
        //       if($user_info['session_id'] === $session){
        //          return true;
        //       } else {
        //          return false;
        //       }
        //     }
        //   }
    };
};
$app = new Slim(array('view' => new \Slim\Views\Twig()));
$view = $app->view();
$view->parserOptions = array('debug' => true);
$app->add(new SessionCookie(array('name' => 'session', 'secret' => 'secret', 'cipher' => MCRYPT_RIJNDAEL_256, 'cipher_mode' => MCRYPT_MODE_CBC)));
$view->parserExtensions = array(new \Slim\Views\TwigExtension());
$app->hook('slim.before.dispatch', function () use($app) {
    $usr = null;
    $sid = null;
    // if (isset($_SESSION['user'])) {
    //    $user = $_SESSION['user'];
    // }
    if (isset($_SESSION['sid'])) {
        $sid = $_SESSION['sid'];
    }
    if (isset($_SESSION['usr'])) {
        $usr = $_SESSION['usr'];
    }
    $app->view()->setData('usr', $usr);
    $app->view()->setData('sid', $sid);
コード例 #23
0
ファイル: start.php プロジェクト: navegs/DocumentQueue
use DocManager\Validation\Validator;
use DocManager\Middleware\BeforeMiddleware;
use Noodlehaus\Config;
use Slim\Slim;
use Slim\Views\Twig;
use Slim\Views\TwigExtension;
// Start the session
session_cache_limiter(false);
session_start();
// This is only used for debugging in development
ini_set('display_errors', 'On');
define('INC_ROOT', dirname(__DIR__));
require INC_ROOT . '/vendor/autoload.php';
$app = new Slim(['mode' => file_get_contents(INC_ROOT . '/mode.php'), 'view' => new Twig(), 'templates.path' => INC_ROOT . '/app/views']);
// Register custom Middleware class that executes before each request
$app->add(new DocManager\Middleware\BeforeMiddleware());
// Loads and sets the configuration file based on the environment specified
// in /mode.php
$app->configureMode($app->config('mode'), function () use($app) {
    $app->config = Config::load(INC_ROOT . "/app/config/{$app->mode}.php");
});
require 'database.php';
require 'DocManager/Middleware/RouteSecurityFilter.php';
require 'routes.php';
// Set default value for auth in Slim container
// Used for for authentication
$app->auth = false;
// Make the custom User class available within the Slim container
// Used for authentication
$app->container->set('user', function () {
    return new User();
コード例 #24
0
ファイル: index.php プロジェクト: lodeale/loginPHP
<?php

require 'vendor/autoload.php';
use Slim\Slim;
use myapp\Classes\DB\DB;
$app = new Slim();
/**
* Configuration Template
*/
$app->config(array('templates.path' => './web'));
/**
* Configuration of the Session and Cookies
*/
$app->add(new \Slim\Middleware\SessionCookie(array('expires' => '20 minutes', 'path' => '/', 'domain' => null, 'secure' => false, 'httponly' => false, 'name' => 'slim_session', 'secret' => 'cryptqwerty', 'cipher' => MCRYPT_RIJNDAEL_256, 'cipher_mode' => MCRYPT_MODE_CBC)));
$db = new DB();
$rootPath = 'http://127.0.0.1/login/';
require_once 'routers/routerLogin.php';
require_once 'routers/routerPanel.php';
$app->get('/', function () {
    echo "Bienvenido.";
});
$app->run();
コード例 #25
0
ファイル: index.php プロジェクト: dazmiller/red4
require_once '../vendor/RedBean/rb.php';
require_once __DIR__ . '/../vendor/autoload.php';
use Slim\Middleware\CsrfGuard;
use Slim\Slim;
use Slim\Views;
// Register autoloaders
Slim::registerAutoloader();
require_once '../app/autoloader.php';
// The session lines must come after the requires to allow (de)serialize to work.
session_cache_limiter(false);
session_start();
$mode = 'DEBUG';
// Change before deploying
// Setup the Slim app instance.
$app = new Slim(array('debug' => $mode == 'DEBUG', 'view' => new Views\Twig(), 'templates.path' => '../app/Views', 'cookies.encrypt' => true, 'cookies.httponly' => true, 'cookies.lifetime' => '2 weeks', 'cookies.secret_key' => 'InsertSecretKeyHere'));
$app->add(new CsrfGuard());
// Setup the Twig view within the app.
$view = $app->view();
$view->parserOptions = array('debug' => $mode == 'DEBUG', 'cache' => __DIR__ . '/../cache');
$view->parserExtensions = array(new Views\TwigExtension());
$basePath = substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/'));
$cssPath = $basePath . '/css/';
$jsPath = $basePath . '/js/';
$fontPath = $basePath . '/fonts/';
$imgPath = $basePath . '/img';
$twig = $view->getEnvironment();
$twig->addGlobal('app_name', 'nohassl_bus');
$twig->addGlobal('css_dir', $cssPath);
$twig->addGlobal('js_dir', $jsPath);
$twig->addGlobal('font_dir', $fontPath);
$twig->addGlobal('img_dir', $imgPath);
コード例 #26
0
ファイル: start.php プロジェクト: owency/Owency
use Owency\Middleware\BeforeMiddleware;
use Owency\Middleware\CsrfMiddleware;
use Owency\Mail\Mailer;
use Noodlehaus\Config;
use Mailgun\Mailgun;
use RandomLib\Factory as RandomLib;
session_cache_limiter(false);
session_start();
//Without Output Buffering, our redirects fail horribly!
ob_start();
ini_set('display_errors', 'On');
define('INC_ROOT', dirname(__DIR__));
//Composer Autoload
require INC_ROOT . '/vendor/autoload.php';
$app = new Slim(['mode' => file_get_contents(INC_ROOT . '/mode.php'), 'view' => new Twig(), 'templates.path' => INC_ROOT . '/app/views']);
$app->add(new BeforeMiddleware());
$app->add(new CsrfMiddleware());
$app->configureMode($app->config('mode'), function () use($app) {
    $app->config = Config::load(INC_ROOT . "/app/config/{$app->mode}.php");
});
require INC_ROOT . '/app/database.php';
require INC_ROOT . '/app/filters.php';
require INC_ROOT . '/app/routes/routes.php';
$app->auth = false;
$app->container->set('user', function () {
    return new User();
});
$app->container->set('bbcode', function () use($app) {
    return new Parser();
});
$app->container->singleton('hash', function () use($app) {
コード例 #27
0
ファイル: index.php プロジェクト: ok2uec/echolink-cron-system
use EcholinkSys\System;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Slim\Middleware\SessionCookie;
use Slim\Slim;
use Slim\Views\Twig;
use Slim\Views\TwigExtension;
require './vendor/autoload.php';
define("masterPassword", "heslo456", true);
define("host", "localhost", true);
define("username", "name", true);
define("password", "pass", true);
define("database", "dbname", true);
$app = new Slim(array('templates.path' => './twig', 'mode' => 'development'));
$app->setName('Echolink CRON System');
$app->add(new SessionCookie(array('expires' => '20 minutes', 'path' => '/', 'domain' => null, 'secure' => false, 'httponly' => false, 'name' => 'slim_session', 'secret' => 'CHANGE_ME', 'cipher' => MCRYPT_RIJNDAEL_256, 'cipher_mode' => MCRYPT_MODE_CBC)));
$app->container->singleton('log', function () {
    $log = new Logger('Echolink CRON System');
    $log->pushHandler(new StreamHandler('./logs/app.log', Logger::DEBUG));
    return $log;
});
// Prepare view
$app->view(new Twig());
$app->view->parserOptions = array('charset' => 'utf-8', 'cache' => realpath('./templates/cache'), 'auto_reload' => true, 'strict_variables' => false, 'autoescape' => true);
$app->view->parserExtensions = array(new TwigExtension());
// dashboard
$app->get('/', function () use($app) {
    $app->log->info("Echolink CRON System - '/' route");
    $echolinksys = new System("mysql:host=" . host . ";dbname=" . database, username, password);
    $dataHistory = $echolinksys->getHistoryLog();
    $dataEcholinkRep = $echolinksys->getRepeaterInArray();
コード例 #28
0
ファイル: index.php プロジェクト: bigset1/blueridge
<?php

/**
 * Blueridge
 *
 * @copyright Ninelabs 2013
 * @author Moses Ngone <*****@*****.**>
 */
include "/var/www/env.php";
// Set Constants
defined('APPLICATION_ROOT') || define('APPLICATION_ROOT', realpath(dirname(__FILE__) . '/../'));
defined('APP_PATH') || define('APP_PATH', APPLICATION_ROOT . '/app');
defined('API_PATH') || define('API_PATH', APPLICATION_ROOT . '/api');
defined('BIN_PATH') || define('BIN_PATH', APPLICATION_ROOT . '/bin');
defined('CACHE_DIR') || define('CACHE_DIR', APPLICATION_ROOT . '/cache');
require APPLICATION_ROOT . '/vendor/autoload.php';
use Slim\Slim;
use Slim\Views;
use Slim\Middleware\SessionCookie;
use Blueridge\Application;
use Blueridge\Middleware\Authentication;
use Blueridge\Middleware\View;
$blueridge = new Application();
$app = new Slim($blueridge['configs']['app']);
$app->setName('blueridgeapp');
$app->add(new View());
$app->add(new Authentication($blueridge));
require APP_PATH . "/init.php";
require API_PATH . "/init.php";
$app->run();
コード例 #29
0
ファイル: start.php プロジェクト: bogiesoft/php-auth
use Slim\Slim;
use Slim\Views\Twig;
use Slim\Views\TwigExtension;
use Noodlehaus\Config;
use Myproject\User\User;
use Myproject\Helpers\Hash;
use Myproject\Validation\Validator;
use Myproject\Middleware\BeforeMiddleware;
session_cache_limiter(false);
session_start();
ini_set('display_errors', 'On');
define(INC_ROOT, dirname(__DIR__));
require INC_ROOT . '/vendor/autoload.php';
$app = new Slim(['mode' => file_get_contents(INC_ROOT . '/mode.php'), 'view' => new Twig(), 'templates.path' => INC_ROOT . '/app/views']);
$app->add(new BeforeMiddleware());
$app->configureMode($app->config('mode'), function () use($app) {
    $app->config = Config::load(INC_ROOT . "/app/config/{$app->mode}.php");
});
require 'database.php';
require 'routes.php';
$app->auth = false;
$app->container->set('user', function () {
    return new User();
});
$app->container->singleton('hash', function () use($app) {
    return new Hash($app->config);
});
$app->container->singleton('validation', function () use($app) {
    return new Validator($app->user);
});
コード例 #30
0
ファイル: start.php プロジェクト: aankittcoolest/lunchbox
use Lunchbox\User\User;
use Lunchbox\Menu\Category;
use Lunchbox\Menu\History;
use Lunchbox\Menu\MenuList;
use Lunchbox\Menu\AdminList;
use Lunchbox\Helpers\Hash;
use Lunchbox\Mail\Mailer;
use Lunchbox\Validation\Validator;
use Lunchbox\Validation\ValidateList;
session_cache_limiter(false);
session_start();
ini_set('display_errors', 'On');
define('INC_ROOT', dirname(__DIR__));
require INC_ROOT . '/vendor/autoload.php';
$app = new Slim(['mode' => rtrim(file_get_contents(INC_ROOT . '/mode.php')), 'view' => new Twig(), 'templates.path' => INC_ROOT . '/app/views']);
$app->add(new Lunchbox\Middleware\BeforeMiddleware());
$app->add(new Lunchbox\Middleware\CsrfMiddleware());
$app->config = Config::load(INC_ROOT . "/app/config/{$app->mode}.php");
require 'database.php';
require 'filters.php';
require 'routes.php';
$app->container->set('user', function () {
    return new User();
});
$app->container->singleton('hash', function () use($app) {
    return new Hash($app->config);
});
$app->container->set('categories', function () {
    return new Category();
});
$app->container->set('history', function () {