public function getApp(Container $container) { $app = new \SlimController\Slim(array('controller.class_prefix' => 'CollegeFBWeb\\Controllers\\Api', 'controller.method_suffix' => 'Action', 'di' => $container)); $app->addRoutes(array('/' => 'Index:index', '/colleges(/)' => 'Colleges:index', '/colleges/:id_college' => 'College:index', '/conferences(/)' => 'Conferences:index', '/conferences/:id_conference' => 'Conference:index', '/news(/)' => 'News:index', '/news/:id_news' => 'SingleNews:index')); $app->add(new \SlimJson\Middleware(array('json.status' => false, 'json.override_error' => true, 'json.override_notfound' => true, 'json.cors' => true))); return $app; }
public function getApp(Container $container) { $app = new \SlimController\Slim(array('controller.class_prefix' => 'CollegeFBWeb\\Controllers\\Web', 'controller.method_suffix' => 'Action', 'templates.path' => $container['web_templates_path'], 'controller.template_suffix' => 'twig', 'di' => $container)); $app->addRoutes(array('/' => 'Index:home', '/conferences(/:division)' => 'Conferences:list', '/conference/:conference' => 'Conferences:one', '/colleges(/:division)' => 'Colleges:list', '/college/:college' => 'Colleges:one')); $app->view(new \Slim\Views\Twig()); $app->view->parserExtensions = array(new \Slim\Views\TwigExtension()); return $app; }
public function getApp(Container $container) { $app = new \SlimController\Slim(array('controller.class_prefix' => 'CollegeFBWeb\\Controllers\\Admin', 'controller.method_suffix' => 'Action', 'templates.path' => $container['admin_templates_path'], 'controller.template_suffix' => 'twig', 'di' => $container)); $app->addRoutes(array('/dashboard' => 'Index:dashboard', '/logout' => 'Index:logout', '/login' => 'Index:login')); $app->view(new \Slim\Views\Twig()); $app->view->parserExtensions = array(new \Slim\Views\TwigExtension()); $app->add(new \CollegeFBWeb\Slim\Middleware\Auth('Index:login', 'Index:logout', 'Index:dashboard')); return $app; }
<?php /* load app */ require 'app/bootstrap.php'; // register Slim auto-loader \Slim\Slim::registerAutoloader(); // init app $app = new \SlimController\Slim(array('templates.path' => ABSPATH . '/FindSite/View', 'Controller.class_prefix' => '\\FindSite\\Controller', 'Controller.class_suffix' => 'Controller', 'Controller.method_suffix' => 'Action', 'Controller.template_suffix' => 'php')); // add content type middleware, so the JSON request will be parsed automatically $app->add(new \Slim\Middleware\ContentTypes()); // add session middleware $app->add(new \Slim\Middleware\SessionCookie(array('expires' => '60 minutes', 'path' => '/', 'domain' => null, 'secure' => false, 'httponly' => false, 'name' => 'slim_session', 'secret' => 'flS3p4PCRD', 'cipher' => MCRYPT_RIJNDAEL_256, 'cipher_mode' => MCRYPT_MODE_CBC))); $app->addRoutes(array('/' => 'Home:index', '/agent' => 'Agent:index', '/agent/contact' => 'Agent:contact', '/site' => 'Site:index', '/site/list' => 'Site:list', '/site/add' => 'Site:add', '/site/detail/:id' => 'Site:detail', '/user' => 'User:index', '/user/login' => 'User:login', '/user/register' => 'User:register')); /* init error handler*/ $errorHandler = new \FindSite\Infrastructure\Handler\ErrorHandler($app); $errorHandler->register(); $app->run();
<?php // Errors error_reporting(E_ALL); ini_set('display_errors', '1'); date_default_timezone_set('UTC'); // Load require '../vendor/autoload.php'; // Load configs $config = (require '../app/Config/config.php'); $routes = (require '../app/Config/routes.php'); // Session session_cache_limiter(false); session_start(); // Startup $app = new \SlimController\Slim(['mode' => $config['app_mode'], 'debug' => $config['app_debug'], 'cookies.lifetime' => $config['app_cookie_ttl'], 'cookies.secret_key' => $config['app_cookie_secret'], 'view' => new \Slim\Views\Twig(), 'templates.path' => '../app/Templates', 'controller.class_prefix' => '\\Controllers', 'controller.method_suffix' => 'Action', 'controller.template_suffix' => 'php', 'cookies.encrypt' => true]); // Views $view = $app->view(); $view->parserOptions = ['debug' => $config['app_debug'], 'cache' => '../cache']; $view->parserExtensions = [new \Slim\Views\TwigExtension()]; $view->setTemplatesDirectory('../app/Templates/'); // Add global values $app->config = $config; $app->view->getEnvironment()->addGlobal('config', $config); // Add moltin middleware $app->add(new \Middleware\Moltin($config)); // Routes $app->addRoutes($routes); // GO! $app->run();
<?php error_reporting(E_ALL ^ E_NOTICE); ini_set('display_errors', 1); // define a working directory define('APP_PATH', __DIR__); // PHP v5.3+ // load require APP_PATH . '/vendor/autoload.php'; // init app $app = new \SlimController\Slim(array('templates.path' => APP_PATH . '/templates', 'controller.class_prefix' => '\\MyApp\\Controller', 'controller.method_suffix' => 'Action', 'controller.template_suffix' => 'php')); $app->addRoutes(array('/feed/:type' => 'Feed\\Feed:index')); $app->run();
<?php // define a working directory define('APP_PATH', __DIR__); // PHP v5.3+ require APP_PATH . '/../vendor/autoload.php'; date_default_timezone_set('UTC'); session_start(); // Prepare app $app = new \SlimController\Slim(array('templates.path' => APP_PATH . '/../templates', 'controller.class_prefix' => '\\dealdb\\Controller', 'controller.method_suffix' => 'Action', 'controller.template_suffix' => 'twig')); // Prepare view $app->view(new \Slim\Views\Twig()); $app->view->parserOptions = array('charset' => 'utf-8', 'cache' => realpath(APP_PATH . '/../templates/cache'), 'auto_reload' => true, 'strict_variables' => false, 'autoescape' => true); $app->view->parserExtensions = array(new \Slim\Views\TwigExtension()); // Define routes $app->addRoutes(array('/' => 'Stat:index', '/clearQiwi' => 'Stat:clearQiwi', '/add' => ['get' => 'Deal:add', 'post' => 'Deal:addDeal'], '/all' => 'Deal:all', '/export' => 'Deal:export')); // Run app $app->run();
<?php require 'vendor/autoload.php'; define('APP_PATH', dirname(__DIR__)); session_cache_limiter(false); session_start(); $app = new \Slim\Slim(); use RedBeanPHP\R; R::setup('mysql:host=localhost;dbname=naughtyfire', 'root', 'nitoryolai'); $app = new \SlimController\Slim(array('controller.class_prefix' => '\\Naughtyfire\\Controller', 'controller.method_suffix' => 'Action', 'controller.template_suffix' => 'php')); $app->addRoutes(array('/' => 'Home:index', '/holiday/create' => 'Home:createHoliday', '/settings' => 'Home:settings', '/settings/update' => 'Home:updateSettings', '/recepients' => 'Home:recepients', '/recepients/new' => 'Home:newRecepient', '/recepients/create' => 'Home:createRecepient', '/notify' => 'Notifier:notify')); $view = $app->view(); $view->setTemplatesDirectory('./templates'); $app->run();
<?php error_reporting(-1); ini_set('error_reporting', E_ALL); // define a working directory define('APP_PATH', getenv('APP_PATH')); // load require APP_PATH . '/vendor/autoload.php'; // init app $app = new \SlimController\Slim(['debug' => true, 'templates.path' => APP_PATH . '/src/Retail/View', 'controller.class_prefix' => '\\Retail\\Controller', 'controller.method_suffix' => 'Action', 'controller.template_suffix' => 'php']); $app->addRoutes(['/' => 'Index:index', '/product/:id' => 'Product:get', '/edit' => 'Product:edit', '/edit/:id' => 'Product:edit', '/add' => 'Product:add', '/product/:name' => ['post' => ['Home:hello', function () { error_log("THIS ROUTE IS ONLY POST"); }]]]); // bootstrap routes $app->run();
<?php session_start(); require 'vendor/autoload.php'; $app = new \SlimController\Slim(array('templates.path' => 'templates')); $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->hook('slim.before', function () use($app) { $app->view()->appendData(array('baseUrl' => '/tester/ebay_trading_api')); }); $app->container->singleton('db', function () { $server = 'localhost'; $user = '******'; $pass = ''; $database = 'ebaytrading'; return new mysqli($server, $user, $pass, $database); }); $app->container->singleton('ebay', function () use($app) { $id = 1; $settings_result = $app->db->query("SELECT user_token, run_name, dev_id, app_id, cert_id, site_id FROM settings WHERE id = {$id}"); $settings = $settings_result->fetch_object(); return new Ebay($settings); }); $app->addRoutes(array('/' => 'Home:index', '/settings' => 'Settings:view', '/settings/update' => 'Settings:update', '/products/new' => 'Product:new', '/products/create' => 'Product:create', '/upload' => 'Product:upload', '/session' => 'Home:session', '/token' => 'Home:token', '/categories' => 'Product:categories')); $app->run();
//mostrar erros no navegador error_reporting(E_ALL); ini_set("display_errors", 1); require '../vendor/autoload.php'; // init app $app = new \SlimController\Slim(array('templates.path' => '../src/PHPAuth/Views', 'controller.class_prefix' => '\\PHPAuth\\Controllers', 'controller.method_suffix' => 'Action', 'controller.template_suffix' => 'html')); // monolog logger $app->container->singleton('log', function () { $log = new \Monolog\Logger('php-auth'); $log->pushHandler(new \Monolog\Handler\StreamHandler('../logs/php-auth.log', \Monolog\Logger::DEBUG)); return $log; }); // config views $app->view(new \Slim\Views\Twig()); $app->view->parserOptions = array('charset' => 'utf-8', 'cache' => realpath('../src/PHPAuth/Views/cache'), 'auto_reload' => true, 'strict_variables' => false, 'autoescape' => true); $app->view->parserExtensions = array(new \Slim\Views\TwigExtension()); $app->addRoutes(array('/' => 'HomeController:index', '/roles' => 'RolesController:index', '/roles/new' => 'RolesController:new', '/roles/create' => array('post' => array('RolesController:create', function () { error_log("Roles create /roles/create"); })), '/roles/:id' => 'RolesController:show', '/roles/:id/update' => array('put' => array('RolesController:update', function () { error_log("Roles update /roles/update"); })), '/roles/:id/edit' => 'RolesController:edit', '/groups' => 'GroupsController:index', '/groups/new' => 'GroupsController:new', '/groups/create' => array('post' => array('GroupsController:create', function () { error_log("Groups create /groups/create"); })), '/groups/:id' => 'GroupsController:show', '/groups/:id/update' => array('put' => array('GroupsController:update', function () { error_log("Groups update /groups/update"); })), '/groups/:id/edit' => 'GroupsController:edit', '/users' => 'UsersController:index', '/users/new' => 'UsersController:new', '/users/create' => array('post' => array('UsersController:create', function () { error_log("users create /users/create"); })), '/users/:id' => 'UsersController:show', '/users/:id/update' => array('put' => array('UsersController:update', function () { error_log("users update /users/update"); })), '/users/:id/edit' => 'UsersController:edit')); $app->run();