Application.php 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655
  1. <?php namespace Laravel\Lumen;
  2. use Closure;
  3. use Exception;
  4. use ErrorException;
  5. use Monolog\Logger;
  6. use FastRoute\Dispatcher;
  7. use Illuminate\Http\Request;
  8. use Illuminate\Http\Response;
  9. use Illuminate\Pipeline\Pipeline;
  10. use Monolog\Handler\StreamHandler;
  11. use Illuminate\Container\Container;
  12. use Illuminate\Foundation\Composer;
  13. use Monolog\Formatter\LineFormatter;
  14. use Illuminate\Filesystem\Filesystem;
  15. use Illuminate\Support\Facades\Facade;
  16. use Illuminate\Support\ServiceProvider;
  17. use Symfony\Component\Console\Output\ConsoleOutput;
  18. use Illuminate\Http\Exception\HttpResponseException;
  19. use Illuminate\Config\Repository as ConfigRepository;
  20. use Symfony\Component\HttpKernel\HttpKernelInterface;
  21. use Illuminate\Contracts\Routing\TerminableMiddleware;
  22. use Symfony\Component\HttpFoundation\BinaryFileResponse;
  23. use Symfony\Component\HttpKernel\Exception\HttpException;
  24. use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
  25. use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
  26. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  27. use Illuminate\Contracts\Foundation\Application as ApplicationContract;
  28. use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
  29. class Application extends Container implements ApplicationContract, HttpKernelInterface
  30. {
  31. /**
  32. * Indicates if the class aliases have been registered.
  33. *
  34. * @var bool
  35. */
  36. protected static $aliasesRegistered = false;
  37. /**
  38. * The base path of the application installation.
  39. *
  40. * @var string
  41. */
  42. protected $basePath;
  43. /**
  44. * The storage path of the application installation.
  45. *
  46. * @var string
  47. */
  48. protected $storagePath;
  49. /**
  50. * The configuration path of the application installation.
  51. *
  52. * @var string
  53. */
  54. protected $configPath;
  55. /**
  56. * The resource path of the application installation.
  57. *
  58. * @var string
  59. */
  60. protected $resourcePath;
  61. /**
  62. * All of the loaded configuration files.
  63. *
  64. * @var array
  65. */
  66. protected $loadedConfigurations = [];
  67. /**
  68. * All of the routes waiting to be registered.
  69. *
  70. * @var array
  71. */
  72. protected $routes = [];
  73. /**
  74. * All of the named routes and URI pairs.
  75. *
  76. * @var array
  77. */
  78. public $namedRoutes = [];
  79. /**
  80. * The shared attributes for the current route group.
  81. *
  82. * @var array|null
  83. */
  84. protected $groupAttributes;
  85. /**
  86. * All of the global middleware for the application.
  87. *
  88. * @var array
  89. */
  90. protected $middleware = [];
  91. /**
  92. * All of the route specific middleware short-hands.
  93. *
  94. * @var array
  95. */
  96. protected $routeMiddleware = [];
  97. /**
  98. * The current route being dispatched.
  99. *
  100. * @var array
  101. */
  102. protected $currentRoute;
  103. /**
  104. * The loaded service providers.
  105. *
  106. * @var array
  107. */
  108. protected $loadedProviders = [];
  109. /**
  110. * The service binding methods that have been executed.
  111. *
  112. * @var array
  113. */
  114. protected $ranServiceBinders = [];
  115. /**
  116. * The FastRoute dispatcher.
  117. *
  118. * @var \FastRoute\Dispatcher
  119. */
  120. protected $dispatcher;
  121. /**
  122. * Create a new Lumen application instance.
  123. *
  124. * @param string|null $basePath
  125. * @return void
  126. */
  127. public function __construct($basePath = null)
  128. {
  129. date_default_timezone_set(env('APP_TIMEZONE', 'UTC'));
  130. $this->basePath = $basePath;
  131. $this->bootstrapContainer();
  132. $this->registerErrorHandling();
  133. }
  134. /**
  135. * Bootstrap the application container.
  136. *
  137. * @return void
  138. */
  139. protected function bootstrapContainer()
  140. {
  141. static::setInstance($this);
  142. $this->instance('app', $this);
  143. $this->registerContainerAliases();
  144. }
  145. /**
  146. * Get the version number of the application.
  147. *
  148. * @return string
  149. */
  150. public function version()
  151. {
  152. return 'Lumen (5.0.10) (Laravel Components 5.0.*)';
  153. }
  154. /**
  155. * Get or check the current application environment.
  156. *
  157. * @param mixed
  158. * @return string
  159. */
  160. public function environment()
  161. {
  162. return env('APP_ENV', 'production');
  163. }
  164. /**
  165. * Determine if the application is currently down for maintenance.
  166. *
  167. * @return bool
  168. */
  169. public function isDownForMaintenance()
  170. {
  171. return false;
  172. }
  173. /**
  174. * Register all of the configured providers.
  175. *
  176. * @return void
  177. */
  178. public function registerConfiguredProviders()
  179. {
  180. //
  181. }
  182. /**
  183. * Register a service provider with the application.
  184. *
  185. * @param \Illuminate\Support\ServiceProvider|string $provider
  186. * @param array $options
  187. * @param bool $force
  188. * @return \Illuminate\Support\ServiceProvider
  189. */
  190. public function register($provider, $options = array(), $force = false)
  191. {
  192. if (!$provider instanceof ServiceProvider) {
  193. $provider = new $provider($this);
  194. }
  195. if (array_key_exists($providerName = get_class($provider), $this->loadedProviders)) {
  196. return;
  197. }
  198. $this->loadedProviders[$providerName] = true;
  199. $provider->register();
  200. $provider->boot();
  201. }
  202. /**
  203. * Register a deferred provider and service.
  204. *
  205. * @param string $provider
  206. * @param string $service
  207. * @return void
  208. */
  209. public function registerDeferredProvider($provider, $service = null)
  210. {
  211. return $this->register($provider);
  212. }
  213. /**
  214. * Boot the application's service providers.
  215. *
  216. * @return void
  217. */
  218. public function boot()
  219. {
  220. //
  221. }
  222. /**
  223. * Register a new boot listener.
  224. *
  225. * @param mixed $callback
  226. * @return void
  227. */
  228. public function booting($callback)
  229. {
  230. //
  231. }
  232. /**
  233. * Register a new "booted" listener.
  234. *
  235. * @param mixed $callback
  236. * @return void
  237. */
  238. public function booted($callback)
  239. {
  240. //
  241. }
  242. /**
  243. * Set the error handling for the application.
  244. *
  245. * @return void
  246. */
  247. protected function registerErrorHandling()
  248. {
  249. error_reporting(-1);
  250. set_error_handler(function ($level, $message, $file = '', $line = 0) {
  251. if (error_reporting() & $level) {
  252. throw new ErrorException($message, 0, $level, $file, $line);
  253. }
  254. });
  255. set_exception_handler(function ($e) {
  256. $this->handleUncaughtException($e);
  257. });
  258. }
  259. /**
  260. * Send the exception to the handler and retunr the response.
  261. *
  262. * @param Exception $e
  263. * @return Response
  264. */
  265. protected function sendExceptionToHandler($e)
  266. {
  267. $handler = $this->make('Illuminate\Contracts\Debug\ExceptionHandler');
  268. $handler->report($e);
  269. return $handler->render($this->make('request'), $e);
  270. }
  271. /**
  272. * Handle an uncaught exception instance.
  273. *
  274. * @param Exception $e
  275. * @return void
  276. */
  277. protected function handleUncaughtException($e)
  278. {
  279. $handler = $this->make('Illuminate\Contracts\Debug\ExceptionHandler');
  280. $handler->report($e);
  281. if ($this->runningInConsole()) {
  282. $handler->renderForConsole(new ConsoleOutput, $e);
  283. } else {
  284. $handler->render($this->make('request'), $e)->send();
  285. }
  286. }
  287. /**
  288. * Throw an HttpException with the given data.
  289. *
  290. * @param int $code
  291. * @param string $message
  292. * @param array $headers
  293. * @return void
  294. *
  295. * @throws \Symfony\Component\HttpKernel\Exception\HttpException
  296. */
  297. public function abort($code, $message = '', array $headers = array())
  298. {
  299. if ($code == 404) {
  300. throw new NotFoundHttpException($message);
  301. }
  302. throw new HttpException($code, $message, null, $headers);
  303. }
  304. /**
  305. * Resolve the given type from the container.
  306. *
  307. * @param string $abstract
  308. * @param array $parameters
  309. * @return mixed
  310. */
  311. public function make($abstract, $parameters = [])
  312. {
  313. if (array_key_exists($abstract, $this->availableBindings) &&
  314. ! array_key_exists($this->availableBindings[$abstract], $this->ranServiceBinders)) {
  315. $this->{$method = $this->availableBindings[$abstract]}();
  316. $this->ranServiceBinders[$method] = true;
  317. }
  318. return parent::make($abstract, $parameters);
  319. }
  320. /**
  321. * Register container bindings for the application.
  322. *
  323. * @return void
  324. */
  325. protected function registerAuthBindings()
  326. {
  327. $this->singleton('auth', function () {
  328. return $this->loadComponent('auth', 'Illuminate\Auth\AuthServiceProvider', 'auth');
  329. });
  330. $this->singleton('auth.driver', function () {
  331. return $this->loadComponent('auth', 'Illuminate\Auth\AuthServiceProvider', 'auth.driver');
  332. });
  333. $this->singleton('auth.password', function () {
  334. return $this->loadComponent('auth', 'Illuminate\Auth\Passwords\PasswordResetServiceProvider', 'auth.password');
  335. });
  336. }
  337. /**
  338. * Register container bindings for the application.
  339. *
  340. * @return void
  341. */
  342. protected function registerBusBindings()
  343. {
  344. $this->singleton('Illuminate\Contracts\Bus\Dispatcher', function () {
  345. $this->register('Illuminate\Bus\BusServiceProvider');
  346. return $this->make('Illuminate\Contracts\Bus\Dispatcher');
  347. });
  348. }
  349. /**
  350. * Register container bindings for the application.
  351. *
  352. * @return void
  353. */
  354. protected function registerCacheBindings()
  355. {
  356. $this->singleton('cache', function () {
  357. return $this->loadComponent('cache', 'Illuminate\Cache\CacheServiceProvider');
  358. });
  359. }
  360. /**
  361. * Register container bindings for the application.
  362. *
  363. * @return void
  364. */
  365. protected function registerConfigBindings()
  366. {
  367. $this->singleton('config', function () {
  368. return new ConfigRepository;
  369. });
  370. }
  371. /**
  372. * Register container bindings for the application.
  373. *
  374. * @return void
  375. */
  376. protected function registerComposerBindings()
  377. {
  378. $this->app->singleton('composer', function ($app) {
  379. return new Composer($app->make('files'), $this->basePath());
  380. });
  381. }
  382. /**
  383. * Register container bindings for the application.
  384. *
  385. * @return void
  386. */
  387. protected function registerCookieBindings()
  388. {
  389. $this->singleton('cookie', function () {
  390. return $this->loadComponent('session', 'Illuminate\Cookie\CookieServiceProvider', 'cookie');
  391. });
  392. }
  393. /**
  394. * Register container bindings for the application.
  395. *
  396. * @return void
  397. */
  398. protected function registerDatabaseBindings()
  399. {
  400. $this->singleton('db', function () {
  401. return $this->loadComponent(
  402. 'database', [
  403. 'Illuminate\Database\DatabaseServiceProvider',
  404. 'Illuminate\Pagination\PaginationServiceProvider'],
  405. 'db'
  406. );
  407. });
  408. }
  409. /**
  410. * Register container bindings for the application.
  411. *
  412. * @return void
  413. */
  414. protected function registerEncrypterBindings()
  415. {
  416. $this->singleton('encrypter', function () {
  417. return $this->loadComponent('app', 'Illuminate\Encryption\EncryptionServiceProvider', 'encrypter');
  418. });
  419. }
  420. /**
  421. * Register container bindings for the application.
  422. *
  423. * @return void
  424. */
  425. protected function registerEventBindings()
  426. {
  427. $this->singleton('events', function () {
  428. $this->register('Illuminate\Events\EventServiceProvider');
  429. return $this->make('events');
  430. });
  431. }
  432. /**
  433. * Register container bindings for the application.
  434. *
  435. * @return void
  436. */
  437. protected function registerErrorBindings()
  438. {
  439. if (! $this->bound('Illuminate\Contracts\Debug\ExceptionHandler')) {
  440. $this->singleton(
  441. 'Illuminate\Contracts\Debug\ExceptionHandler', 'Laravel\Lumen\Exceptions\Handler'
  442. );
  443. }
  444. }
  445. /**
  446. * Register container bindings for the application.
  447. *
  448. * @return void
  449. */
  450. protected function registerFilesBindings()
  451. {
  452. $this->singleton('files', function () {
  453. return new Filesystem;
  454. });
  455. $this->singleton('filesystem', function () {
  456. return $this->loadComponent('filesystems', 'Illuminate\Filesystem\FilesystemServiceProvider', 'filesystem');
  457. });
  458. }
  459. /**
  460. * Register container bindings for the application.
  461. *
  462. * @return void
  463. */
  464. protected function registerHashBindings()
  465. {
  466. $this->singleton('hash', function () {
  467. $this->register('Illuminate\Hashing\HashServiceProvider');
  468. return $this->make('hash');
  469. });
  470. }
  471. /**
  472. * Register container bindings for the application.
  473. *
  474. * @return void
  475. */
  476. protected function registerLogBindings()
  477. {
  478. $this->singleton('Psr\Log\LoggerInterface', function () {
  479. return new Logger('lumen', [$this->getMonologHandler()]);
  480. });
  481. }
  482. /**
  483. * Get the Monolog handler for the application.
  484. *
  485. * @return \Monolog\Handler\AbstractHandler
  486. */
  487. protected function getMonologHandler()
  488. {
  489. return (new StreamHandler(getcwd().'/vendor/laravel/lumen-framework/storage/logs/lumen.log', Logger::DEBUG))
  490. ->setFormatter(new LineFormatter(null, null, true, true));
  491. }
  492. /**
  493. * Register container bindings for the application.
  494. *
  495. * @return void
  496. */
  497. protected function registerMailBindings()
  498. {
  499. $this->singleton('mailer', function () {
  500. $this->configure('services');
  501. return $this->loadComponent('mail', 'Illuminate\Mail\MailServiceProvider', 'mailer');
  502. });
  503. }
  504. /**
  505. * Register container bindings for the application.
  506. *
  507. * @return void
  508. */
  509. protected function registerQueueBindings()
  510. {
  511. $this->singleton('queue', function () {
  512. return $this->loadComponent('queue', 'Illuminate\Queue\QueueServiceProvider', 'queue');
  513. });
  514. $this->singleton('queue.connection', function () {
  515. return $this->loadComponent('queue', 'Illuminate\Queue\QueueServiceProvider', 'queue.connection');
  516. });
  517. }
  518. /**
  519. * Register container bindings for the application.
  520. *
  521. * @return void
  522. */
  523. protected function registerRedisBindings()
  524. {
  525. $this->singleton('redis', function() {
  526. return $this->loadComponent('database', 'Illuminate\Redis\RedisServiceProvider', 'redis');
  527. });
  528. }
  529. /**
  530. * Register container bindings for the application.
  531. *
  532. * @return void
  533. */
  534. protected function registerRequestBindings()
  535. {
  536. $this->singleton('Illuminate\Http\Request', function () {
  537. return Request::capture()->setUserResolver(function () {
  538. return $this->make('auth')->user();
  539. })->setRouteResolver(function () {
  540. return $this->currentRoute;
  541. });
  542. });
  543. }
  544. /**
  545. * Register container bindings for the application.
  546. *
  547. * @return void
  548. */
  549. protected function registerSessionBindings()
  550. {
  551. $this->singleton('session', function () {
  552. return $this->loadComponent('session', 'Illuminate\Session\SessionServiceProvider');
  553. });
  554. $this->singleton('session.store', function () {
  555. return $this->loadComponent('session', 'Illuminate\Session\SessionServiceProvider', 'session.store');
  556. });
  557. }
  558. /**
  559. * Register container bindings for the application.
  560. *
  561. * @return void
  562. */
  563. protected function registerTranslationBindings()
  564. {
  565. $this->singleton('translator', function () {
  566. $this->configure('app');
  567. $this->instance('path.lang', $this->getLanguagePath());
  568. $this->register('Illuminate\Translation\TranslationServiceProvider');
  569. return $this->make('translator');
  570. });
  571. }
  572. /**
  573. * Get the path to the application's language files.
  574. *
  575. * @return string
  576. */
  577. protected function getLanguagePath()
  578. {
  579. if (is_dir($appPath = $this->resourcePath('lang'))) {
  580. return $appPath;
  581. } else {
  582. return __DIR__.'/../lang';
  583. }
  584. }
  585. /**
  586. * Register container bindings for the application.
  587. *
  588. * @return void
  589. */
  590. protected function registerUrlGeneratorBindings()
  591. {
  592. $this->singleton('url', function () {
  593. return new Routing\UrlGenerator($this);
  594. });
  595. }
  596. /**
  597. * Register container bindings for the application.
  598. *
  599. * @return void
  600. */
  601. protected function registerValidatorBindings()
  602. {
  603. $this->singleton('validator', function () {
  604. $this->register('Illuminate\Validation\ValidationServiceProvider');
  605. return $this->make('validator');
  606. });
  607. }
  608. /**
  609. * Register container bindings for the application.
  610. *
  611. * @return void
  612. */
  613. protected function registerViewBindings()
  614. {
  615. $this->singleton('view', function () {
  616. return $this->loadComponent('view', 'Illuminate\View\ViewServiceProvider');
  617. });
  618. }
  619. /**
  620. * Configure and load the given component and provider.
  621. *
  622. * @param string $config
  623. * @param array|string $providers
  624. * @param string|null $return
  625. * @return mixed
  626. */
  627. protected function loadComponent($config, $providers, $return = null)
  628. {
  629. $this->configure($config);
  630. foreach ((array) $providers as $provider) {
  631. $this->register($provider);
  632. }
  633. return $this->make($return ?: $config);
  634. }
  635. /**
  636. * Load a configuration file into the application.
  637. *
  638. * @return void
  639. */
  640. public function configure($name)
  641. {
  642. if (isset($this->loadedConfigurations[$name])) {
  643. return;
  644. }
  645. $this->loadedConfigurations[$name] = true;
  646. $path = $this->getConfigurationPath($name);
  647. if ($path) {
  648. $this->make('config')->set($name, require $path);
  649. }
  650. }
  651. /**
  652. * Get the path to the given configuration file.
  653. *
  654. * @param string $name
  655. * @return string
  656. */
  657. protected function getConfigurationPath($name)
  658. {
  659. $appConfigPath = ($this->configPath ?: $this->basePath('config')).'/'.$name.'.php';
  660. if (file_exists($appConfigPath)) {
  661. return $appConfigPath;
  662. } elseif (file_exists($path = __DIR__.'/../config/'.$name.'.php')) {
  663. return $path;
  664. }
  665. }
  666. /**
  667. * Register the facades for the application.
  668. *
  669. * @return void
  670. */
  671. public function withFacades()
  672. {
  673. Facade::setFacadeApplication($this);
  674. if (! static::$aliasesRegistered) {
  675. static::$aliasesRegistered = true;
  676. class_alias('Illuminate\Support\Facades\App', 'App');
  677. class_alias('Illuminate\Support\Facades\Auth', 'Auth');
  678. class_alias('Illuminate\Support\Facades\Bus', 'Bus');
  679. class_alias('Illuminate\Support\Facades\DB', 'DB');
  680. class_alias('Illuminate\Support\Facades\Cache', 'Cache');
  681. class_alias('Illuminate\Support\Facades\Cookie', 'Cookie');
  682. class_alias('Illuminate\Support\Facades\Crypt', 'Crypt');
  683. class_alias('Illuminate\Support\Facades\Event', 'Event');
  684. class_alias('Illuminate\Support\Facades\Hash', 'Hash');
  685. class_alias('Illuminate\Support\Facades\Log', 'Log');
  686. class_alias('Illuminate\Support\Facades\Mail', 'Mail');
  687. class_alias('Illuminate\Support\Facades\Queue', 'Queue');
  688. class_alias('Illuminate\Support\Facades\Request', 'Request');
  689. class_alias('Illuminate\Support\Facades\Schema', 'Schema');
  690. class_alias('Illuminate\Support\Facades\Session', 'Session');
  691. class_alias('Illuminate\Support\Facades\Storage', 'Storage');
  692. class_alias('Illuminate\Support\Facades\Validator', 'Validator');
  693. }
  694. }
  695. /**
  696. * Load the Eloquent library for the application.
  697. *
  698. * @return void
  699. */
  700. public function withEloquent()
  701. {
  702. $this->make('db');
  703. }
  704. /**
  705. * Register a set of routes with a set of shared attributes.
  706. *
  707. * @param array $attributes
  708. * @param Closure $callback
  709. * @return void
  710. */
  711. public function group(array $attributes, Closure $callback)
  712. {
  713. $this->groupAttributes = $attributes;
  714. call_user_func($callback, $this);
  715. $this->groupAttributes = null;
  716. }
  717. /**
  718. * Register a route with the application.
  719. *
  720. * @param string $uri
  721. * @param mixed $action
  722. * @return $this
  723. */
  724. public function get($uri, $action)
  725. {
  726. $this->addRoute('GET', $uri, $action);
  727. return $this;
  728. }
  729. /**
  730. * Register a route with the application.
  731. *
  732. * @param string $uri
  733. * @param mixed $action
  734. * @return $this
  735. */
  736. public function post($uri, $action)
  737. {
  738. $this->addRoute('POST', $uri, $action);
  739. return $this;
  740. }
  741. /**
  742. * Register a route with the application.
  743. *
  744. * @param string $uri
  745. * @param mixed $action
  746. * @return $this
  747. */
  748. public function put($uri, $action)
  749. {
  750. $this->addRoute('PUT', $uri, $action);
  751. return $this;
  752. }
  753. /**
  754. * Register a route with the application.
  755. *
  756. * @param string $uri
  757. * @param mixed $action
  758. * @return $this
  759. */
  760. public function patch($uri, $action)
  761. {
  762. $this->addRoute('PATCH', $uri, $action);
  763. return $this;
  764. }
  765. /**
  766. * Register a route with the application.
  767. *
  768. * @param string $uri
  769. * @param mixed $action
  770. * @return $this
  771. */
  772. public function delete($uri, $action)
  773. {
  774. $this->addRoute('DELETE', $uri, $action);
  775. return $this;
  776. }
  777. /**
  778. * Register a route with the application.
  779. *
  780. * @param string $uri
  781. * @param mixed $action
  782. * @return $this
  783. */
  784. public function options($uri, $action)
  785. {
  786. $this->addRoute('OPTIONS', $uri, $action);
  787. return $this;
  788. }
  789. /**
  790. * Add a route to the collection.
  791. *
  792. * @param string $method
  793. * @param string $uri
  794. * @param mixed $action
  795. */
  796. protected function addRoute($method, $uri, $action)
  797. {
  798. $action = $this->parseAction($action);
  799. $uri = $uri === '/' ? $uri : '/'.trim($uri, '/');
  800. if (isset($this->groupAttributes)) {
  801. if (isset($this->groupAttributes['prefix'])) {
  802. $uri = rtrim('/'.trim($this->groupAttributes['prefix'], '/').$uri, '/');
  803. }
  804. $action = $this->mergeGroupAttributes($action);
  805. }
  806. if (isset($action['as'])) {
  807. $this->namedRoutes[$action['as']] = $uri;
  808. }
  809. $this->routes[$method.$uri] = ['method' => $method, 'uri' => $uri, 'action' => $action];
  810. }
  811. /**
  812. * Parse the action into an array format.
  813. *
  814. * @param mixed $action
  815. * @return array
  816. */
  817. protected function parseAction($action)
  818. {
  819. if (is_string($action)) {
  820. return ['uses' => $action];
  821. } elseif (! is_array($action)) {
  822. return [$action];
  823. }
  824. return $action;
  825. }
  826. /**
  827. * Merge the group attributes into the action.
  828. *
  829. * @param array $action
  830. * @return array
  831. */
  832. protected function mergeGroupAttributes(array $action)
  833. {
  834. return $this->mergeNamespaceGroup(
  835. $this->mergeMiddlewareGroup($action)
  836. );
  837. }
  838. /**
  839. * Merge the namespace group into the action.
  840. *
  841. * @param array $action
  842. * @return array
  843. */
  844. protected function mergeNamespaceGroup(array $action)
  845. {
  846. if (isset($this->groupAttributes['namespace']) && isset($action['uses'])) {
  847. $action['uses'] = $this->groupAttributes['namespace'].'\\'.$action['uses'];
  848. }
  849. return $action;
  850. }
  851. /**
  852. * Merge the middleware group into the action.
  853. *
  854. * @param array $action
  855. * @return array
  856. */
  857. protected function mergeMiddlewareGroup($action)
  858. {
  859. if (isset($this->groupAttributes['middleware'])) {
  860. if (isset($action['middleware'])) {
  861. $action['middleware'] .= '|'.$this->groupAttributes['middleware'];
  862. } else {
  863. $action['middleware'] = $this->groupAttributes['middleware'];
  864. }
  865. }
  866. return $action;
  867. }
  868. /**
  869. * Add new middleware to the application.
  870. *
  871. * @param array $middleware
  872. * @return $this
  873. */
  874. public function middleware(array $middleware)
  875. {
  876. $this->middleware = array_unique(array_merge($this->middleware, $middleware));
  877. return $this;
  878. }
  879. /**
  880. * Define the route middleware for the application.
  881. *
  882. * @param array $middleware
  883. * @return $this
  884. */
  885. public function routeMiddleware(array $middleware)
  886. {
  887. $this->routeMiddleware = array_merge($this->routeMiddleware, $middleware);
  888. return $this;
  889. }
  890. /**
  891. * {@inheritdoc}
  892. */
  893. public function handle(SymfonyRequest $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
  894. {
  895. return $this->dispatch($request);
  896. }
  897. /**
  898. * Run the application and send the response.
  899. *
  900. * @param SymfonyRequest|null $request
  901. * @return void
  902. */
  903. public function run($request = null)
  904. {
  905. $response = $this->dispatch($request);
  906. if ($response instanceof SymfonyResponse) {
  907. $response->send();
  908. } else {
  909. echo (string) $response;
  910. }
  911. if (count($this->middleware) > 0) {
  912. $this->callTerminableMiddleware($response);
  913. }
  914. }
  915. /**
  916. * Call the terminable middleware.
  917. *
  918. * @param mixed $response
  919. * @return void
  920. */
  921. protected function callTerminableMiddleware($response)
  922. {
  923. $response = $this->prepareResponse($response);
  924. foreach ($this->middleware as $middleware) {
  925. $instance = $this->make($middleware);
  926. if ($instance instanceof TerminableMiddleware) {
  927. $instance->terminate(
  928. $this->make('request'), $response
  929. );
  930. }
  931. }
  932. }
  933. /**
  934. * Dispatch the incoming request.
  935. *
  936. * @param SymfonyRequest|null $request
  937. * @return Response
  938. */
  939. public function dispatch($request = null)
  940. {
  941. if ($request) {
  942. $this->instance('Illuminate\Http\Request', $request);
  943. $this->ranServiceBinders['registerRequestBindings'] = true;
  944. $method = $request->getMethod();
  945. $pathInfo = $request->getPathInfo();
  946. } else {
  947. $method = $this->getMethod();
  948. $pathInfo = $this->getPathInfo();
  949. }
  950. try {
  951. return $this->sendThroughPipeline($this->middleware, function () use ($method, $pathInfo) {
  952. if (isset($this->routes[$method.$pathInfo])) {
  953. return $this->handleFoundRoute([true, $this->routes[$method.$pathInfo]['action'], []]);
  954. }
  955. return $this->handleDispatcherResponse(
  956. $this->createDispatcher()->dispatch($method, $pathInfo)
  957. );
  958. });
  959. } catch (Exception $e) {
  960. return $this->sendExceptionToHandler($e);
  961. }
  962. }
  963. /**
  964. * Create a FastRoute dispatcher instance for the application.
  965. *
  966. * @return Dispatcher
  967. */
  968. protected function createDispatcher()
  969. {
  970. return $this->dispatcher ?: \FastRoute\simpleDispatcher(function ($r) {
  971. foreach ($this->routes as $route) {
  972. $r->addRoute($route['method'], $route['uri'], $route['action']);
  973. }
  974. });
  975. }
  976. /**
  977. * Set the FastRoute dispatcher instance.
  978. *
  979. * @param \FastRoute\Dispatcher $dispatcher
  980. * @return void
  981. */
  982. public function setDispatcher(Dispatcher $dispatcher)
  983. {
  984. $this->dispatcher = $dispatcher;
  985. }
  986. /**
  987. * Handle the response from the FastRoute dispatcher.
  988. *
  989. * @param array $routeInfo
  990. * @return mixed
  991. */
  992. protected function handleDispatcherResponse($routeInfo)
  993. {
  994. switch ($routeInfo[0]) {
  995. case Dispatcher::NOT_FOUND:
  996. throw new NotFoundHttpException;
  997. case Dispatcher::METHOD_NOT_ALLOWED:
  998. throw new MethodNotAllowedHttpException($routeInfo[1]);
  999. case Dispatcher::FOUND:
  1000. return $this->handleFoundRoute($routeInfo);
  1001. }
  1002. }
  1003. /**
  1004. * Handle a route found by the dispatcher.
  1005. *
  1006. * @param array $routeInfo
  1007. * @return mixed
  1008. */
  1009. protected function handleFoundRoute($routeInfo)
  1010. {
  1011. $this->currentRoute = $routeInfo;
  1012. $action = $routeInfo[1];
  1013. // Pipe through route middleware...
  1014. if (isset($action['middleware'])) {
  1015. $middleware = $this->gatherMiddlewareClassNames($action['middleware']);
  1016. return $this->prepareResponse($this->sendThroughPipeline($middleware, function () use ($routeInfo) {
  1017. return $this->callActionOnArrayBasedRoute($routeInfo);
  1018. }));
  1019. }
  1020. return is_string($response = $this->callActionOnArrayBasedRoute($routeInfo))
  1021. ? $response : $this->prepareResponse($response);
  1022. }
  1023. /**
  1024. * Call the Closure on the array based route.
  1025. *
  1026. * @param array $routeInfo
  1027. * @return mixed
  1028. */
  1029. protected function callActionOnArrayBasedRoute($routeInfo)
  1030. {
  1031. $action = $routeInfo[1];
  1032. if (isset($action['uses'])) {
  1033. return $this->callControllerAction($routeInfo);
  1034. }
  1035. foreach ($action as $value) {
  1036. if ($value instanceof Closure) {
  1037. $closure = $value->bindTo(new Routing\Closure);
  1038. break;
  1039. }
  1040. }
  1041. try {
  1042. return $this->call($closure, $routeInfo[2]);
  1043. } catch (HttpResponseException $e) {
  1044. return $e->getResponse();
  1045. }
  1046. }
  1047. /**
  1048. * Call a controller based route.
  1049. *
  1050. * @param array $routeInfo
  1051. * @return mixed
  1052. */
  1053. protected function callControllerAction($routeInfo)
  1054. {
  1055. list($controller, $method) = explode('@', $routeInfo[1]['uses']);
  1056. if (! method_exists($instance = $this->make($controller), $method)) {
  1057. throw new NotFoundHttpException;
  1058. }
  1059. if ($instance instanceof Routing\Controller) {
  1060. return $this->callLumenController($instance, $method, $routeInfo);
  1061. } else {
  1062. return $this->callControllerCallable(
  1063. [$instance, $method], $routeInfo[2]
  1064. );
  1065. }
  1066. }
  1067. /**
  1068. * Send the request through a Lumen controller.
  1069. *
  1070. * @param mixed $instance
  1071. * @param string $method
  1072. * @param array $routeInfo
  1073. * @return mixed
  1074. */
  1075. protected function callLumenController($instance, $method, $routeInfo)
  1076. {
  1077. $middleware = $instance->getMiddlewareForMethod(
  1078. $this->make('request'), $method
  1079. );
  1080. if (count($middleware) > 0) {
  1081. return $this->callLumenControllerWithMiddleware(
  1082. $instance, $method, $routeInfo, $middleware
  1083. );
  1084. } else {
  1085. return $this->callControllerCallable(
  1086. [$instance, $method], $routeInfo[2]
  1087. );
  1088. }
  1089. }
  1090. /**
  1091. * Send the request through a set of controller middleware.
  1092. *
  1093. * @param mixed $instance
  1094. * @param string $method
  1095. * @param array $routeInfo
  1096. * @param array $middleware
  1097. * @return mixed
  1098. */
  1099. protected function callLumenControllerWithMiddleware($instance, $method, $routeInfo, $middleware)
  1100. {
  1101. $middleware = $this->gatherMiddlewareClassNames($middleware);
  1102. return $this->sendThroughPipeline($middleware, function () use ($instance, $method, $routeInfo) {
  1103. return $this->callControllerCallable(
  1104. [$instance, $method], $routeInfo[2]
  1105. );
  1106. });
  1107. }
  1108. /**
  1109. * Call the callable for a controller action with the given parameters.
  1110. *
  1111. * @param array $callable
  1112. * @param array $parameters
  1113. * @return mixed
  1114. */
  1115. protected function callControllerCallable(array $callable, array $parameters)
  1116. {
  1117. try {
  1118. return $this->prepareResponse(
  1119. $this->call($callable, $parameters)
  1120. );
  1121. } catch (HttpResponseException $e) {
  1122. return $e->getResponse();
  1123. }
  1124. }
  1125. /**
  1126. * Gather the full class names for the middleware short-cut string.
  1127. *
  1128. * @param string $middleware
  1129. * @return array
  1130. */
  1131. protected function gatherMiddlewareClassNames($middleware)
  1132. {
  1133. $middleware = is_string($middleware) ? explode('|', $middleware) : (array) $middleware;
  1134. return array_map(function ($name) {
  1135. return $this->routeMiddleware[$name];
  1136. }, $middleware);
  1137. }
  1138. /**
  1139. * Send the request through the pipeline with the given callback.
  1140. *
  1141. * @param array $middleware
  1142. * @param Closure $then
  1143. * @return mixed
  1144. */
  1145. protected function sendThroughPipeline(array $middleware, Closure $then)
  1146. {
  1147. if (count($middleware) > 0) {
  1148. return (new Pipeline($this))
  1149. ->send($this->make('request'))
  1150. ->through($middleware)
  1151. ->then($then);
  1152. }
  1153. return $then();
  1154. }
  1155. /**
  1156. * Prepare the response for sending.
  1157. *
  1158. * @param mixed $response
  1159. * @return Response
  1160. */
  1161. public function prepareResponse($response)
  1162. {
  1163. if (! $response instanceof SymfonyResponse) {
  1164. $response = new Response($response);
  1165. } elseif ($response instanceof BinaryFileResponse) {
  1166. $response = $response->prepare(Request::capture());
  1167. }
  1168. return $response;
  1169. }
  1170. /**
  1171. * Get the current HTTP request method.
  1172. *
  1173. * @return string
  1174. */
  1175. protected function getMethod()
  1176. {
  1177. if (isset($_POST['_method'])) {
  1178. return strtoupper($_POST['_method']);
  1179. } else {
  1180. return $_SERVER['REQUEST_METHOD'];
  1181. }
  1182. }
  1183. /**
  1184. * Get the current HTTP path info.
  1185. *
  1186. * @return string
  1187. */
  1188. public function getPathInfo()
  1189. {
  1190. $query = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
  1191. return '/'.trim(str_replace('?'.$query, '', $_SERVER['REQUEST_URI']), '/');
  1192. }
  1193. /**
  1194. * Get the base path for the application.
  1195. *
  1196. * @param string $path
  1197. * @return string
  1198. */
  1199. public function basePath($path = null)
  1200. {
  1201. if (isset($this->basePath)) {
  1202. return $this->basePath.($path ? '/'.$path : $path);
  1203. }
  1204. if ($this->runningInConsole() || php_sapi_name() === 'cli-server') {
  1205. $this->basePath = getcwd();
  1206. } else {
  1207. $this->basePath = realpath(getcwd().'/../');
  1208. }
  1209. return $this->basePath($path);
  1210. }
  1211. /**
  1212. * Get the storage path for the application.
  1213. *
  1214. * @param string $path
  1215. * @return string
  1216. */
  1217. public function storagePath($path = null)
  1218. {
  1219. if ($this->storagePath) {
  1220. return $this->storagePath.($path ? '/'.$path : $path);
  1221. }
  1222. return $this->basePath().'/storage'.($path ? '/'.$path : $path);
  1223. }
  1224. /**
  1225. * Set a custom storage path for the application.
  1226. *
  1227. * @param string $path
  1228. * @return $this
  1229. */
  1230. public function useStoragePath($path)
  1231. {
  1232. $this->storagePath = $path;
  1233. return $this;
  1234. }
  1235. /**
  1236. * Get the database path for the application.
  1237. *
  1238. * @return string
  1239. */
  1240. public function databasePath()
  1241. {
  1242. return $this->basePath().'/database';
  1243. }
  1244. /**
  1245. * Set a custom configuration path for the application.
  1246. *
  1247. * @param string $path
  1248. * @return $this
  1249. */
  1250. public function useConfigPath($path)
  1251. {
  1252. $this->configPath = $path;
  1253. return $this;
  1254. }
  1255. /**
  1256. * Get the resource path for the application.
  1257. *
  1258. * @param string $path
  1259. * @return string
  1260. */
  1261. public function resourcePath($path = null)
  1262. {
  1263. if ($this->resourcePath) {
  1264. return $this->resourcePath.($path ? '/'.$path : $path);
  1265. }
  1266. return $this->basePath().'/resources'.($path ? '/'.$path : $path);
  1267. }
  1268. /**
  1269. * Set a custom resource path for the application.
  1270. *
  1271. * @param string $path
  1272. * @return $this
  1273. */
  1274. public function useResourcePath($path)
  1275. {
  1276. $this->resourcePath = $path;
  1277. return $this;
  1278. }
  1279. /**
  1280. * Determine if the application is running in the console.
  1281. *
  1282. * @return string
  1283. */
  1284. public function runningInConsole()
  1285. {
  1286. return php_sapi_name() == 'cli';
  1287. }
  1288. /**
  1289. * Prepare the application to execute a console command.
  1290. *
  1291. * @return void
  1292. */
  1293. public function prepareForConsoleCommand()
  1294. {
  1295. $this->withFacades();
  1296. $this->make('cache');
  1297. $this->make('queue');
  1298. $this->configure('database');
  1299. $this->register('Illuminate\Database\MigrationServiceProvider');
  1300. $this->register('Illuminate\Database\SeedServiceProvider');
  1301. $this->register('Illuminate\Queue\ConsoleServiceProvider');
  1302. }
  1303. /**
  1304. * Get the raw routes for the application.
  1305. *
  1306. * @return array
  1307. */
  1308. public function getRoutes()
  1309. {
  1310. return $this->routes;
  1311. }
  1312. /**
  1313. * Set the cached routes.
  1314. *
  1315. * @param array $routes
  1316. * @return void
  1317. */
  1318. public function setRoutes(array $routes)
  1319. {
  1320. $this->routes = $routes;
  1321. }
  1322. /**
  1323. * Register the core container aliases.
  1324. *
  1325. * @return void
  1326. */
  1327. protected function registerContainerAliases()
  1328. {
  1329. $this->aliases = [
  1330. 'Illuminate\Contracts\Foundation\Application' => 'app',
  1331. 'Illuminate\Contracts\Auth\Guard' => 'auth.driver',
  1332. 'Illuminate\Contracts\Auth\PasswordBroker' => 'auth.password',
  1333. 'Illuminate\Contracts\Cache\Factory' => 'cache',
  1334. 'Illuminate\Contracts\Cache\Repository' => 'cache.store',
  1335. 'Illuminate\Container\Container' => 'app',
  1336. 'Illuminate\Contracts\Container\Container' => 'app',
  1337. 'Illuminate\Contracts\Cookie\Factory' => 'cookie',
  1338. 'Illuminate\Contracts\Cookie\QueueingFactory' => 'cookie',
  1339. 'Illuminate\Contracts\Encryption\Encrypter' => 'encrypter',
  1340. 'Illuminate\Contracts\Events\Dispatcher' => 'events',
  1341. 'Illuminate\Contracts\Filesystem\Factory' => 'filesystem',
  1342. 'Illuminate\Contracts\Hashing\Hasher' => 'hash',
  1343. 'log' => 'Psr\Log\LoggerInterface',
  1344. 'Illuminate\Contracts\Mail\Mailer' => 'mailer',
  1345. 'Illuminate\Contracts\Queue\Queue' => 'queue.connection',
  1346. 'Illuminate\Redis\Database' => 'redis',
  1347. 'Illuminate\Contracts\Redis\Database' => 'redis',
  1348. 'request' => 'Illuminate\Http\Request',
  1349. 'Illuminate\Session\SessionManager' => 'session',
  1350. 'Illuminate\Contracts\View\Factory' => 'view',
  1351. ];
  1352. }
  1353. /**
  1354. * The available container bindings and their respective load methods.
  1355. *
  1356. * @var array
  1357. */
  1358. public $availableBindings = [
  1359. 'auth' => 'registerAuthBindings',
  1360. 'auth.driver' => 'registerAuthBindings',
  1361. 'Illuminate\Contracts\Auth\Guard' => 'registerAuthBindings',
  1362. 'auth.password' => 'registerAuthBindings',
  1363. 'Illuminate\Contracts\Auth\PasswordBroker' => 'registerAuthBindings',
  1364. 'Illuminate\Contracts\Bus\Dispatcher' => 'registerBusBindings',
  1365. 'cache' => 'registerCacheBindings',
  1366. 'Illuminate\Contracts\Cache\Factory' => 'registerCacheBindings',
  1367. 'Illuminate\Contracts\Cache\Repository' => 'registerCacheBindings',
  1368. 'config' => 'registerConfigBindings',
  1369. 'composer' => 'registerComposerBindings',
  1370. 'cookie' => 'registerCookieBindings',
  1371. 'Illuminate\Contracts\Cookie\Factory' => 'registerCookieBindings',
  1372. 'Illuminate\Contracts\Cookie\QueueingFactory' => 'registerCookieBindings',
  1373. 'db' => 'registerDatabaseBindings',
  1374. 'encrypter' => 'registerEncrypterBindings',
  1375. 'Illuminate\Contracts\Encryption\Encrypter' => 'registerEncrypterBindings',
  1376. 'events' => 'registerEventBindings',
  1377. 'Illuminate\Contracts\Events\Dispatcher' => 'registerEventBindings',
  1378. 'Illuminate\Contracts\Debug\ExceptionHandler' => 'registerErrorBindings',
  1379. 'files' => 'registerFilesBindings',
  1380. 'filesystem' => 'registerFilesBindings',
  1381. 'Illuminate\Contracts\Filesystem\Factory' => 'registerFilesBindings',
  1382. 'hash' => 'registerHashBindings',
  1383. 'Illuminate\Contracts\Hashing\Hasher' => 'registerHashBindings',
  1384. 'log' => 'registerLogBindings',
  1385. 'Psr\Log\LoggerInterface' => 'registerLogBindings',
  1386. 'mailer' => 'registerMailBindings',
  1387. 'Illuminate\Contracts\Mail\Mailer' => 'registerMailBindings',
  1388. 'queue' => 'registerQueueBindings',
  1389. 'queue.connection' => 'registerQueueBindings',
  1390. 'Illuminate\Contracts\Queue\Queue' => 'registerQueueBindings',
  1391. 'redis' => 'registerRedisBindings',
  1392. 'request' => 'registerRequestBindings',
  1393. 'Illuminate\Http\Request' => 'registerRequestBindings',
  1394. 'session' => 'registerSessionBindings',
  1395. 'session.store' => 'registerSessionBindings',
  1396. 'Illuminate\Session\SessionManager' => 'registerSessionBindings',
  1397. 'translator' => 'registerTranslationBindings',
  1398. 'url' => 'registerUrlGeneratorBindings',
  1399. 'validator' => 'registerValidatorBindings',
  1400. 'view' => 'registerViewBindings',
  1401. 'Illuminate\Contracts\View\Factory' => 'registerViewBindings',
  1402. ];
  1403. /**
  1404. * Get the HTML from the Lumen welcome screen.
  1405. *
  1406. * @return string
  1407. */
  1408. public function welcome()
  1409. {
  1410. return "<html>
  1411. <head>
  1412. <title>Lumen</title>
  1413. <link href='//fonts.googleapis.com/css?family=Lato:100' rel='stylesheet' type='text/css'>
  1414. <style>
  1415. body {
  1416. margin: 0;
  1417. padding: 0;
  1418. width: 100%;
  1419. height: 100%;
  1420. color: #B0BEC5;
  1421. display: table;
  1422. font-weight: 100;
  1423. font-family: 'Lato';
  1424. }
  1425. .container {
  1426. text-align: center;
  1427. display: table-cell;
  1428. vertical-align: middle;
  1429. }
  1430. .content {
  1431. text-align: center;
  1432. display: inline-block;
  1433. }
  1434. .title {
  1435. font-size: 96px;
  1436. margin-bottom: 40px;
  1437. }
  1438. .quote {
  1439. font-size: 24px;
  1440. }
  1441. </style>
  1442. </head>
  1443. <body>
  1444. <div class=\"container\">
  1445. <div class=\"content\">
  1446. <div class=\"title\">Lumen.</div>
  1447. </div>
  1448. </div>
  1449. </body>
  1450. </html>
  1451. ";
  1452. }
  1453. }