Jump to content
adrian

Tracy Debugger

Recommended Posts

Ok, the PHP 5.3 issue should be fixed in TracyDebugger and a PR has been submitted for Performance panel as well.

  • Like 3

Share this post


Link to post
Share on other sites

Some more improvements:

Fields List and Values section on the PW Info panel

Take a look at the "images" field in the screeshot - much cleaner and more informative.

I have populated all the files/images related properties: filename, ext, url, httpUrl, filesize, filesizeStr, width, height, description, etc. Think of it as a cheatsheet with properties and values built right in. I have also added formatted dates and user names in parentheses for reference.

post-985-0-25555700-1456797445_thumb.png

Variables Panel

I have also recently tweaked the Variables panel to be easier to read and to separate into columns with the variable name, its type, and value:

post-985-0-89696500-1456797753_thumb.png

Development Tip

One final thing - a bit of a development tip using Tracy - want a quick way to see the results of a PW selector?

Try this out in one of your template files:

bd($pages->find("template=basic-page")->explode('name'));

You will see something like this in your Dumps panel:

post-985-0-21138400-1456797893_thumb.png

On a live site in production mode, it pays to do it like this:

if($user->isSuperuser()) bd($pages->find("template=basic-page")->explode('name'));

This way, even if your selector generates an exception (quite easy to do if you accidentally enter an incorrect field name), no-one but you will see the error.

  • Like 4

Share this post


Link to post
Share on other sites

Now I get (in Diag & Output panel):

PDOException: SQLSTATE[HY000] [2002] Nobene povezave ni mogoe vzpostaviti, ker jo ciljni raunalnik aktivno zavraa.
in C:\inetpub\wwwroot\site\assets\cache\FileCompiler\site\modules\TracyDebugger\DiagnosticsPanel.inc:287
Stack trace:
#0 C:\inetpub\wwwroot\site\assets\cache\FileCompiler\site\modules\TracyDebugger\DiagnosticsPanel.inc(287): PDO->__construct('mysql:host=loca...', 'myusername', 'mypassword')
#1 C:\inetpub\wwwroot\site\assets\cache\FileCompiler\site\modules\TracyDebugger\tracy\src\Tracy\Bar.php(73): DiagnosticsPanel->getPanel()
#2 C:\inetpub\wwwroot\site\assets\cache\FileCompiler\site\modules\TracyDebugger\tracy\src\Tracy\Debugger.php(221): Tracy\Bar->render()
#3 [internal function]: Tracy\Debugger::shutdownHandler()
#4 {main}

It shows user/pass for DB in plain view...

A also can't move some panels, see the video.

post-2202-0-57364600-1456802881_thumb.gi

Edited by matjazp
  • Like 2

Share this post


Link to post
Share on other sites

Sorry about the database connection error. There was a problem with some attributes and the PW $database connection, but I have removed those two problem ones and now use $database. Please let me know if it is working properly again now with the latest version.

I know about the panel moving issue - some do that weird resizing before they will move. It is on my list of things to take a look at - not sure if it's maybe a core Tracy issue, but I'll try to sort it out regardless.

  • Like 1

Share this post


Link to post
Share on other sites

No luck with the new version, error is stil there.

Hm, it's working now ... don't know what I did...

Edited by matjazp
  • Like 1

Share this post


Link to post
Share on other sites

No luck with the new version, error is stil there.

Hm, it's working now ... don't know what I did...

Glad it's working fine now - please let me know if you come across any other problems with that.

Share this post


Link to post
Share on other sites

Thanks for the new releases! I get used to it recently, updating Tracy when having the morning coffee :)

Adding an "in-panel search as you type" feature would be handy I think. Basically I mean a search input above the panel tables (one per panel), in which if you start typing the table non-matching rows would get hidden.

The problem is that not all panels have tables but divs.

  • Like 1

Share this post


Link to post
Share on other sites

After update to version 0.9.7 i have this error :

Fatal error: Call to a member function getImageInfo() on a non-object in /......./......./......./......./site/assets/cache/FileCompiler/site/modules/TracyDebugger/ProcesswireInfoPanel.inc on line 259 

Tracy panel not appear for front-end and if i comment this line it look like working.

PW version : ProcessWire 3.0.9 devns

Share this post


Link to post
Share on other sites

Hey @ukyo - sorry about that - please try the latest version and let me know how it goes for you. That was actually some leftover code that wasn't needed anymore :)

  • Like 1

Share this post


Link to post
Share on other sites

With 0.9.8 version problem look like gone. Thanks for quick reply / fix !

  • Like 1

Share this post


Link to post
Share on other sites

Hi everyone,

I have just set up the ability to customize the potocol handler for opening files in your editor directly to the line of error - this is potentially a huge timesaver :)

The new config setting is "Editor Protocol Handler":

post-985-0-31774400-1456895869_thumb.png

It is initially configured for SublimeText because that is my editor and I know lots of you also use it.

To make things work, grab this free subl:// protocol registering app: https://github.com/saetia/sublime-url-protocol-mac - note the instructions at the bottom if you need to make it work for ST2 instead of ST3. If you're not using ST, there are other ways to set up your own custom protocol handler, but I'l leave you guys to figure that out.

Once you have done that you will be able to click on any of the links in errors, dumps, and barBumps and it will open the file in ST to the exact line.

post-985-0-99120100-1456932310_thumb.png

post-985-0-86665200-1456932311_thumb.png

post-985-0-78615100-1456932309_thumb.png

 

Note: the links are to the actual original files, not the PW 3.x compiled versions !

  • Like 3

Share this post


Link to post
Share on other sites

The Editor Protocol Handler would be great, but I have problems with escaped characters like / as %2F. The links look like this:

openineclipse://open?url=file://%2FLibrary%2FWebServer%2FDocuments%2Fpw25%2Fsite%2Ftemplates%2Fhome.php&line=25

But in Safari at least this doesn't work if I don't change each "%2F" to "/".  How could I change the links to be like:

openineclipse://open?url=file:///Library/WebServer/Documents/pw25/site/templates/home.php&line=25

or get Safari or Chrome understand 

I found help on defining the Editor Protocol Handler for Eclipse "openineclipse" on this page: http://teleyag.com/blog/2011/08/19/openineclipse-url-scheme-for-mac/

Share this post


Link to post
Share on other sites

Hi @Ipa,

It's working fine for me on Safari, Chrome, and Firefox on my Mac with Sublime so I am guessing it's an eclipse issue. 

I wonder if it could be solved in your applescript with the urldecode line from this snippet?

using terms from application "Quicksilver"
        on process text theurl
                return do shell script "php -r 'echo urldecode(\"" & theurl & "\");'"
        end process text
end using terms from

https://qsapp.com/wiki/Encode/Decode_URL_(AppleScript)

or maybe one of these options:

http://harvey.nu/applescript_url_decode_routine.html

http://macscripter.net/viewtopic.php?id=3675

If that doesn't work, here is the route of the "problem": https://github.com/adrianbj/TracyDebugger/blob/master/tracy/src/Tracy/Helpers.php#L49

Of course that is part of the Tracy core so I'd rather not edit it. I did however test with Sublime by removing the `rawurlencode` on that line and it works fine. Maybe if you can't get Eclipse to work, you could post on the Tracy forums to see if they would remove the encoding, although I expect it is important if there are spaces in the path?

I'd actually like to start compiling a list of resources for all of the various editors and platforms. I will add these to the module's readme as they are provided by you guys!

  • Like 1

Share this post


Link to post
Share on other sites

I see this in browser's View source:

</body>
</html>

?>

<!-- Tracy Debug Bar -->




<script>
(function() {...

There is unexpected "?>" but only in front end, not in backend. Also, is it ok to have script after the </html>?

Share this post


Link to post
Share on other sites

The position of the Tracy script after </html> might be a little weird - I am not sure their reasoning for this, but it's definitely a core Tracy thing, rather than an issue with this module. Take at look at their demo page and you'll notice the same thing: https://nette.github.io/tracy/tracy-exception.html

As for the extra "?>" - that looks to be related to the Variables panel - I am injecting code into the end of the compiled template files to make this work. I thought my regex was handling all scenarios, but perhaps not. Could you please try clearing your FileCompiler templates cache and let me know if the issue remains. If it does, please post the last few lines of your template file so I can test here and fix it.

  • Like 1

Share this post


Link to post
Share on other sites

Issue remains, but depends on template file:

<?php 
  echo $page->title;

is ok.

<?php 
  echo $page->title;
?>

is also ok.

<?php 
  echo $page->title;
?>
foo

is not ok.

Share this post


Link to post
Share on other sites

Thanks @matjazp - that helped - I had forgotten to consider text after the last closing php tag.

I have a fix that is working here. I have something else I am working on with Tracy right now so I'll commit both things fairly soon.

  • Like 2

Share this post


Link to post
Share on other sites

@matjazp - just letting you know that the latest version includes the fix for your problem. Could you please let me know if it works for you?

  • Like 1

Share this post


Link to post
Share on other sites

Yes, it works for me, I had to clean the templates cache.

One more thing: debug.innerHTML is "oneliner", with " \n\n" etc. How do you manage to debug that? :-)

  • Like 1

Share this post


Link to post
Share on other sites

Glad to hear it's working for you - hopefully this new approach will work in all scenarios.

As for debugging debug.innerHTML - I haven't had to debug it yet - it's mostly generated by Tracy anyway. Being a JS variable, there isn't really an easy way of making it multiline without concatenation, which really isn't worth the trouble in this case. I am looking forward to Template Literals in ES6 though - we'll finally have real multiline variables for JS.

But, back to your question, - if you do need to debug code like that you can use the regex find & replace option in your editor to replace \\n with \n and \\t with \t and it will be fully formatted.

In Sublime Text (in case you use that), click the asterisk in the find and replace box - super easy!

  • Like 1

Share this post


Link to post
Share on other sites

Small update that enhances links from the PW Info panel Summary section - now you can have shortcuts to either view (page name) or edit (page id) each of the linked pages that are related to the current page.

The children item now has:

  • an "open tree" link (opens this page in the page tree expanded to show all children)
  • an "edit" link (opens this page to the Children tab, which is particularly useful if you have Batch Child Editor installed).

The template filename in the Template Info section uses the defined editor protocol handler to open the file directly in your code editor.

Hopefully you'll all find these nice little time/click savers :)

post-985-0-62155000-1457205386_thumb.png

And page edit and template file edit buttons are also in the footer of this panel for instant access:

post-985-0-04478800-1457207052_thumb.png

  • Like 6

Share this post


Link to post
Share on other sites

New public method:

TD::templateVars()
templateVars()
tv()

Basically what this does is strip any system PW variables and returns just those that you have defined in your template file. It replicates what is output on the "Variables" panel, but lets you dump, barDump, fireLog, or log at whatever points you want throughout the execution of your template file script. Obviously if you are only interested in the changes to one variable there is no point in using this, but if you want to see how they all change, this is a nice shortcut.

It is really only designed to work with PHP's get_defined_vars()

Here's an example output via barDump: bd()

$i=0;
$x=10;
bd(tv(get_defined_vars()), 'breakpoint one');
$i++;
$x--;
bd(tv(get_defined_vars()), 'breakpoint two');

This results in:

post-985-0-34988500-1457279330_thumb.png

Without tv() in there it would include all PW variables/objects and it would be difficult to see the variables you are interested in.

Note that the templateVars() and tv() shortcuts/aliases may need to be turned on in the config settings if you are upgrading.

  • Like 4

Share this post


Link to post
Share on other sites

You can now click on the text of any entry in the PW and Tracy log panels to open the file in your code editor to the line number of the clicked entry.

Of course for this to work, you need to have properly configured your editor protocol handler.

Not really worthy of a screenshot, but still a very handy shortcut that I hope you'll find useful for when you have an log entry that has been truncated because it's too long for the built-in viewer.

  • Like 1

Share this post


Link to post
Share on other sites

Note: the links are to the actual original files, not the PW 3.x compiled versions !

Hello adrian,

Thank you very much again for the new feature!

I have just found the time to test out this protocol handler thingy, and with the following configuration string it seems to work well with PhpStorm Mac:

phpstorm://open?file=%file&line=%line

However, it does open the compiled file in cache instead of the original ones.

Do you have any ideas why?

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Gadgetto
      SnipWire - Snipcart integration for ProcessWire
      Snipcart is a powerful 3rd party, developer-first HTML/JavaScript shopping cart platform. SnipWire is the missing link between Snipcart and the content management framework ProcessWire.
      With SnipWire, you can quickly turn any ProcessWire site into a Snipcart online shop. The SnipWire plugin helps you to get your store up and running in no time. Detailed knowledge of the Snipcart system is not required.
      SnipWire is free and open source licensed under Mozilla Public License 2.0! A lot of work and effort has gone into development. It would be nice if you could donate an amount to support further development:

      Status update links (inside this thread) for SnipWire development
      2020-01-21 -- Snipcart v3 - when will the new cart system be implemented? 2020-01-19 -- integrated taxes provider finished (+ very flexible shipping taxes handling) 2020-01-14 -- new date range picker, discount editor, order notifiactions, order statuses, and more ... 2019-11-15 -- orders filter, order details, download + resend invoices, refunds 2019-10-18 -- list filters, REST API improvements, new docs platform, and more ... 2019-08-08 -- dashboard interface, currency selector, managing Orders, Customers and Products, Added a WireTabs, refinded caching behavior 2019-06-15 -- taxes provider, shop templates update, multiCURL implementation, and more ... 2019-06-02 -- FieldtypeSnipWireTaxSelector 2019-05-25 -- SnipWire will be free and open source Plugin Key Features
      Fast and simple store setup Full integration of the Snipcart dashboard into the ProcessWire backend (no need to leave the ProcessWire admin area) Browse and manage orders, customers, discounts, abandoned carts, and more Process refunds and send customer notifications from within the ProcessWire backend Process Abandoned Carts + sending messages to customers from within the ProcessWire backend Complete Snipcart webhooks integration (all events are hookable via ProcessWire hooks) Integrated taxes provider (which is more flexible then Snipcart own provider) Useful Links
      SnipWire in PW modules directory (alpha version only available via GitHub) SnipWire Docs (please note that the documentation is a work in progress) SnipWire @GitHub (feature requests and suggestions for improvement are welcome - I also accept pull requests) Snipcart Website  
      ---- INITIAL POST FROM 2019-05-25 ----
       
    • By d'Hinnisdaël
      Happy new year, everybody 🥬
      I've been sitting on this Dashboard module I made for a client and finally came around to cleaning it up and releasing it to the wider public. This is how it looks.
      ProcessWire Dashboard

      If anyone is interested in trying this out, please go ahead! I'd love to get some feedback on it. If this proves useful and survives some real-world testing, I'll add this to the module directory.
      Download
      You can find the latest release on Github.
      Documentation
      Check out the documentation to get started. This is where you'll find information about included panel types and configuration options.
      Custom Panels
      My goal was to make it really simple to create custom panels. The easiest way to do that is to use the panel type template and have it render a file in your templates folder. This might be enough for 80% of all use cases. For anything more complex (FormBuilder submissions? Comments? Live chat?), you can add new panel types by creating modules that extend the DashboardPanel base class. Check out the documentation on custom panels or take a look at the HelloWorld panel to get started. I'm happy to merge any user-created modules into the main repo if they might be useful to more than a few people.
       Disclaimer
      This is a pre-release version. Please treat it as such — don't install it on production sites. Just making sure 🍇
      Roadmap
      These are the things I'm looking to implement myself at some point. The wishlist is a lot longer, but those are the 80/20 items that I probably won't regret spending time on.
      Improve documentation & add examples ⚙️ Panel types Google Analytics ⚙️ Add new page  🔥 Drafts 🔥 At a glance / Page counter 404s  Layout options Render multiple tabs per panel panel groups with heading and spacing between ✅ panel wrappers as grid item (e.g. stacked notices) ✅ Admin themes support AdminThemeReno and AdminThemeDefault ✅ Shortcuts panel add a table layout with icon, title & summary ✅ Chart panel add default styles for common chart types ✅ load chart data from JS file (currently passed as PHP array) Collection panel support image columns ✅ add buttons: view all & add new ✅
    • By Robin S
      This module is inspired by and similar to the Template Stubs module. The author of that module has not been active in the PW community for several years now and parts of the code for that module didn't make sense to me, so I decided to create my own module. Auto Template Stubs has only been tested with PhpStorm because that is the IDE that I use.
      Auto Template Stubs
      Automatically creates stub files for templates when fields or fieldgroups are saved.
      Stub files are useful if you are using an IDE (e.g. PhpStorm) that provides code assistance - the stub files let the IDE know what fields exist in each template and what data type each field returns. Depending on your IDE's features you get benefits such as code completion for field names as you type, type inference, inspection, documentation, etc.
      Installation
      Install the Auto Template Stubs module.
      Configuration
      You can change the class name prefix setting in the module config if you like. It's good to use a class name prefix because it reduces the chance that the class name will clash with an existing class name.
      The directory path used to store the stub files is configurable.
      There is a checkbox to manually trigger the regeneration of all stub files if needed.
      Usage
      Add a line near the top of each of your template files to tell your IDE what stub class name to associate with the $page variable within the template file. For example, with the default class name prefix you would add the following line at the top of the home.php template file:
      /** @var tpl_home $page */ Now enjoy code completion, etc, in your IDE.

      Adding data types for non-core Fieldtype modules
      The module includes the data types returned by all the core Fieldtype modules. If you want to add data types returned by one or more non-core Fieldtype modules then you can hook the AutoTemplateStubs::getReturnTypes() method. For example, in /site/ready.php:
      // Add data types for some non-core Fieldtype modules $wire->addHookAfter('AutoTemplateStubs::getReturnTypes', function(HookEvent $event) { $extra_types = [ 'FieldtypeDecimal' => 'string', 'FieldtypeLeafletMapMarker' => 'LeafletMapMarker', 'FieldtypeRepeaterMatrix' => 'RepeaterMatrixPageArray', 'FieldtypeTable' => 'TableRows', ]; $event->return = $event->return + $extra_types; }); Credits
      Inspired by and much credit to the Template Stubs module by mindplay.dk.
       
      https://github.com/Toutouwai/AutoTemplateStubs
      https://modules.processwire.com/modules/auto-template-stubs/
    • By Mike Rockett
      Jumplinks for ProcessWire
      Release: 1.5.60
      Composer: rockett/jumplinks
      ⚠️ NOTICE: 1.5.60 is an important security patch-release for an XSS vulnerability discovered by @phlp. It's HIGHLY RECOMMENDED that all Jumplinks users update to the latest version as soon as possible.
      Jumplinks is an enhanced version of the original ProcessRedirects by Antti Peisa.
      The Process module manages your permanent and temporary redirects (we'll call these "jumplinks" from now on, unless in reference to redirects from another module), useful for when you're migrating over to ProcessWire from another system/platform. Each jumplink supports wildcards, shortening the time needed to create them.
      Unlike similar modules for other platforms, wildcards in Jumplinks are much easier to work with, as Regular Expressions are not fully exposed. Instead, parameters wrapped in curly braces are used - these are described in the documentation.
      Under Development: 2.0, to be powered by FastRoute
      As of version 1.5.0, Jumplinks requires at least ProcessWire 2.6.1 to run.
      View on GitLab
      Download via the Modules Directory
      Read the docs
      Features
      The most prominent features include:
      Basic jumplinks (from one fixed route to another) Parameter-based wildcards with "Smart" equivalents Mapping Collections (for converting ID-based routes to their named-equivalents without the need to create multiple jumplinks) Destination Selectors (for finding and redirecting to pages containing legacy location information) Timed Activation (activate and/or deactivate jumplinks at specific times) 404-Monitor (for creating jumplinks based on 404 hits) Additionally, the following features may come in handy:
      Stale jumplink management Legacy domain support for slow migrations An importer (from CSV or ProcessRedirects) Feedback & Feature Requests
      I’d love to know what you think of this module. Please provide some feedback on the module as a whole, or even regarding smaller things that make it whole. Also, please feel free to submit feature requests and their use-cases.
      Note: Features requested so far have been added to the to-do list, and will be added to 2.0, and not the current dev/master branches.
      Open Source

      Jumplinks is an open-source project, and is free to use. In fact, Jumplinks will always be open-source, and will always remain free to use. Forever. If you would like to support the development of Jumplinks, please consider making a small donation via PayPal.
      Enjoy! 🙂
    • By Robin S
      Add Image URLs
      Allows images/files to be added to Image/File fields by pasting URLs.

      Usage
      Install the Add Image URLs module.
      A "Paste URLs" button will be added to all image and file fields. Use the button to show a textarea where URLs may be pasted, one per line. Images/files are added when the page is saved.
       
      https://github.com/Toutouwai/AddImageUrls
      https://modules.processwire.com/modules/add-image-urls/
×
×
  • Create New...