php-middleware/phpdebugbar

Assets are in vendor directory

weierophinney opened this issue · 2 comments

This is not really an issue of this repository, other than it will require a documentation point in the README.md file: the debugbar creates links and script references to files that are in the vendor/ directory. Examples:

  • /vendor/maximebf/debugbar/src/DebugBar/Resources/vendor/font-awesome/css/font-awesome.min.css
  • /vendor/maximebf/debugbar/src/DebugBar/Resources/vendor/highlightjs/styles/github.css
  • /vendor/maximebf/debugbar/src/DebugBar/Resources/debugbar.css
  • etc.

The issue with this is that for many applications, the web root is not the same as the project root, which means that the vendor/ directory is not directly accessible via the web.

There are a few ways to fix the situation.

First, you can symlink the vendor/ directory into your web root:

$ cd public
$ ln -s ../vendor .

This is not recommended, as it exposes library code via the web.

A better way is to copy just the assets into a directory of your web root, and pass that relative path to the call to getJavascriptRenderer(). As an example:

$ cd public
$ cp -a ../vendor/maximebf/debugbar/src/DebugBar/Resources phpdebugbar

The above copies the entire set of assets into a directory named phpdebugbar/ in your web root. From there, you only need to alter the line where you retrieve the JSON renderer:

$debugbarRenderer = $debugbar->getJavascriptRenderer('phpdebugbar');

Once you've done that, everything works correctly.

I'd recommend adding this documentation to the README.md file to help users understand how to incorporate the middleware in such applications.

@weierophinney You are absolutely right, however I have found better and simpler to use solution in #3 . Can you review this?

@weierophinney thanks for help. I have just release 1.1.0. I have also added factory to respository, so installation will be easier.