Пример #1
0
<?php

/**
 * Created by PhpStorm.
 * User: Amir Hossein Babaeian
 * Date: 12/26/15
 * Time: 10:44 AM
 */
use Symfony\Component\HttpFoundation\Request;
$router = new League\Route\RouteCollection();
$router->addRoute('GET', '/migrate', 'app\\controllers\\MigrationController::index');
$router->addRoute('GET', '/welcome', 'app\\controllers\\DefaultController::welcome');
$router->addRoute('GET', '/', 'app\\controllers\\DefaultController::shoutBox');
$router->addRoute('POST', '/', 'app\\controllers\\DefaultController::shoutBox');
$router->addRoute('GET', '/{uri}', 'app\\controllers\\DefaultController::index');
$dispatcher = $router->getDispatcher();
$request = Request::createFromGlobals();
$response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
$response->send();
Пример #2
0
<?php

require '../vendor/autoload.php';
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
$router = new League\Route\RouteCollection();
$router->addRoute('GET', '/', 'Rayac\\searchController::action');
$router->addRoute('POST', '/', 'Rayac\\searchController::find');
$router->addRoute('GET', '/{link}!{from}', 'Rayac\\peopleController::action');
$dispatcher = $router->getDispatcher();
$request = Request::createFromGlobals();
$response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
$response->send();
Пример #3
0
<?php

namespace Skybet;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . "/ErrorReporting/php_error.php";
\php_error\reportErrors();
error_reporting(E_ALL);
$environment = 'development';
//loading routes
$router = new \League\Route\RouteCollection();
$router->addRoute('GET', '/', 'Skybet\\Controllers\\MainController::ListAll');
// Classname::methodName
$router->addRoute('POST', '/add', 'Skybet\\Controllers\\MainController::add');
$router->addRoute('POST', '/update', 'Skybet\\Controllers\\MainController::update');
$router->addRoute('POST', '/delete', 'Skybet\\Controllers\\MainController::del');
$dispatcher = $router->getDispatcher();
$response = $dispatcher->dispatch($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']);
$response->send();
Пример #4
0
<?php

chdir('..');
include 'vendor/autoload.php';
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
$router = new League\Route\RouteCollection();
$templates = new League\Plates\Engine(dirname(__FILE__) . '/../views');
$router->addRoute('GET', '/', 'Controller::index');
# Browser routes
$router->addRoute('GET', '/device', 'Controller::device');
$router->addRoute('GET', '/auth/verify_code', 'Controller::verify_code');
$router->addRoute('GET', '/auth/redirect', 'Controller::redirect');
# Device API
$router->addRoute('POST', '/device/code', 'Controller::generate_code');
$router->addRoute('POST', '/device/token', 'Controller::access_token');
$dispatcher = $router->getDispatcher();
$request = Request::createFromGlobals();
$response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
$response->send();
Пример #5
0
/**
 * Created by PhpStorm.
 * User: balint
 * Date: 2015. 12. 05.
 * Time: 19:43
 */
include_once '../vendor/autoload.php';
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\DomCrawler\Crawler;
use Evista\Perform\Service;
use Evista\Perform\Exception\FormFieldException;
date_default_timezone_set('Europe/Budapest');
$router = new League\Route\RouteCollection();
$loader = new Twig_Loader_Filesystem('../src/views');
$crawler = new Crawler();
// Initialize form transpilation service (dependency injection friendly interface)
$formService = new Service($crawler, '../var/uploads');
$twig = new Twig_Environment($loader, array('cache' => '../var/cache'));
$twig->clearCacheFiles();
$router->addRoute('GET', '/', function (Request $request, Response $response) use($twig) {
    // do something clever
    $response = new Response($twig->render('form.twig.html', []));
    return $response;
});
$router->addRoute('POST', '/displayform', function (Request $request, Response $response) use($twig, $crawler, $formService) {
    $formMarkup = $request->request->get('serform');
    $form = $formService->transpileForm($formMarkup);
    // Dump the object
Пример #6
0
<?php

require_once __DIR__ . '/../../vendor/autoload.php';
use Symfony\Component\HttpFoundation\Request;
use League\Route\Strategy\RestfulStrategy;
$router = new League\Route\RouteCollection();
$router->setStrategy(new RestfulStrategy());
require_once '../routes.php';
$request = Request::createFromGlobals();
$dispatcher = $router->getDispatcher();
$response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
$response->send();
Пример #7
0
<?php

require __DIR__ . '/../vendor/autoload.php';
/* Register Dotenv */
$dotenv = new Dotenv\Dotenv(__DIR__ . '/..');
$dotenv->load();
/* Load Configuration */
$config = (include __DIR__ . '/config.php');
Config::getInstance()->setConfig($config);
if ($config['debug']) {
    /* Register the error handler */
    $whoops = new \Whoops\Run();
    $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler());
    $whoops->register();
}
/* Dependency Injection container */
$container = (include __DIR__ . '/dependencies.php');
Container::getInstance()->setContainer($container);
/* Boot Eloquent ORM */
include __DIR__ . '/db.php';
$request = $container->get('request');
$response = $container->get('response');
/* Router & Routes */
$route = new League\Route\RouteCollection($container);
include __DIR__ . '/routes.php';
try {
    $response = $route->dispatch($request, $response);
} catch (\League\Route\Http\Exception\NotFoundException $e) {
    $response->getBody()->write($container->get('templater')->render('errors/404'));
}
$container->get('emitter')->emit($response);
Пример #8
0
<?php

/**
 * Bootstrap. This file, the test suite, and the CLI tool all run the same bootstrap.
 */
require_once 'bootstrap.php';
/**
 * Routes.
 */
$router = new League\Route\RouteCollection();
// Assets, installation, and home.
$router->addRoute('GET', '/{file:.*\\.(?:css|js)}', 'App\\Controllers\\AssetsController::css');
$router->addRoute('GET', '/', 'App\\Controllers\\TagController::index');
// Items.
$router->addRoute('GET', '/create', 'App\\Controllers\\ItemController::edit');
$router->addRoute('POST', '/save', 'App\\Controllers\\ItemController::save');
$router->addRoute('GET', '/{id:number}', 'App\\Controllers\\ItemController::view');
$router->addRoute('GET', '/{id:number}/edit', 'App\\Controllers\\ItemController::edit');
//Tags
$router->addRoute('GET', '/t/{id:number}', 'App\\Controllers\\TagController::index');
$router->addRoute('GET', '/t/{id:number}/edit', 'App\\Controllers\\TagController::edit');
// Files
$router->addRoute('GET', '/{id:number}.png', 'App\\Controllers\\FileController::render');
$router->addRoute('GET', '/{id:number}_{size}.png', 'App\\Controllers\\FileController::render');
$router->addRoute('GET', '/{id:number}_v{version}_{size}.png', 'App\\Controllers\\FileController::render');
// Users and groups.
$router->addRoute('GET', '/login', 'App\\Controllers\\UserController::loginForm');
$router->addRoute('POST', '/login', 'App\\Controllers\\UserController::login');
$router->addRoute('GET', '/register', 'App\\Controllers\\UserController::registerForm');
$router->addRoute('POST', '/register', 'App\\Controllers\\UserController::register');
$router->addRoute('GET', '/remind/{userid}/{token}', 'App\\Controllers\\UserController::remindResetForm');
Пример #9
0
<?php

chdir('..');
include 'vendor/autoload.php';
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
$router = new League\Route\RouteCollection();
$templates = new League\Plates\Engine(dirname(__FILE__) . '/../views');
$router->addRoute('GET', '/', 'Controller::index');
$router->addRoute('GET', '/dashboard', 'Controller::dashboard');
$router->addRoute('GET', '/api', 'Controller::api');
$router->addRoute('GET', '/webmention/{code}/details', 'Controller::webmention_details');
$router->addRoute('GET', '/dashboard/send', 'Controller::dashboard_send');
$router->addRoute('POST', '/dashboard/get_outgoing_links.json', 'Controller::get_outgoing_links');
$router->addRoute('POST', '/dashboard/discover_endpoint.json', 'Controller::discover_endpoint');
$router->addRoute('POST', '/webmention', 'API::webmention');
$router->addRoute('GET', '/webmention/{code}', 'API::webmention_status');
$router->addRoute('GET', '/login', 'Auth::login');
$router->addRoute('GET', '/logout', 'Auth::logout');
$router->addRoute('POST', '/login/start', 'Auth::login_start');
$router->addRoute('GET', '/login/callback', 'Auth::login_callback');
$dispatcher = $router->getDispatcher();
$request = Request::createFromGlobals();
$response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
$response->send();
Пример #10
0
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
require_once __DIR__ . '/../vendor/autoload.php';
$dotenv = new Dotenv\Dotenv(__DIR__ . '/..');
$dotenv->load();
$json = json_decode(file_get_contents('../game_data/' . getenv('CURRENT_GAME') . '.json'), true);
$config = [];
$config = ['enable_toggle' => false];
$config['contestants'] = $json['contestants'];
$config['players'] = array_map(function (array $contestant_info) {
    return $contestant_info['name'];
}, $json['contestants']);
$config['display_host'] = false;
$loader = new Twig_Loader_Filesystem('views');
$twig = new Twig_Environment($loader);
$router = new \League\Route\RouteCollection();
$router->get('/', function (Request $request, Response $response) use($twig, $config) {
    $response->setContent($twig->render('index.html.twig', ['players' => $config['players']]));
    return $response;
});
$router->get('/play', function (Request $request, Response $response, array $args) use($twig, $config) {
    return new RedirectResponse('/');
});
$router->get('/obs', function (Request $request, Response $response, array $args) use($twig, $config) {
    $response->setContent($twig->render('obs.html.twig', ['players' => $config['players'], 'display_host' => $config['display_host'], 'contestants' => $config['contestants']]));
    return $response;
});
$router->get('/play/{player}', function (Request $request, Response $response, array $args) use($twig, $config) {
    $player = $args['player'];
    if (!in_array($player, $config['players'], true)) {
        return new RedirectResponse('/');
Пример #11
0
<?php

use Rayac\skola\user;
use Symfony\Component\HttpFoundation\Request;
require_once '../vendor/autoload.php';
session_start();
$router = new League\Route\RouteCollection();
if (empty($_SESSION['language'])) {
    $_SESSION['language'] = "en";
}
$router->addRoute('GET', '/', 'Rayac\\skola\\controllers\\homeController::action');
$router->addRoute('GET', '/hr', 'Rayac\\skola\\controllers\\languageController::croatia');
$router->addRoute('GET', '/en', 'Rayac\\skola\\controllers\\languageController::english');
$router->addRoute('GET', '/reg', 'Rayac\\skola\\controllers\\regController::action');
$router->addRoute('GET', '/login', 'Rayac\\skola\\controllers\\loginController::action');
$router->addRoute('GET', '/logout', 'Rayac\\skola\\controllers\\loginController::logout');
$router->addRoute('GET', '/gallery', 'Rayac\\skola\\controllers\\homeController::gallery');
$router->addRoute('GET', '/aboutus', 'Rayac\\skola\\controllers\\homeController::aboutus');
$router->addRoute('GET', '/account', 'Rayac\\skola\\controllers\\accountController::action');
$router->addRoute('GET', '/create', 'Rayac\\skola\\controllers\\postController::action');
$router->addRoute('GET', '/plan/{id}', 'Rayac\\skola\\controllers\\postController::show');
$router->addRoute('POST', '/create', 'Rayac\\skola\\controllers\\postController::create');
$router->addRoute('POST', '/login', 'Rayac\\skola\\controllers\\loginController::login');
$router->addRoute('POST', '/reg', 'Rayac\\skola\\controllers\\regController::register');
$router->addRoute('POST', '/filipmail', 'Rayac\\skola\\controllers\\homeController::filipmail');
//$router->addRoute('GET', '/{link}!{from}', 'Rayac\peopleController::action');
$dispatcher = $router->getDispatcher();
$request = Request::createFromGlobals();
$response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
$response->send();
Пример #12
0
<?php

chdir('..');
include 'vendor/autoload.php';
use Errbit\Errbit;
if (Config::$errbitHost) {
    Errbit::instance()->configure(array('api_key' => Config::$errbitKey, 'host' => Config::$errbitHost, 'port' => 443, 'secure' => true))->start();
}
initdb();
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
$router = new League\Route\RouteCollection();
$templates = new League\Plates\Engine(dirname(__FILE__) . '/../views');
$router->addRoute('GET', '/', 'Controller::index');
$router->addRoute('GET', '/dashboard', 'Controller::dashboard');
$router->addRoute('GET', '/site/new', 'Controller::new_site');
$router->addRoute('GET', '/site/edit', 'Controller::new_site');
$router->addRoute('POST', '/site/save', 'Controller::save_site');
$router->addRoute('GET', '/api', 'Controller::api');
$router->addRoute('GET', '/superfeedr', 'Controller::superfeedr');
$router->addRoute('GET', '/webmention/{code}/details', 'Controller::webmention_details');
$router->addRoute('GET', '/dashboard/send', 'Controller::dashboard_send');
$router->addRoute('POST', '/dashboard/get_outgoing_links.json', 'Controller::get_outgoing_links');
$router->addRoute('POST', '/dashboard/discover_endpoint.json', 'Controller::discover_endpoint');
$router->addRoute('POST', '/webmention', 'API::webmention');
$router->addRoute('POST', '/superfeedr/{token}', 'API::superfeedr_tracker');
$router->addRoute('GET', '/webmention/{code}', 'API::webmention_status');
$router->addRoute('GET', '/login', 'Auth::login');
$router->addRoute('GET', '/logout', 'Auth::logout');
$router->addRoute('POST', '/login/start', 'Auth::login_start');
$router->addRoute('GET', '/login/callback', 'Auth::login_callback');
<?php

// register autoload
require 'vendor/autoload.php';
// use keyword to avoid FQCN declaration
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use League\Route\Http\Exception\NotFoundException;
use Workshop\About;
use Workshop\Profile;
// create route collection
$router = new League\Route\RouteCollection();
// create page object
$about = new About();
$profile = new Profile();
// register route
$router->addRoute('GET', '/about', $about);
$router->addRoute('GET', '/profile', $profile);
// create route dispatcher
$dispatcher = $router->getDispatcher();
// create request object from globals
$request = Request::createFromGlobals();
try {
    // dispatch request
    $response = $dispatcher->dispatch($request->getMethod(), $request->getRequestUri());
} catch (NotFoundException $e) {
    // catch not found exception
    $response = new Response('Not Found', Response::HTTP_NOT_FOUND, ['Content-Type' => 'text/html']);
} finally {
    // send response to browser
    $response->send();
Пример #14
0
<?php

include_once dirname(__DIR__) . '/vendor/autoload.php';
/** @var League\Container\Container $container */
$container = new League\Container\Container();
/** @var League\Route\RouteCollection $router */
$router = new League\Route\RouteCollection($container);
include_once dirname(__DIR__) . '/includes/services.php';
include_once dirname(__DIR__) . '/includes/routes.php';
$dispatcher = $router->getDispatcher();
$request = Symfony\Component\HttpFoundation\Request::createFromGlobals();
$response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
$response->send();