My existing Laravel project is such that all the tasks are executed sequentially. I have identified part of the code which can be run in parallel using PHP threads and can reduce the response time.
So I'm trying to use pthreads, https://github.com/krakjoe/pthreads/tree/PHP5. The appserver.io is already comes with pthread, thus I'm running project on appserver.io and not apache.
I was able to use pthread successfully. As in creating new PDO connection under run()
method for each thread and database interaction is working fine using native query like this:
self::$connection = new PDO ( 'mysql:host=127.0.0.1;dbname=mydb' , 'myuser' , 'mypass' );
But I'm not able to use Laravel's \DB:connection
the same way. I need to have this working in order to run my code which is written with ORM based queries. How can I create new connection every time under run()
method?