*/
public function createConnection($dsn, array $config, array $options)
{
$username = array_get($config, 'username');
$password = array_get($config, 'password');
return new PDO($dsn, $username, $password, $options);
}
<?php namespace Illuminate\Database\Connectors;
use PDO;
class Connector {
/**
* The default PDO connection options.
*
* @var array
*/
public function createConnection($dsn, array $config, array $options)
{
$username = array_get($config, 'username');
$password = array_get($config, 'password');
return new PDO($dsn, $username, $password, $options);
}
*/
public function createConnection($dsn, array $config, array $options)
{
$username = array_get($config, 'username');
$password = array_get($config, 'password');
return new PDO($dsn, $username, $password, $options);
}
$dsn = $this->getDsn($config);
$options = $this->getOptions($config);
// We need to grab the PDO options that should be used while making the brand
// new connection instance. The PDO options control various aspects of the
// connection's behavior, and some might be specified by the developers.
$connection = $this->createConnection($dsn, $config, $options);
if (isset($config['unix_socket']))
if (isset($config['read'])) {
return $this->createReadWriteConnection($config);
}
return $this->createSingleConnection($config);
}
protected function createSingleConnection(array $config)
{
$pdo = $this->createConnector($config)->connect($config);
return $this->createConnection($config['driver'], $pdo, $config['database'], $config['prefix'], $config);
}
}
public function make(array $config, $name = null)
{
$config = $this->parseConfig($config, $name);
if (isset($config['read'])) {
return $this->createReadWriteConnection($config);
}
return $this->createSingleConnection($config);
}
protected function createSingleConnection(array $config)
if (isset($this->extensions[$name])) {
return call_user_func($this->extensions[$name], $config, $name);
}
$driver = $config['driver'];
if (isset($this->extensions[$driver])) {
return call_user_func($this->extensions[$driver], $config, $name);
}
return $this->factory->make($config, $name);
}
protected function prepare(Connection $connection)
$this->app = $app;
$this->factory = $factory;
}
public function connection($name = null)
{
list($name, $type) = $this->parseConnectionName($name);
if (!isset($this->connections[$name])) {
$connection = $this->makeConnection($name);
$this->setPdoForType($connection, $type);
$this->connections[$name] = $this->prepare($connection);
public function setConnection($name)
{
$this->connection = $name;
return $this;
}
public static function resolveConnection($connection = null)
{
return static::$resolver->connection($connection);
}
public static function getConnectionResolver()
public function setRelations(array $relations)
{
$this->relations = $relations;
return $this;
}
public function getConnection()
{
return static::resolveConnection($this->connection);
}
public function getConnectionName()
}
public function newEloquentBuilder($query)
{
return new Builder($query);
}
protected function newBaseQueryBuilder()
{
$conn = $this->getConnection();
$grammar = $conn->getQueryGrammar();
return new QueryBuilder($conn, $grammar, $conn->getPostProcessor());
public function newQueryWithoutScope($scope)
{
$this->getGlobalScope($scope)->remove($builder = $this->newQuery(), $this);
return $builder;
}
public function newQueryWithoutScopes()
{
$builder = $this->newEloquentBuilder($this->newBaseQueryBuilder());
return $builder->setModel($this)->with($this->with);
}
}
public function freshTimestampString()
{
return $this->fromDateTime($this->freshTimestamp());
}
public function newQuery()
{
$builder = $this->newQueryWithoutScopes();
return $this->applyGlobalScopes($builder);
}
}
public static function with($relations)
{
if (is_string($relations)) {
$relations = func_get_args();
}
$instance = new static();
return $instance->newQuery()->with($relations);
}
public function hasOne($related, $foreignKey = null, $localKey = null)
* Load global settings
*/
// create global settings singleton
App::singleton('globals', function(){
$globals = Cache::tags('global')->get('global_settings');
if (!$globals){
$globals = Settings::with('localization')
->with('businessConditions')
->with('phones')
protected function missingLeadingSlash($abstract)
{
return is_string($abstract) && strpos($abstract, '\\') !== 0;
}
public function build($concrete, $parameters = array())
{
if ($concrete instanceof Closure) {
return $concrete($this, $parameters);
}
$reflector = new ReflectionClass($concrete);
{
$abstract = $this->getAlias($abstract);
if (isset($this->instances[$abstract])) {
return $this->instances[$abstract];
}
$concrete = $this->getConcrete($abstract);
if ($this->isBuildable($concrete, $abstract)) {
$object = $this->build($concrete, $parameters);
} else {
$object = $this->make($concrete, $parameters);
}
public function make($abstract, $parameters = array())
{
$abstract = $this->getAlias($abstract);
if (isset($this->deferredServices[$abstract])) {
$this->loadDeferredProvider($abstract);
}
return parent::make($abstract, $parameters);
}
public function bound($abstract)
* @param string $make
* @return mixed
*/
function app($make = null)
{
if ( ! is_null($make))
{
return app()->make($make);
}
->find(1);
Cache::tags('global')->put('global_settings',$globals,1);
}
return $globals;
});
// share through views
View::share('globals', app('globals'));
/**
{
$responses = array();
if (!is_array($payload)) {
$payload = array($payload);
}
$this->firing[] = $event;
foreach ($this->getListeners($event) as $listener) {
$response = call_user_func_array($listener, $payload);
if (!is_null($response) && $halt) {
array_pop($this->firing);
if (is_string($subscriber)) {
return $this->container->make($subscriber);
}
return $subscriber;
}
public function until($event, $payload = array())
{
return $this->fire($event, $payload, true);
}
public function flush($event)
}
}
protected function callFilter($filter, $request, $response = null)
{
if (!$this->filtering) {
return null;
}
return $this->events->until('router.' . $filter, array($request, $response));
}
public function callRouteBefore($route, $request)
{
$group = last($this->groupStack);
return isset($group['namespace']) ? $group['namespace'] . '\\' . $uses : $uses;
}
public function dispatch(Request $request)
{
$this->currentRequest = $request;
$response = $this->callFilter('before', $request);
if (is_null($response)) {
$response = $this->dispatchToRoute($request);
if (!is_null($response)) {
return $this->prepareResponse($response, $request);
}
}
if ($this->runningUnitTests() && !$this['session']->isStarted()) {
$this['session']->start();
}
return $this['router']->dispatch($this->prepareRequest($request));
}
public function terminate(SymfonyRequest $request, SymfonyResponse $response)
});
}
public function handle(SymfonyRequest $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
try {
$this->refreshRequest($request = Request::createFromBase($request));
$this->boot();
return $this->dispatch($request);
} catch (\Exception $e) {
if (!$catch || $this->runningUnitTests()) {
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
$this->checkRequestForArraySessions($request);
if ($this->sessionConfigured()) {
$session = $this->startSession($request);
$request->setSession($session);
}
$response = $this->app->handle($request, $type, $catch);
if ($this->sessionConfigured()) {
$this->closeSession($session);
public function __construct(HttpKernelInterface $app, CookieJar $cookies)
{
$this->app = $app;
$this->cookies = $cookies;
}
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
$response = $this->app->handle($request, $type, $catch);
foreach ($this->cookies->getQueuedCookies() as $cookie) {
$response->headers->setCookie($cookie);
public function __construct(HttpKernelInterface $app, Encrypter $encrypter)
{
$this->app = $app;
$this->encrypter = $encrypter;
}
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
return $this->encrypt($this->app->handle($this->decrypt($request), $type, $catch));
}
protected function decrypt(Request $request)
public function __construct(HttpKernelInterface $app, array $middlewares)
{
$this->app = $app;
$this->middlewares = $middlewares;
}
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
return $this->app->handle($request, $type, $catch);
}
public function terminate(Request $request, Response $response)
if ($this->isBooted()) {
$this->fireAppCallbacks(array($callback));
}
}
public function run(SymfonyRequest $request = null)
{
$request = $request ?: $this['request'];
$response = with($stack = $this->getStackedClient())->handle($request);
$response->send();
$stack->terminate($request, $response);
| 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();