Semi-new to the backend world.
In the process of creating a small web app for my work place.
I just want to find out what the best method will be to give the end user a script that they put on their site. i.e. how google give their analytics script.
Simple answers such as which frameworks, tools etc to use is more than fine. Willing to learn! ;)
My hope is to have it published on S3 when they save their configurations.
I've been building the app with Laravel framework.
Originally I was using Wordpress, I created a function that saved a section to a js file on the server, but it didn't feel practical.
Any help or guidance will be very appreciated.
Simple answers such as which frameworks, tools etc to use is more than fine. Willing to learn! ;)
Your question is too general, there isn't a one right way or a framework/tools that does this task better/worse than others, it just depends on how you want and how you will implement it.
You also mentioned google analytics script but I don't think they offer users to download a js file with the code, all they do is show it in a textarea where the user can copy/paste the generated code. Not sure what your requirements are but why would you want to host users' js files and pay for that (you mentioned S3). If a user is able to include a <script> tag into their site - they are also able to host the .js file or include it inside html.
Anyaway, if you want the users to be able to download the JS files then there are still many was of doing this:
You could use AWS S3 API and upload the generated JS code (no need to save files locally) and show the direct link to the user.
You could store the generated JS code in a public folder locally and provide the user with direct link.
You could create a route with unique URLs where the framework handler would generate (or pull from database) the JS code (no need to save files locally) every time. The link would look something like http://example.com/download/<user_id>/<script_id>.js your framework of choice would receive the request, associate it with the user and user's settings and generate the code. This would probably be the best way of doing this assuming that the user will rarely use the link and only to actually download the code and not to hotlink.