Reputation: 1650
I'm developing a web project with Google Dart SDK version 2.2 and using PhpStorm as my IDE. The project is intended to start with a index.php
file which does some preliminary server side work at the end of which is a call to include('project1.html');
which downloads the html file to the client and includes <script defer src="project1.dart.js"></script>
at the end. I'm trying to figure out the best setup for development. I have php installed on the development machine and included in the path.
I have found that calling webdev serve
from the terminal serves the project to http://localhost:8080
but displays Could not find web/index.html
instead of the expected rendering of project1.html
. So I guess the webdev server does not handle .php files?
Another approach is to right click the index.php
file and select run in browser
. This brings up a Chrome page displaying the text of the index.php
file. So again php not processed I guess.
Another approach is to set up a javascript debug configuration with default settings and clicking the green debug icon. This does produces the correct project1.index
output and the index.php
has been correctly processed. However, I cannot get breakpoints to work and errors in the Chrome Dev Console refer to the project1.dart.js
file in the build
directory.
Another approach I tried is using an Xampp server to serve the files. In this case I had a number of projects and set each up under xampp/htdocs
i.e. xampp/htdcos/project1
etc. In PhpStorm I set up a local or mounted server with:
C:\xampp\htdocs\project1
,http://localhost/project1
,web
subdirectory of my project, and\
.PhpStorm seems to work ok but again breakpoints did not work and debug error messages did not refer to the dart files.
Any help would be most welcome. Is what I am trying to do even possible with this setup i.e. starting with an index.php
file?
** EDIT **
Following advice below, I added following to my httpd-vhosts.conf file:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/project1"
ServerName localhost
ProxyPreserveHost On
ProxyRequests Off
ProxyPassMatch ^/(.*\.js)$ http://localhost:8080/$1
</VirtualHost>
Then I keep my .php files and MySql on Xampp and javascript is served by webdev serve
.
However, I have the same problem i.e. breakpoints in PhpStorm or Chrome dev tools source Dart files don't trigger and Chrome dev tools console refers to javascript files instead of Dart source.
Upvotes: 0
Views: 704
Reputation: 27
You need to run a reverse proxy on the apache/php server and redirect js requests to webdev server, then you just run your application testing using the apache/php server and any browser. When you go to deploy, use dart2js to generate the js files and copy the whole build directory where it can be read by a normal apache/php server (i.e. no reverse proxy).
Upvotes: 2