2
votes

I have hard time crafting PHP project with Dart:

  1. Dart recommends (i think) to set a workspace putting my web files in directory called 'web', but since I am using a PHP framework, there is already directory scheme, which doesn't include web in it. The main problem is importing packages is very annoying.

    for example:

    import 'package:polymer/polymer.dart';

    should have no problem with the Dart editor, but when running the site, it show a 404 error in the console saying 'An error occurred loading file: package:polymer/polymer.dart', this happens because it is trying to load it relatively to the file it was imported in.

    So I moved the packages folder to my Dart folder (the folder responsible for holding my dart scripts), and it loads fine.

    is this fine, or some other library will fail to work properly ?

  2. After I used my hack in point 1, custom elements doesn't work. All the files are loaded successfully (the polymer library, the custom element HTML file), but no output !!

    note: I named my element 'tab-control', so there should be no problem with the one dash rule.

  3. Of course after the mess up in point 1, I can't produce working dart2js file, because it doesn't produce any.

So my main big question, What is the proposed way to manage a Dart project with normal server side language (i.e. not an AJAX project) ??

My brain is really tired, and I am thinking to revert my project to JS :(.

All the examples in https://www.dartlang.org/samples/ are pure HTML apps, or AJAX apps, which is not my issue here.

1

1 Answers

0
votes

You should convert you project to JavaScript using pub build and deploy the resulting build directory. This way you don't need package directories.

When dart2dart is ready you can deploy a Dart version too. Currently it's possible using pub build --mode=debug which also generates the Dart output but doesn't minify Dart or JS..