I am finishing my large app which uses Vue.js on client side, and php and mysql on server side, however both client and server side will run on the same computer which won't have access to internet. Any security issues like XSS attacks and so on are not a problem right now.

Because app also need access to IoT i decided to use google chrome apps so i can create tcp server and exchange data via TCP protocol with arduino. I did sth like this before, and it is not an issue. However need of using mysql and php face me today with a huge problem - how to use google chrome packaged app with php files.

First attempt was to just load a php file in bacgkround.js file like this:

chrome.app.runtime.onLaunched.addListener(function() {
  chrome.app.window.create('admin/admin.php', {
    'outerBounds': {
      'width': 400,
      'height': 500
    }
  });
});

It didnt work - whole php code of file was treated as pure text (not compiled).

Later i decided to create a file admin.html and change above code to admin/admin.html which holds:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
</head>
<body>
  <h1>Hello, let's code!</h1>
</body>
</html>
  <script src='../libraries/jquery.min.js'></script>
  <script src='test.js'></script>

and test.js looks like this:

console.log('Did it load?')
$.ajax({
    url: '../server/admin.php'
}).done(function (data) {
$('body').html(data)
})

I loaded jQuery just to speed up my tests. Unfortunatelly it still doesnt work. Code of admin.php is loaded correctly, but only html tags. PHP is commented automatically by the browser. Also vue library is ignored, but I didnt went there yet.

The question is: - how to use php generated by apache files in google chrome packaged apps if it is not possible: - is that possible to create tcp server within google packaged app, and let it communicate with normal page?

0 Answers