I'm creating a module that is meant to consume an API and create nodes based on the data received. Currently, I just have one long PHP script (650 lines) that creates the config form, processes the data, consumes the API, then create and save the nodes. Since PHP isn't really build to handle long scripts or processes like that, I'm having trouble optimizing my code and avoiding stack overflows. What are some strategies that module developers use to effectively process large amounts of data? Do you write a script in Java or C++, then call the exec() function from the PHP script? If so, how would you include the additional file properly in the PSR-4 file structure. If you have other ideas, please do share.

Comments

Jaypan’s picture

Unfortunately your question is too broad. Maybe you can break it down into a few smaller specific points that people will be able to answer.

Jaypan’s picture

Unfortunately your question is too broad. Maybe you can break it down into a few smaller specific points that people will be able to answer.

blakemorgan’s picture

Sorry. I guess my question is this: yes a module has a PHP backend, but is there a way to pull in scripts in other programming languages? The issue isn't writing the script (as I already have it written), rather the issue is handling memory.

Jaypan’s picture

You can call server scripts with exec() or shell_exec().

blakemorgan’s picture

And where in the PSR-4 file structure would I put that script?

Jaypan’s picture

I'd probably put it at somewhere like src/Importer/NodeImporter.php or something like that.