app.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /*
  3. |--------------------------------------------------------------------------
  4. | Create The Application
  5. |--------------------------------------------------------------------------
  6. |
  7. | The first thing we will do is create a new Laravel application instance
  8. | which serves as the "glue" for all the components of Laravel, and is
  9. | the IoC container for the system binding all of the various parts.
  10. |
  11. */
  12. $app = new \app\framework\Foundation\Application(
  13. realpath(__DIR__.'/../')
  14. );
  15. /*
  16. |--------------------------------------------------------------------------
  17. | Bind Important Interfaces
  18. |--------------------------------------------------------------------------
  19. |
  20. | Next, we need to bind some important interfaces into the container so
  21. | we will be able to resolve them when needed. The kernels serve the
  22. | incoming requests to this application from both the web and CLI.
  23. |
  24. */
  25. $app->singleton('Log.trace', function (){
  26. return new \app\framework\Log\TraceLog();
  27. });
  28. $app->singleton('Log.debug', function (){
  29. return new \app\framework\Log\DebugLog();
  30. });
  31. $app->singleton('Log.error', function (){
  32. return new \app\framework\Log\ErrorLog();
  33. });
  34. $app->singleton(
  35. Illuminate\Contracts\Http\Kernel::class,
  36. app\Kernel::class
  37. );
  38. $app->singleton(
  39. Illuminate\Contracts\Console\Kernel::class,
  40. app\console\Kernel::class
  41. );
  42. $app->singleton(
  43. Illuminate\Contracts\Debug\ExceptionHandler::class,
  44. app\common\exceptions\Handler::class
  45. );
  46. $app->bind(app\framework\Http\Request::class,'request');
  47. error_reporting(E_ALL);ini_set('display_errors', 1);
  48. $app->bind(\Illuminate\Contracts\Bus\Dispatcher::class,\app\framework\Bus\Dispatcher::class);
  49. /*
  50. |--------------------------------------------------------------------------
  51. | Return The Application
  52. |--------------------------------------------------------------------------
  53. |
  54. | This script returns the application instance. The instance is given to
  55. | the calling script so we can separate the building of the instances
  56. | from the actual running of the application and sending responses.
  57. |
  58. */
  59. return $app;