Beispiel #1
0
 /**
  * @return $this
  */
 public function run()
 {
     $this->routes = Yaml::parse(file_get_contents(__DIR__ . '/../config/routes.yml'))['routes'];
     $this->config = Yaml::parse(file_get_contents(__DIR__ . '/../config/config.yml'));
     $this->app = new \Slim\Slim(['view' => new Twig()]);
     $this->app->view()->parserOptions = ['debug' => true];
     $this->app->view()->parserExtensions = [new TwigExtension(), new \Twig_Extensions_Extension_Text(), new \Twig_Extensions_Extension_Array(), new \Twig_Extensions_Extension_Date(), new \Twig_Extensions_Extension_I18n(), new \Twig_Extensions_Extension_Intl()];
     $this->app->view()->setTemplatesDirectory(__DIR__ . '/Views/');
     $this->instantiateRoutes()->app->run();
     return $this;
 }
Beispiel #2
0
Datei: TDK.php Projekt: pasls/tdk
 protected function configureView()
 {
     $view = $this->app->view();
     $view->parserOptions = array('debug' => true, 'cache' => sys_get_temp_dir());
     $view->parserExtensions = array(new \Slim\Views\TwigExtension(), new TwigExtension($this), new \Twig_Extension_Debug());
     /** @var \Twig_Environment $twig */
     $twig = $view->getInstance();
     /** @var \Twig_Loader_Filesystem $loader */
     $loader = $twig->getLoader();
     $loader->addPath($this->options['root.dir'] . "/lib/Pasls/TDK/templates");
 }
Beispiel #3
0
 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());
 }
Beispiel #4
0
 protected function getFramework($config)
 {
     $app = new Slim(['view' => new Twig()]);
     $app->config(['templates.path' => $config['templates.path']]);
     $view = $app->view();
     $view->parserOptions = $config['parserOptions'];
     $view->parserExtensions = array(new TwigExtension());
     return $app;
 }
 public function testNoDataAppendedIfProfileKeyDoesNotExist()
 {
     $app = new Slim();
     $app->view(new SlimView());
     $mw = new Profile(array());
     $mw->setApplication($app);
     $mw->setNextMiddleware($app);
     $mw->call();
     $data = $app->view()->getData('profile');
     $this->assertEmpty($data);
 }
 public function __construct()
 {
     $slim = new Slim(['view' => new Twig()]);
     $slim->config(['templates.path' => __DIR__ . '/../../view']);
     $slim->view()->parserOptions = array('debug' => true, 'cache' => __DIR__ . '/../../compilation_cache');
     $slim->config(['content' => ['main_menu' => $this->getMainMenu()]]);
     global $config;
     ORM::configure("mysql:host={$config['host']};port={$config['port']};dbname={$config['db_name']}");
     ORM::configure('username', $config['db_user']);
     ORM::configure('password', $config['db_password']);
     ORM::configure('driver_options', [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8']);
     ORM::configure('error_mode', PDO::ERRMODE_EXCEPTION);
     $this->initSlimRoute();
 }
 public function register(Slim $app)
 {
     $app->container->singleton('cache', function () {
         return new FilesystemCache('tmp/cache/db');
     });
     $app->container->singleton('connection', function () {
         $dbOptions = (require 'config/connection.config.php');
         $config = new Configuration();
         return DriverManager::getConnection($dbOptions, $config);
     });
     $app->container->singleton('log', function () {
         $logger = new Logger('echale-gas');
         $logger->pushHandler(new StreamHandler('tmp/logs/app.log', LogLevel::DEBUG));
         return $logger;
     });
     $app->container->singleton('paginator', function () use($app) {
         return new PagerfantaPaginator($app->config('defaultPageSize'));
     });
     $app->container->singleton('paginatorFactory', function () use($app) {
         return new PaginatorFactory($app->paginator);
     });
     $app->container->singleton('proxiesConfiguration', function () use($app) {
         $config = new ProxyConfiguration();
         $config->setProxiesTargetDir('tmp/cache/proxies');
         spl_autoload_register($config->getProxyAutoloader());
         return $config;
     });
     $app->urlHelper = new TwigExtension();
     $app->container->singleton('twig', function () use($app) {
         $twig = new Twig();
         $twig->parserOptions = ['charset' => 'utf-8', 'cache' => realpath('tmp/cache/twig'), 'auto_reload' => true, 'strict_variables' => false, 'autoescape' => true];
         $twig->parserExtensions = [$app->urlHelper, new HalRendererExtension()];
         return $twig;
     });
     $app->container->singleton('controllerEvents', function () use($app) {
         $eventManager = new EventManager();
         // Ensure rendering is performed at the end by assigning a very low priority
         $eventManager->attach('postDispatch', new RenderResourceListener($app->twig), -100);
         $eventManager->attach('renderErrors', new RenderErrorsListener($app->twig), -100);
         return $eventManager;
     });
     $app->container->singleton('controller', function () use($app) {
         $controller = new RestController($app->request(), $app->response());
         $factory = new RestControllerProxyFactory($app->proxiesConfiguration, $app->controllerEvents);
         $controller = $factory->createProxy($controller);
         $factory->addEventManagement($controller);
         return $controller;
     });
     $app->view($app->twig);
 }
Beispiel #8
0
 /**
  * Setup the template service.
  *
  * @param \Slim\Slim $app The application instance.
  */
 public static function setup(Slim $app)
 {
     $debug = $app->config('debug');
     $view = $app->view(new Twig());
     $view->parserOptions = ['debug' => $debug, 'cache' => $app->config('view.cache_path')];
     $view->setTemplatesDirectory($app->config('view.path'));
     $view->parserExtensions = [new TwigExtension()];
     if ($debug) {
         $view->parserExtensions[] = new Twig_Extension_Debug();
     }
     $extensions = (array) $app->config('view.extensions');
     foreach ($extensions as $ext) {
         $view->parserExtensions[] = new $ext();
     }
 }
 public static function newInstance(\Slim\Slim $app)
 {
     try {
         $config = $app->config('connection');
         $instance = new \PDO("mysql:host={$config['mysql']['host']};dbname={$config['mysql']['database']}", $config['mysql']['user'], $config['mysql']['password'], $config['mysql']['options']);
         if (!empty($config['mysql']['execute'])) {
             foreach ($config['mysql']['execute'] as $sql) {
                 $stmt = $instance->prepare($sql);
                 $stmt->execute();
             }
         }
     } catch (\PDOException $p) {
         //$this->slim->log->error('BAD THINGS');
         return $app->halt(500, $app->view()->fetch('error/500.php'));
     }
     return $instance;
 }
Beispiel #10
0
 /**
  * This function adds the clickable labels with alternate formats to the results webpage
  *
  * @return void
  */
 protected function prepareWebResultView()
 {
     // mime type buttons
     // TODO:
     // get mimetypes of the current route and
     // only output the buttons for the allowed mimetypes of that route
     // $currentRouteAcceptableMimeTypes = $this->app->router()->getCurrentRoute();
     // $formats = (isset($this->routeInfo->mimeTypes) ? $this->routeInfo->mimeTypes : $this->mimeLabels);
     $formats = $this->mimeLabels;
     // we are viewing a html page, so remove this result format
     // unset($formats['text/html']);
     $this->app->view()->set('alternate_formats', $formats);
     //set the current selected mime type
     $this->app->view()->set('current_mime', $this->mimeBest);
     // inject javascript
     $this->app->view()->set('javascript', '<script src="' . $this->app->request()->getRootUri() . '/assets/js/web-result.js" type="text/javascript"></script>');
 }
Beispiel #11
0
 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;
     });
 }
Beispiel #12
0
 /**
  * Portfolio constructor.
  * @param array $config
  */
 public function __construct(array $config)
 {
     Portfolio::$app = $this;
     $this->config = $config;
     $this->slim = new \Slim\Slim(['view' => new \Slim\Views\Twig()]);
     $this->slim->view()->parserOptions = array('debug' => $config['debug'], 'cache' => $config['twig']['cacheDir']);
     $this->slim->view()->parserExtensions = array(new \Slim\Views\TwigExtension());
     $this->slim->view()->setTemplatesDirectory($config['twig']['templatesDir']);
     $this->client = new \ApiClient\Client($config['vk']);
     $this->storage = new \Storage\Storage(new \Predis\Client($config['redis']));
     $group = $this->storage->getById(new \Model\Group(), -$config['vk']['owner_id']);
     $this->slim->view()->appendData(['Group' => $group]);
     $this->slim->view()->appendData(['Meta' => $this->getMetaData($config['meta'])]);
 }
Beispiel #13
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;
     });
 }
Beispiel #14
0
/**
 * Created by PhpStorm.
 * @author : Verem Dugeri
 * Date: 10/8/15
 * Time: 9:30 AM
 */
require_once 'vendor/autoload.php';
use Slim\Slim;
use Verem\Emoji\Api\AuthController;
use Verem\Emoji\Api\EmojiController;
use Verem\Emoji\Api\DAO\UserManager;
use Verem\Emoji\Api\Exceptions\RecordNotFoundException;
$app = new Slim(['templates.path' => 'templates/', 'debug' => true]);
// Prepare view
$app->view(new \Slim\Views\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 \Slim\Views\TwigExtension());
//route middleware
$authenticator = function () use($app) {
    $response = $app->response();
    $response->header("Content-type", "application/json");
    //determine if the user has authorization.
    $authorization = $app->request->headers->get('Authorization');
    if (!is_null($authorization)) {
        //check token expiry
        $manager = new UserManager();
        try {
            $user = $manager->where('token', '=', $authorization);
            if ($user['token_expire'] < date('Y-m-d H:i:s')) {
                $response->body(json_encode(['status' => 401, 'message' => 'You have no authorization']));
Beispiel #15
0
//Specify the location of the translation tables
bindtextdomain('BachViewer', APP_DIR . '/locale');
bind_textdomain_codeset('BachViewer', 'UTF-8');
//Choose domain
textdomain('BachViewer');
/** /I18n stuff */
$app = new Slim(array('debug' => APP_DEBUG, 'view' => new Twig(), 'templates.path' => APP_DIR . '/views'));
$app_base_url = '';
if (strncmp($_SERVER['PHP_SELF'], '/index.php', strlen('/index.php')) && strncmp($_SERVER['PHP_SELF'], '/debug.php', strlen('/debug.php'))) {
    preg_match('/.*(index|debug)\\.php/', $_SERVER['PHP_SELF'], $matches);
    if (isset($matches[0])) {
        $app_base_url = $matches[0];
    }
}
$viewer = new Viewer($conf, $app_base_url);
$view = $app->view();
$view->parserExtensions = array(new Twig_Extensions_Extension_I18n());
if (defined('APP_CACHE') && APP_CACHE !== false) {
    $view->parserOptions = array('cache' => APP_CACHE, 'auto_reload' => true);
}
if (!defined('DEFAULT_PICTURE')) {
    define('DEFAULT_PICTURE', 'main.jpg');
}
$app->hook('slim.before.dispatch', function () use($app, $conf, $lang, $app_base_url) {
    //let's send view parameters before dispatching
    $v = $app->view();
    $ui = $conf->getUI();
    $v->setData('app_base_url', $app_base_url);
    $v->setData('app_web_url', str_replace(array('/index.php', '/debug.php'), array('', ''), $app_base_url));
    $v->setData('enable_right_click', $ui['enable_right_click']);
    $v->setData('lang', $lang);
Beispiel #16
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());
Beispiel #17
0
$app = new Slim(array('view' => new Twig()));
$app->config('debug', false);
$app->config('templates.path', '../templates');
$app->setName('Holidays');
$app->container->singleton('db', function () {
    $database = new PDO("sqlite:" . APP_PATH . "../databases/database.sqlite");
    checkAndInitDatabase($database);
    return $database;
});
$app->container->singleton('periods', function () use($app) {
    return new Periods($app->db);
});
$app->container->singleton('allowances', function () use($app) {
    return new Allowances($app->db);
});
$view = $app->view();
$app->configureMode('production', function () use($app, $view) {
    (new Bootstrap($app, new PdoAdapter($app->db, 'users', 'user', 'hash', new PasswordValidator()), new acl()))->bootstrap();
    $app->config(array('log.enable' => true, 'templates.path' => '../templates', 'debug' => false));
    $view->parserOptions = array('debug' => false, 'cache' => dirname(__FILE__) . '/../cache', 'auto_reload' => true);
    $view->parserExtensions = array(new TwigExtension());
});
$app->configureMode('development', function () use($app, $view) {
    (new Bootstrap($app, new DebugAdapter(), new acl()))->bootstrap();
    $app->authenticator->authenticate("admin", "admin");
    $app->config(array('log.enable' => false, 'templates.path' => '../templates', 'debug' => true));
    $view->parserOptions = array('debug' => true, 'cache' => false);
    $view->parserExtensions = array(new TwigExtension(), new Twig_Extension_Debug());
});
$app->hook('slim.before.router', function () use($app) {
    if ($app->auth->hasIdentity()) {
Beispiel #18
0
<?php

session_start();
require 'vendor/autoload.php';
require 'Tazzy-Helpers/autoload.php';
use Slim\Slim;
use Carbon\Carbon;
$app = new Slim(['view' => new \Slim\Views\Twig(), 'debug' => Settings::get('debug')]);
//Middleware
$app->add(new Before());
$app->add(new Csrf());
require 'app/Middleware/auth_filters.php';
//views
$view = $app->view();
$view->setTemplatesDirectory('app/views');
$view->parserExtensions = [new \Slim\Views\TwigExtension(), new \Twig_Extension_Debug()];
//models
$app->container->set('User', function () {
    return new User();
});
$app->container->set('Exp', function () {
    return new Expenses();
});
$app->container->set('Inc', function () {
    return new Incomes();
});
$app->container->set('Tags', function () {
    return new Tags();
});
$app->container->set('ExpTags', function () {
    return new ExpTags();
Beispiel #19
0
 /**
  * Render content and status
  *
  * @param mixed $data
  * @param int $status
  */
 protected function render(array $data, $status = 200)
 {
     $this->app->view(new JsonView());
     $this->app->response()->setStatus($status);
     $this->app->render('', $data);
 }
Beispiel #20
0
        //       $session = $_SESSION['sid'];
        //       $usr = $_SESSION['usr'];
        //       $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->container->singleton('mail', function () use($app) {
    $mail = new PHPMailer();
    $mail->isSMTP();
    $mail->Host = $app->config->get('mail.host');
    $mail->SMTPAuth = $app->config->get('mail.smtp_auth');
    // Enable SMTP authentication
    $mail->Username = $app->config->get('mail.username');
    // SMTP username
    $mail->Password = $app->config->get('mail.password');
    // SMTP password
    $mail->SMTPSecure = $app->config->get('mail.smtp_secure');
    // Enable TLS encryption, `ssl` also accepted
    $mail->Port = $app->config->get('mail.port');
    $mail->isHTML($app->config->get('mail.html'));
    return new site\mail\Mailer($mail, $app->view());
});
$app->container->singleton('randomlib', function () {
    $factory = new Factory();
    return $factory->getMediumStrengthGenerator();
});
/* MULTIPLE WAYS TO RETRIEVE FROM CONTAINER/APP!!!
  $fooBar = $app->container->get('config);
  $fooBar = $app->container['congig'];
  $fooBar = $app->config;
 *  */
/**
 * Setup view config
 * */
$view = $app->view();
// if we are in debug mode turn on debuging
Beispiel #22
0
| Create Slim Application
|--------------------------------------------------------------------------
|
| Now, we will create a new Slim application instance
| which serves as the "glue" for all the components of this web-application.
|
*/
$app = new Slim(require_once ROOT . '/app/config/app.php');
$app->setName('RedSlim');
/*
 * set some globally available view-data
 */
$resourceUri = $_SERVER['REQUEST_URI'];
$rootUri = $app->request()->getRootUri();
$assetUri = $rootUri;
$app->view()->appendData(array('app' => $app, 'rootUri' => $rootUri, 'assetUri' => $assetUri, 'resourceUri' => $resourceUri));
// include all controllers
foreach (glob(ROOT . '/app/controllers/*.php') as $router) {
    include $router;
}
// disable fluid mode in production environment
$app->configureMode(SLIM_MODE_PRO, function () use($app) {
    // note, transactions will be auto-committed in fluid mode
    R::freeze(true);
});
/*
|--------------------------------------------------------------------------
| configure Twig
|--------------------------------------------------------------------------
|
| The application uses Twig as its template engine. This script configures
Beispiel #23
0
$app->jsonResponse = function () use($app) {
    return new JsonResponse($app->response);
};
$app->error(function (\Exception $e) use($app) {
    if ($e instanceof JsonResponseEncodingException) {
        $app->logger->error(sprintf("Error encoding JSON response for request path '%'", $app->request->getPathInfo()));
        $app->jsonResponse->build(array('error' => array('message' => 'Response body could not be parsed as valid JSON')), 500);
        $app->response->finalize();
    }
    $app->logger->alert('UNHANDLED EXCEPTION', array('exception' => $e));
    if (isset($_SESSION['username']) && !empty($_SESSION['username'])) {
        return $app->render('errors/500-authed.mustache');
    }
    $app->render('errors/500-guest.mustache');
});
$app->view(new Mustache());
$app->view->parserOptions = $config['mustache'];
$app->view->appendData(array('copyrightYear' => date('Y')));
$app->add(new Navigation());
$app->add(new SessionCookie(array('expires' => '12 hours')));
$isLoggedIn = function () use($app) {
    if (empty($_SESSION['username'])) {
        $app->redirect($app->urlFor('home'));
    }
};
// home
$app->get('/', function () use($app) {
    $isAuthenticated = empty($_SESSION['username']) ? false : true;
    $app->render('home/index.mustache', array('isAuthenticated' => $isAuthenticated));
})->name('home');
$app->get('/login', function () use($app) {
Beispiel #24
0
 /**
  * @param array $data
  * @return $this
  */
 public function appendDataToView(array $data)
 {
     $this->app->view()->appendData($data);
     return $this;
 }
Beispiel #25
0
use Slim\Views\Twig;
use Slim\Views\TwigExtension;
use Noodlehaus\Config;
ini_set('display_errors', 1);
error_reporting(E_ALL);
//Define Main Root
define("INC_ROOT", dirname(__DIR__));
//Define Globals
require_once INC_ROOT . "/app/config/globals.php";
//Database Info
require_once CONFIG_ROOT . "/db.php";
//Composer Autoloader
require_once INC_ROOT . "/vendor/autoload.php";
//Create Slim App
$app = new Slim(["debug" => true, "mode" => file_get_contents(INC_ROOT . "/app/mode.php"), "view" => new Twig(), "templates.path" => VIEWS_ROOT, "routes.case_sensitive" => false, "cookies.encrypt" => true, "cookies.secret_key" => "some_secret", "cookies.cipher" => MCRYPT_RIJNDAEL_256, "cookies.cipher_mode" => MCRYPT_MODE_CBC]);
//Hooks
$app->hook('slim.before', function () use($app) {
    $app->view()->appendData(array('siteUrl' => $app->config->get("template_data.url")));
});
//Set Configuration
$app->configureMode($app->config("mode"), function () use($app) {
    $app->config = Config::load(CONFIG_ROOT . "/{$app->config("mode")}.php");
});
//Include Routes
include ROUTES_ROOT . "/routes.php";
//Twig Configuration
$view = $app->view();
$view->parserOptions = ["debug" => $app->config->get("view.debug")];
$view->parserExtensions = [new TwigExtension()];
//Include Filters
require_once FILTERS_ROOT . "/filters.php";
Beispiel #26
0
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();
    $app->render('index.twig', array('dataHistory' => $dataHistory, 'dataEcholinkRepeater' => $dataEcholinkRep));
})->name('list');
// updating data
$app->get('/check', function () use($app) {
    $app->log->info("Echolink CRON System - '/check' route");
    $echolinksys = new System("mysql:host=" . host . ";dbname=" . database, username, password);
    $echolinksys->dataFromTheServer();
Beispiel #27
0
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();
Beispiel #28
0
use Ace\Helpers\Hash;
use Ace\Validation\Validator;
use Ace\Middleware\BeforeMiddleware;
session_cache_limiter(false);
session_start();
ini_set('display_errors', 'On');
define('ROOT', dirname(__DIR__));
require ROOT . '/vendor/autoload.php';
$app = new Slim(['mode' => file_get_contents(ROOT . '/mode.php'), 'view' => new Twig(), 'templates.path' => ROOT . '/app/views']);
$app->add(new BeforeMiddleware());
$app->configureMode($app->config('mode'), function () use($app) {
    $app->config = Config::load(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);
});
//$app->get('/', function () use ($app) {
//    $app->render('home.php');
//});
$view = $app->view();
$view->parserOption = ['debug' => $app->config->get('twig.debug')];
$view->parserExtensions = [new TwigExtension()];
    $dbpass = $app->config->get('db.password');
    $dbname = $app->config->get('db.name');
    $dbmethod = $app->config->get('db.method');
    $dsn = $dbmethod . $dbname;
    $pdo = new PDO($dsn, $dbuser, $dbpass);
    $db = new NotORM($pdo);
    return $db;
});
$db = $app->db;
$capsule = new Capsule();
$capsule->addConnection(['driver' => $app->config->get('db.driver'), 'host' => $app->config->get('db.host'), 'database' => $app->config->get('db.name'), '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();
/* ============================================
VIEWS
===============================================*/
$view = $app->view();
$view->parserOptions = ['debug' => $app->config->get('twig.debug')];
$view->parserExtensions = [new TwigExtension()];
$app->hook('slim.before', function () use($app) {
    $app->view()->appendData(array('AssetsURL' => $app->config->get('app.staticUrl'), 'baseAdminURL' => $app->config->get('app.adminUrl')));
});
/* ============================================
Custom Models
===============================================*/
$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) {