Frameworks: Because stack traces should be 60 lines long

You don't call the framework, the framework calls you.

Other people can better explain why composing libraries is better than using a framework:

If you don't want to read much then I can still persuade you that working with (and thus debugging inside) a framework is no joy:

Call Stack:
 1. {main}()
 2. Illuminate\Foundation\Http\Kernel->handle()
 3. Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()
 4. Illuminate\Pipeline\Pipeline->then()
 5. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
 6. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
 7. Dingo\Api\Http\Middleware\Request->handle()
 8. Dingo\Api\Http\Middleware\Request->sendRequestThroughRouter()
 9. Illuminate\Pipeline\Pipeline->then()
10. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
11. Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle()
12. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
13. Immogic\Http\Middleware\LogAfterRequest->handle()
14. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
15. Dingo\Api\Http\Middleware\Request->Dingo\Api\Http\Middleware\{closure}()
16. Dingo\Api\Routing\Router->dispatch()
17. Dingo\Api\Routing\Adapter\Laravel->dispatch()
18. Illuminate\Routing\Router->dispatch()
19. Illuminate\Routing\Router->dispatchToRoute()
20. Illuminate\Routing\Router->runRouteWithinStack()
21. Illuminate\Pipeline\Pipeline->then()
22. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
23. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
24. Dingo\Api\Http\Middleware\PrepareController->handle()
25. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
26. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
27. Immogic\Http\Middleware\Authenticate->handle()
28. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
29. Illuminate\Routing\Router->Illuminate\Routing\{closure}()
30. Illuminate\Routing\Route->run()
31. Illuminate\Routing\Route->runController()
32. Illuminate\Routing\ControllerDispatcher->dispatch()
33. Illuminate\Routing\Controller->callAction()
34. call_user_func_array:{/var/www/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:55}()
35. Immogic\Http\Controllers\Api\V1\BrokerController->index()
36. Dingo\Api\Http\Response\Factory->paginator()
37. Dingo\Api\Http\Response->__construct()
38. Symfony\Component\HttpFoundation\Response->__construct()
39. Dingo\Api\Http\Response->setContent()
40. Illuminate\Http\Response->setContent()
41. Illuminate\Http\Response->morphToJson()
42. Illuminate\Pagination\LengthAwarePaginator->toJson()
43. Illuminate\Pagination\LengthAwarePaginator->jsonSerialize()
44. Illuminate\Pagination\LengthAwarePaginator->toArray()
45. Illuminate\Support\Collection->toArray()
46. array_map()
47. Illuminate\Support\Collection->Illuminate\Support\{closure}()
48. Immogic\User->toArray()
49. Immogic\User->getFileSizeField()
50. Immogic\User->getFileUrl()
51. app()
52. Illuminate\Foundation\Application->make()
53. Illuminate\Container\Container->make()
54. Illuminate\Container\Container->build()
55. Dingo\Api\Provider\RoutingServiceProvider->Dingo\Api\Provider\{closure}()
56. Dingo\Api\Routing\Router->getRoutes()
57. Dingo\Api\Routing\Router->createRoute()
58. Dingo\Api\Routing\Route->__construct()
59. Dingo\Api\Routing\Route->setupRouteProperties()
60. Dingo\Api\Routing\Route->mergeControllerProperties()
61. Dingo\Api\Routing\Route->makeControllerInstance()
62. Illuminate\Foundation\Application->make()
63. Illuminate\Container\Container->make()
64. Illuminate\Container\Container->build()
65. ReflectionClass->newInstanceArgs()
66. Immogic\Http\Controllers\Api\ProducerDb\ProducersController->__construct()
67. Dingo\Api\Transformer\Factory->register()
68. xdebug_print_function_stack()

I've shortened the output for brevity. I'm sure you spotted the error.

Written by Christian Weiske.

Comments? Please send an e-mail.