1

I am making a sales system to record and monitor sales. I am using webpack to bundle all of my code. For the backend I am using PHP and MySql. I came across php-loader package. The description says that it will load any php content and use php to turn it into a html page. I am not quite sure I fully understand the working of it here. If it is converting it into an HTML page, do I need an html-loader or not. If yes, how am I supposed to put it in the webpack.config.js file? Please guide me through this? Thanks in advance!

  • Can you say a little more about your requirements? What do you want to do with PHP and how will you handle it in the frontend? I have the impression that this does not macht your requirements. The PHP Loader simply returns what a client would see when calling the PHP file (rendered HTML). In your JS code you are able to re-use the return as a variable, e.g. var fileContent = require("php!./file.php"); From how I think the PHP loader works, this is static at the time of compiling. That means your PHP will only be executed once when you build your app (not 100% sure, though). – Gegenwind Oct 22 '17 at 08:40
  • I am trying to develop a dashboard system with two types of users; admin and salesman. Salesmen would record their sales and the admin will monitor it using a dashboard. I am using jquery, jquery-ui and bootstrap as of now for the frontend and I wanted to keep it as simple as possible so I am using PHP and MySql for the backend(as in to recored and fetch data) – Amaan Kulshreshtha Oct 22 '17 at 10:29
  • Can you give an example of what your PHP script is responding? With your current approach it seems that PHP needs to have its own HTML rendering which seems a bit mixed between frontend and backend. A better approach could be to have PHP return only the data, for example in JSON format, and then process the data structure and display it in the frontend. – Gegenwind Oct 22 '17 at 11:19

0 Answers0