From my understand Composer is used to autoload classes via the SPL function provided by PHP, or at least register the method to call when the class does not exist. This then has to happen upon every request for a traditional setup with Laravel or CakePHP for example...
My question is, how would Composer work in a Swoole HTTP Server situation where you are free to preload everything before hand? Is Composer even needed in this context?
A Swoole HTTP PHP Server in basic terms looks like this:
<?php
// Load all your classes and files here?
$http = new swoole_http_server("127.0.0.1", 9501);
$http->on("start", function ($server) {
echo "Swoole http server is started at http://127.0.0.1:9501\n";
});
$http->on("request", function ($request, $response) {
$response->header("Content-Type", "text/plain");
$response->end("Hello World\n");
});
$http->start();
So I could load everything before hand not worry about having to call any autoloading script?
All of the classes would then be in global scope thus, everything is preloaded and ready to use in the ->on("request")
function callback.