* Helper method to handle connection errors.
*
* @param string $message Error message.
* @param int $code Error code.
*/
protected function onConnectionError($message, $code = null)
{
CommunicationException::handle(new ConnectionException($this, "$message [{$this->parameters->scheme}://{$this->getIdentifier()}]", $code));
}
$flags |= STREAM_CLIENT_PERSISTENT;
$uri .= strpos($path = $parameters->path, '/') === 0 ? $path : "/$path";
}
$resource = @stream_socket_client($uri, $errno, $errstr, $parameters->timeout, $flags);
if (!$resource) {
$this->onConnectionError(trim($errstr), $errno);
}
* {@inheritdoc}
*/
protected function createResource()
{
$parameters = $this->parameters;
$initializer = "{$parameters->scheme}StreamInitializer";
return $this->$initializer($parameters);
}
*/
public function connect()
{
if ($this->isConnected()) {
throw new ClientException('Connection already estabilished');
}
$this->resource = $this->createResource();
}
}
/**
* {@inheritdoc}
*/
public function connect()
{
parent::connect();
if ($this->initCmds) {
*/
public function getResource()
{
if (isset($this->resource)) {
return $this->resource;
}
$this->connect();
return $this->resource;
* Performs a write operation on the stream of the buffer containing a
* command serialized with the Redis wire protocol.
*
* @param string $buffer Redis wire protocol representation of a command.
*/
protected function writeBytes($buffer)
{
$socket = $this->getResource();
while (($length = strlen($buffer)) > 0) {
for ($i = 0, $reqlen--; $i < $reqlen; $i++) {
$argument = $arguments[$i];
$arglen = strlen($argument);
$buffer .= "\${$arglen}\r\n{$argument}\r\n";
}
$this->writeBytes($buffer);
}
}
/**
* {@inheritdoc}
*/
public function executeCommand(CommandInterface $command)
{
$this->writeCommand($command);
return $this->readResponse($command);
}
/**
* {@inheritdoc}
*/
public function executeCommand(CommandInterface $command)
{
$response = $this->connection->executeCommand($command);
if ($response instanceof ResponseObjectInterface) {
* @param string $commandID Command ID.
* @param array $arguments Arguments for the command.
* @return mixed
*/
public function __call($commandID, $arguments)
{
$command = $this->createCommand($commandID, $arguments);
$response = $this->executeCommand($command);
return $response;
* Retrieve an item from the cache by key.
*
* @param string $key
* @return mixed
*/
public function get($key)
{
if ( ! is_null($value = $this->connection()->get($this->prefix.$key)))
{
return is_numeric($value) ? $value : unserialize($value);
*
* @param string $key
* @param mixed $default
* @return mixed
*/
public function get($key, $default = null)
{
$value = $this->store->get($key);
return ! is_null($value) ? $value : value($default);
}
/**
* {@inheritDoc}
*/
public function read($sessionId)
{
return $this->cache->get($sessionId, '');
}
/**
* Read the session data from the handler.
*
* @return array
*/
protected function readFromHandler()
{
$data = $this->handler->read($this->getId());
return $data ? unserialize($data) : array();
/**
* Load the session data from the handler.
*
* @return void
*/
protected function loadSession()
{
$this->attributes = $this->readFromHandler();
foreach (array_merge($this->bags, array($this->metaBag)) as $bag)
}
/**
* {@inheritdoc}
*/
public function start()
{
$this->loadSession();
if ( ! $this->has('_token')) $this->regenerateToken();
* @param \Symfony\Component\HttpFoundation\Request $request
* @return \Illuminate\Session\SessionInterface
*/
protected function startSession(Request $request)
{
with($session = $this->getSession($request))->setRequestOnHandler($request);
$session->start();
return $session;
$this->checkRequestForArraySessions($request);
// If a session driver has been configured, we will need to start the session here
// so that the data is ready for an application. Note that the Laravel sessions
// do not make use of PHP "native" sessions in any way since they are crappy.
if ($this->sessionConfigured())
{
$session = $this->startSession($request);
$request->setSession($session);
* @param \Symfony\Component\HttpFoundation\Request $request
* @param int $type
* @param bool $catch
* @return \Symfony\Component\HttpFoundation\Response
*/
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
$response = $this->app->handle($request, $type, $catch);
foreach ($this->cookies->getQueuedCookies() as $cookie)
* @param \Symfony\Component\HttpFoundation\Request $request
* @param int $type
* @param bool $catch
* @return \Symfony\Component\HttpFoundation\Response
*/
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
return $this->encrypt($this->app->handle($this->decrypt($request), $type, $catch));
}
{
$this->app = $app;
$this->middlewares = $middlewares;
}
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
return $this->app->handle($request, $type, $catch);
}
* @param \Symfony\Component\HttpFoundation\Request $request
* @return void
*/
public function run(SymfonyRequest $request = null)
{
$request = $request ?: $this['request'];
$response = with($stack = $this->getStackedClient())->handle($request);
$response->send();
| Once we have the application, we can simply call the run method,
| which will execute the request and send the response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have whipped up for them.
|
*/
$app->run();