Speed Up Your Laravel Projects Using Laravel Octane & Swoole Server
As we already know, the Laravel framework gives us abundant features. It also has a lot of packages that we can use to build our next great apps. But, here’s a question for yourself. Do you know how’s the lifecycle of Laravel works? This thing is important to us, as a developer, because if we understand how it works, we can be more understand what’s in here and what’s missing, and maybe we can extend the functionalities further.
Laravel lifecycle is pretty complicated to explain in this short article but, let me explain in this way. Every request that comes into our app, will start to execute the public/index.php as the starting point. From this index file, the request will go through to the HTTP/Console Kernels, Service Providers, Routing, and finally send back a response to the user. You can see the detailed lifecycle in the documentation here. In the steps above, Laravel will execute, load, and compile some scripts. Later, when the response is being sent back, all of the instances will be destroyed.
PHP is an interpreted language. This means, when a PHP script runs, the interpreter parses, compiles, and executes the code over and over again on each request. This may result in wasting CPU…