Inheritance: extends Illuminate\Container\Container, use trait Laravel\Lumen\Concerns\RoutesRequests, use trait Laravel\Lumen\Concerns\RegistersExceptionHandlers
 protected function setupApplication()
 {
     // Create the application such that the config is loaded.
     $app = new Application(sys_get_temp_dir());
     $app->instance('config', new Repository());
     return $app;
 }
コード例 #2
0
ファイル: Redirector.php プロジェクト: emsdog/lumen-todo
 /**
  * Create a new redirect response.
  *
  * @param  string  $path
  * @param  int     $status
  * @param  array   $headers
  * @return \Illuminate\Http\RedirectResponse
  */
 protected function createRedirect($path, $status, $headers)
 {
     $redirect = new RedirectResponse($path, $status, $headers);
     $redirect->setRequest($this->app->make('request'));
     $redirect->setSession($this->app->make('session.store'));
     return $redirect;
 }
コード例 #3
0
 /**
  * After each scenario, reboot the kernel.
  */
 public function reboot()
 {
     Facade::clearResolvedInstances();
     $lumen = new LumenBooter($this->app->basePath());
     $this->context->getSession('lumen')->getDriver()->reboot($this->app = $lumen->boot());
     $this->setAppOnContext();
 }
コード例 #4
0
ファイル: RunsLumen.php プロジェクト: nordsoftware/lumen-core
 /**
  * Stops the application.
  */
 private function stopApplication()
 {
     if ($this->application) {
         $this->application->flush();
         $this->application = null;
     }
 }
コード例 #5
0
 /**
  * Bootstrap the application events.
  *
  * @return void
  */
 public function boot()
 {
     $app = $this->app;
     if ($app->runningInConsole()) {
         $this->app['config']->set('debugbar.enabled', false);
     }
     $routeConfig = ['namespace' => 'Barryvdh\\Debugbar\\Controllers', 'prefix' => $this->app['config']->get('debugbar.route_prefix')];
     $this->app->group($routeConfig, function ($router) {
         $router->get('open', ['uses' => 'OpenHandlerController@handle', 'as' => 'debugbar.openhandler']);
         $router->get('assets/stylesheets', ['uses' => 'AssetController@css', 'as' => 'debugbar.assets.css']);
         $router->get('assets/javascript', ['uses' => 'AssetController@js', 'as' => 'debugbar.assets.js']);
     });
     $enabled = $this->app['config']->get('debugbar.enabled');
     // If enabled is null, set from the app.debug value
     if (is_null($enabled)) {
         $enabled = env('APP_DEBUG');
         $this->app['config']->set('debugbar.enabled', $enabled);
     }
     if (!$enabled) {
         return;
     }
     $this->app['config']->set('debugbar.options.logs.file', storage_path('logs/lumen.log'));
     /** @var LaravelDebugbar $debugbar */
     $debugbar = $this->app['debugbar'];
     $debugbar->boot();
     $app->middleware(['Barryvdh\\Debugbar\\Middleware\\Debugbar']);
 }
コード例 #6
0
ファイル: Lumen.php プロジェクト: hitechdk/Codeception
 /**
  * Handle a request.
  *
  * @param SymfonyRequest $request
  * @param int $type
  * @param bool $catch
  * @return Response
  */
 public function handle(SymfonyRequest $request, $type = self::MASTER_REQUEST, $catch = true)
 {
     $this->app['request'] = $request = Request::createFromBase($request);
     $response = $this->app->handle($request);
     $method = new \ReflectionMethod(get_class($this->app), 'callTerminableMiddleware');
     $method->setAccessible(true);
     $method->invoke($this->app, $response);
     return $response;
 }
コード例 #7
0
 /**
  * Handle incoming requests.
  * @param Request $request
  * @param \Closure $next
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function handle($request, Closure $next)
 {
     if ($this->maintenance->isDownMode()) {
         if ($this->view->exists('errors.503')) {
             return new Response($this->view->make('errors.503'), 503);
         }
         return $this->app->abort(503, 'The application is down for maintenance.');
     }
     return $next($request);
 }
コード例 #8
0
ファイル: Lumen.php プロジェクト: rlacerda83/api
 /**
  * Dispatch a request.
  *
  * @param \Illuminate\Http\Request $request
  * @param string                   $version
  *
  * @return mixed
  */
 public function dispatch(Request $request, $version)
 {
     if (!isset($this->routes[$version])) {
         throw new UnknownVersionException();
     }
     $this->removeRequestMiddlewareFromApp();
     $routes = $this->routes[$version];
     $this->app->setDispatcher(new $this->dispatcher($routes->getData()));
     return $this->app->dispatch($request);
 }
コード例 #9
0
 /**
  * Create a new application instance.
  *
  * @param  string|null  $basePath
  * @return void
  */
 public function __construct($basePath = null)
 {
     parent::__construct($basePath);
     $this->withFacades();
     $this->withEloquent();
     $this->registerSingletons();
     $this->loadEnvSupport($basePath);
 }
コード例 #10
0
 /**
  * Bootstrap the application container.
  *
  * @return void
  */
 protected function bootstrapContainer()
 {
     parent::bootstrapContainer();
     $this->registerBernardProvider();
     $this->registerDoctrineProvider();
     $this->registerTacticianProvider();
     $this->registerJwtAuthServiceProvider();
     $this->registerSyndraServiceProvider();
 }
コード例 #11
0
 /**
  * Get the Monolog handler for the application.
  *
  * @return \Monolog\Handler\AbstractHandler
  */
 protected function getMonologHandler()
 {
     if (env('LOG_UDP_HOST')) {
         return new SyslogUdpHandler(env('LOG_UDP_HOST'), env('LOG_UDP_PORT'));
     }
     // @codeCoverageIgnoreStart
     return parent::getMonologHandler();
     // @codeCoverageIgnoreEnd
 }
コード例 #12
0
 /**
  * Specify a list of jobs that should be dispatched for the given operation.
  *
  * These jobs will be mocked, so that handlers will not actually be executed.
  *
  * @param  array|string  $jobs
  * @return $this
  */
 protected function expectsJobs($jobs)
 {
     $jobs = is_array($jobs) ? $jobs : func_get_args();
     $mock = Mockery::mock('Illuminate\\Bus\\Dispatcher[dispatch]', [$this->app]);
     foreach ($jobs as $job) {
         $mock->shouldReceive('dispatch')->atLeast()->once()->with(Mockery::type($job));
     }
     $this->app->instance('Illuminate\\Contracts\\Bus\\Dispatcher', $mock);
     return $this;
 }
コード例 #13
0
 /**
  * @param string $controllerAction
  *
  * @return mixed
  *
  *
  * Add the missing implementation by using this as inspiration:
  * https://gist.github.com/radmen/92200c62b633320b98a8
  */
 protected function uriGenerator($controllerAction)
 {
     /** @var array $routes */
     $routes = Application::getInstance()->getRoutes();
     foreach ($routes as $route) {
         if ($route['action'] === $controllerAction) {
             return $route;
         }
     }
 }
コード例 #14
0
ファイル: UrlGenerator.php プロジェクト: Calky/uas
 /**
  * Get the base URL for the request.
  *
  * @param  string  $scheme
  * @param  string  $root
  * @return string
  */
 protected function getRootUrl($scheme, $root = null)
 {
     if (is_null($root)) {
         if (is_null($this->cachedRoot)) {
             $this->cachedRoot = $this->app->make('request')->root();
         }
         $root = $this->cachedRoot;
     }
     $start = starts_with($root, 'http://') ? 'http://' : 'https://';
     return preg_replace('~' . $start . '~', $scheme, $root, 1);
 }
コード例 #15
0
 public function __construct($basePath = null)
 {
     parent::__construct($basePath);
     // Use bucket-based storage when not running in dev.
     // Needed for template caching.
     if (array_key_exists('APPLICATION_ID', $_SERVER) && substr($_SERVER['APPLICATION_ID'], 0, 3) !== 'dev') {
         $this->useBucketForStorage();
         $this->setAppEngineEnvironment('appengine');
     } else {
         $this->setAppEngineEnvironment('dev');
     }
 }
コード例 #16
0
ファイル: Application.php プロジェクト: matiux/lumen-expander
 /**
  *
  *
  * @param ReflectionParameter $parameter
  * @param array $parameters
  * @param array $dependencies
  * @return mixed|void
  */
 protected function addDependencyForCallParameter(ReflectionParameter $parameter, array &$parameters, &$dependencies)
 {
     try {
         $c = $parameter->getClass()->name;
         $v = $parameters[$parameter->name];
         //$classParam     = new \ReflectionClass($parameter->getClass());
         //$classCheck     = new \ReflectionClass('AoApi\Models\AoApiModel');
     } catch (ErrorException $e) {
         /**
          * Se sono qui è perche non ho usato il type Hinting nei parametri dei metodi dei controller
          */
         //if (!$classParam->isInstance($classCheck)) {
         return parent::addDependencyForCallParameter($parameter, $parameters, $dependencies);
         //}
     }
     try {
         $model = $c::findOrFail($v);
         $dependencies[] = $model;
         unset($parameters[$parameter->name]);
     } catch (ModelNotFoundException $e) {
         abort(404, sprintf("'The {$c} %s was not found.'", $v));
     }
 }
コード例 #17
0
 /**
  * @param Application $app
  * @param Closure[] $routes
  */
 public static function apply(Application $app, array $routes)
 {
     foreach ($routes as $pattern => $handler) {
         list($method, $pattern) = array_values(array_filter(explode(' ', $pattern)));
         $pattern = preg_replace('/@([\\w]+)/', '{$1}', $pattern);
         switch ($method) {
             case 'GET':
                 $app->get($pattern, $handler);
                 break;
             case 'POST':
                 $app->post($pattern, $handler);
                 break;
             case 'PUT':
                 $app->put($pattern, $handler);
                 break;
             case 'DELETE':
                 $app->delete($pattern, $handler);
                 break;
             case 'PATCH':
                 $app->patch($pattern, $handler);
                 break;
         }
     }
 }
コード例 #18
0
ファイル: song-changes.php プロジェクト: jrenton/volumio
<?php

// Song changes is responsible for listening on port 4500
// which is used when a song is changed (via SongChangeNotifier), and then
// sending the message to web socket port 8082
require __DIR__ . '/vendor/autoload.php';
Dotenv::load(__DIR__);
use Laravel\Lumen\Application;
$app = new Application(realpath(__DIR__));
$pusher = $app->make("App\\Volumio\\WebSockets\\PlayerWebSocket");
$loop = React\EventLoop\Factory::create();
//$pusher = new App\Volumio\WebSockets\PlayerWebSocket;
// Listen for the web server to make a ZeroMQ push after an ajax request
$context = new React\ZMQ\Context($loop);
$pull = $context->getSocket(ZMQ::SOCKET_PULL);
// Listen to any song changes over port 4500
$pull->bind('tcp://127.0.0.1:4500');
// Binding to 127.0.0.1 means the only client that can connect is itself
$pull->on('message', array($pusher, 'onReceiveMessage'));
// Set up our WebSocket server for clients wanting real-time updates
$webSock = new React\Socket\Server($loop);
$webSock->listen(8082, '0.0.0.0');
// Binding to 0.0.0.0 means remotes can connect
$webServer = new Ratchet\Server\IoServer(new Ratchet\Http\HttpServer(new Ratchet\WebSocket\WsServer(new Ratchet\Wamp\WampServer($pusher))), $webSock);
$loop->run();
コード例 #19
0
 /**
  * Assert that a given where condition does not exist in the database.
  *
  * @param  string  $table
  * @param  array  $data
  * @return $this
  */
 protected function notSeeInDatabase($table, array $data)
 {
     $count = $this->app->make('db')->table($table)->where($data)->count();
     $this->assertEquals(0, $count, sprintf('Found unexpected records in database table [%s] that matched attributes [%s].', $table, json_encode($data)));
     return $this;
 }
コード例 #20
0
 public function testMiddlewareReceiveResponsesEvenWhenStringReturned()
 {
     unset($_SERVER['__middleware.response']);
     $app = new Application();
     $app->routeMiddleware(['foo' => 'LumenTestPlainMiddleware']);
     $app->get('/', ['middleware' => 'foo', function () {
         return 'Hello World';
     }]);
     $response = $app->handle(Request::create('/', 'GET'));
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertEquals('Hello World', $response->getContent());
     $this->assertEquals(true, $_SERVER['__middleware.response']);
 }
コード例 #21
0
ファイル: spotify-listen.php プロジェクト: jrenton/volumio
<?php

require __DIR__ . '/vendor/autoload.php';
Dotenv::load(__DIR__);
use App\Volumio\Spotify\SpotifySocket;
use Laravel\Lumen\Application;
$loop = React\EventLoop\Factory::create();
$app = new Application(realpath(__DIR__));
$pusher = $app->make("App\\Volumio\\Spotify\\SpotifySocket");
$client = SpotifySocket::getInstance();
fputs($client, "idle\n");
$message = fgets($client);
$loop->addReadStream($client, function ($client) use($loop, $pusher) {
    $message = fgets($client);
    fputs($client, "idle\n");
    $pusher->onMessage($message);
});
$loop->run();
コード例 #22
0
 /**
  * @inheritdoc
  */
 public function __construct($basePath = null)
 {
     parent::__construct(realpath(__DIR__ . '/../'));
 }
コード例 #23
0
 public function testRedirectToNamedRoute()
 {
     $app = new Application();
     $app->get('login', ['as' => 'login', function (Illuminate\Http\Request $request) {
         return 'login';
     }]);
     $app->get('/', function (Illuminate\Http\Request $request) {
         return redirect()->route('login');
     });
     $response = $app->handle(Request::create('/', 'GET'));
     $this->assertEquals(302, $response->getStatusCode());
 }
コード例 #24
0
 /**
  * Maintenance file path.
  *
  * @return string
  */
 public function maintenanceFilePath()
 {
     return $this->app->storagePath($this->maintenanceFile);
 }
コード例 #25
0
 protected function get($method, $pathRoot, $controller, $routeNamePrefix)
 {
     $path = $pathRoot . $this->methodPathBind[$method];
     $this->app->get($path, $this->getAction($routeNamePrefix, $controller, $method));
 }
コード例 #26
0
 public function testEnvironmentDetection()
 {
     $app = new Application();
     $this->assertEquals('production', $app->environment());
     $this->assertTrue($app->environment('production'));
     $this->assertTrue($app->environment(['production']));
 }
コード例 #27
0
ファイル: Plugin.php プロジェクト: acmadi/MinionCMS
 /**
  * Load config plugin
  */
 public function registerConfig()
 {
     $this->app->make('config')->set($this->getLowerName(), require $this->path . '/' . 'config.php');
 }
コード例 #28
0
/**
 * @param \Illuminate\Container\Container|\Laravel\Lumen\Application $app
 */
function rebind($app)
{
    unset($app[IAuthBundle::class]);
    $app->bind(IAuthBundle::class, DummyAuthBundle::class);
}
コード例 #29
0
 public function testUsingCustomDispatcher()
 {
     $routes = new FastRoute\RouteCollector(new FastRoute\RouteParser\Std(), new FastRoute\DataGenerator\GroupCountBased());
     $routes->addRoute('GET', '/', [function () {
         return response('Hello World');
     }]);
     $app = new Application();
     $app->setDispatcher(new FastRoute\Dispatcher\GroupCountBased($routes->getData()));
     $response = $app->handle(Request::create('/', 'GET'));
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertEquals('Hello World', $response->getContent());
 }
コード例 #30
-2
ファイル: Lumen.php プロジェクト: corcre/elabftw
 /**
  * Get the route for a route name.
  *
  * @param string $routeName
  * @return array|null
  */
 private function getRouteByName($routeName)
 {
     foreach ($this->app->getRoutes() as $route) {
         if ($route['method'] != 'GET') {
             return;
         }
         if (isset($route['action']['as']) && $route['action']['as'] == $routeName) {
             return $route;
         }
     }
     return null;
 }