soundarrr the ideal solution is to have a second hosting/computer with a similar system. This could be a temporary server, a virtual machine, or your local machine with some
platform attributes in
composer.json if your system is not the same as the server. What's important is that Composer knows which PHP version is used and which PHP extensions (not Flarum extensions) are available on the system.
Then you use Composer just like you would on the server, but on your more powerful computer.
Then you copy the
composer.lock files to the hosting and run
composer install on the hosting. This will install everything listed in
composer.lock and requires a lot less memory than running
require on the hosting. Or alternatively, upload the whole
vendor folder from the computer to the hosting, but this might be a bit more slow and could end up with wrong file permissions.
That being said we strongly recommend choosing a host that can run Composer on the hosting itself as this could be necessary for some troubleshooting or upgrade steps in the future.