/** * 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; }
/** * 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); }
/** * 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; }
<?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();
/** * Load config plugin */ public function registerConfig() { $this->app->make('config')->set($this->getLowerName(), require $this->path . '/' . 'config.php'); }
<?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();
/** * Resolve the given type from the container. * * @param string $abstract * @param array $parameters * @return mixed * @static */ public static function make($abstract, $parameters = array()) { return \Laravel\Lumen\Application::make($abstract, $parameters); }
/** * Assert that the form errors are bound to the View. * * @return bool */ public function seeFormHasErrors() { $viewErrorBag = $this->app->make('view')->shared('errors'); $this->assertTrue(count($viewErrorBag) > 0); }
<?php // Pandora listens for messages from pianod tcp 4445 // and sends the information to the db and websocket 8081 require __DIR__ . '/vendor/autoload.php'; Dotenv::load(__DIR__); use Laravel\Lumen\Application; $loop = React\EventLoop\Factory::create(); $app = new Application(realpath(__DIR__)); $pusher = $app->make("App\\Volumio\\WebSockets\\Pusher"); $client = stream_socket_client('tcp://127.0.0.1:4445'); stream_set_timeout($client, 0, 100000); stream_set_blocking($client, 0); $loop->addReadStream($client, function ($client) use($loop, $pusher) { $message = ""; while (true) { $response = fgets($client); $message .= $response; if (!$response) { break; } } $pusher->onReceiveMessage($message); }); // Set up our WebSocket server for clients wanting real-time updates $webSock = new React\Socket\Server($loop); $webSock->listen(8081, '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();
/** * Setup the tests. */ public function setUp() { parent::setUp(); $this->app = $this->createApplication(); $this->url = $this->app->make('url'); }