Download the PHP package tracy/tracy without Composer

On this page you can find all versions of the php package tracy/tracy. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package tracy

Tracy

Downloads this Month Tests Build Status Windows Latest Stable Version License

 <!---->

Introduction

Tracy library is a useful helper for everyday PHP programmers. It helps you to:

✅ designed to facilitate debugging PHP code
✅ hints and corrects you just like a good friend watching your back
✅ damn cool visualization of errors

PHP is a perfect language for making hardly detectable errors because it gives great flexibility to programmers. Tracy\Debugger is more valuable because of that. It is an ultimate tool among the diagnostic ones.

If you are meeting Tracy for the first time, believe me, your life starts to be divided into one before the Tracy and the one with her. Welcome to the good part!

Documentation can be found on the website.

 <!---->

Support Tracy

Do you like Tracy? Are you looking forward to the new features?

Buy me a coffee

Thank you!

 <!---->

Installation and Requirements

The recommended way to is via Composer:

Alternatively, you can download the whole package or tracy.phar file.

Tracy is compatible with PHP 8.1 to 8.4.

 <!---->

Usage

Tracy is activated by calling the `Tracy\Debugger::enable()' method as soon as possible at the beginning of the program, before any output is sent:

The first thing you'll notice on the page is the Tracy Bar in the bottom right corner. If you don't see it, it may mean that Tracy is running in production mode. This is because Tracy is only visible on localhost for security reasons. To test if it works, you can temporarily put it into development mode using the Debugger::enable(Debugger::Development) parameter.

 <!---->

Tracy Bar

The Tracy Bar is a floating panel. It is displayed in the bottom right corner of a page. You can move it using the mouse. It will remember its position after the page reloading.

Debugger-Bar

You can add other useful panels to the Tracy Bar. You can find interesting ones in addons or you can create your own.

If you do not want to show Tracy Bar, set:

 <!---->

Visualization of Errors and Exceptions

Surely, you know how PHP reports errors: there is something like this in the page source code:

or uncaught exception:

It is not so easy to navigate through this output. If you enable Tracy, both errors and exceptions are displayed in a completely different form:

Uncaught exception rendered by Tracy

The error message literally screams. You can see a part of the source code with the highlighted line where the error occurred. A message clearly explains an error. The entire site is interactive, try it.

And you know what? Fatal errors are captured and displayed in the same way. No need to install any extension (click for live example):

Fatal error rendered by Tracy

Errors like a typo in a variable name or an attempt to open a nonexistent file generate reports of E_NOTICE or E_WARNING level. These can be easily overlooked and/or can be completely hidden in a web page graphic layout. Let Tracy manage them:

Notice rendered by Tracy

Or they may be displayed like errors:

Notice rendered by Tracy

Note: Tracy when activated changes the error reporting level to E_ALL. If you want to change this, do so after calling enable().

 <!---->

Development vs Production Mode

As you can see, Tracy is quite talkative, which can be appreciated in the development environment, while on the production server it would cause a disaster. That's because no debugging information should be displayed there. Tracy therefore has environment auto-detection and if the example is run on a live server, the error will be logged instead of displayed, and the visitor will only see a user-friendly message:

Server Error 500

Production mode suppresses the display of all debugging information sent out using [dump() |dumper], and of course also all error messages generated by PHP. So if you have forgotten some dump($obj) in the code, you don't have to worry, nothing will be displayed on the production server.

How does mode auto-detection work? The mode is development if the application is running on localhost (i.e., IP address 127.0.0.1 or ::1) and there is no proxy (i.e., its HTTP header). Otherwise, it runs in production mode.

If you want to enable development mode in other cases, for example for developers accessing from a specific IP address, you can specify it as a parameter of the enable() method:

We definitely recommend combining the IP address with a cookie. Store a secret token, e.g., secret1234, in the tracy-debug cookie, and in this way, activate the development mode only for developers accessing from a specific IP address who have the mentioned token in the cookie:

You can also directly set the development/production mode using the Debugger::Development or Debugger::Production constants as a parameter of the enable() method.

(If you use the Nette Framework, take a look at how to set the mode for it, and it will then also be used for Tracy.)

 <!---->

Error Logging

In production mode, Tracy automatically logs all errors and exceptions to a text log. In order for logging to take place, you need to set the absolute path to the log directory to the $logDirectory variable or pass it as the second parameter to enable() method:

Error logging is extremely useful. Imagine that all users of your application are actually beta testers who do top-notch work in finding errors for free, and you would be foolish to throw their valuable reports away unnoticed into the trash bin.

If you need to log your own messages or caught exceptions, use the method log():

If you want Tracy to log PHP errors like E_NOTICE or E_WARNING with detailed information (HTML report), set Debugger::$logSeverity:

For a real professional the error log is a crucial source of information and he or she wants to be notified about any new error immediately. Tracy helps him. She is capable of sending an email for every new error record. The variable $email identifies where to send these e-mails:

(If you use the Nette Framework, you can set this and others in the configuration file.)

To protect your e-mail box from flood, Tracy sends only one message and creates a file email-sent. When a developer receives the e-mail notification, he checks the log, corrects his application and deletes the email-sent monitoring file. This activates the e-mail sending again.

 <!---->

Opening Files in the Editor

When the error page is displayed, you can click on file names and they will open in your editor with the cursor on the corresponding line. Files can also be created (action create file) or bug fixed in them (action fix it). In order to do this, you need to configure the browser and the system.

 <!---->

Variable Dumping

Every debugging developer is a good friend with the function var_dump, which lists all contents of any variable in detail. Unfortunately, its output is without HTML formatting and outputs the dump into a single line of HTML code, not to mention context escaping. It is necessary to replace the var_dump with a more handy function. That is just what dump() is.

generates the output:

dump

You can change the default light theme to dark:

dump

You can also change the nesting depth by Debugger::$maxDepth and displayed strings length by Debugger::$maxLength. Naturally, lower values accelerate Tracy rendering.

The dump() function can display other useful information. Tracy\Dumper::LOCATION_SOURCE adds a tooltip with path to the file, where the function was called. Tracy\Dumper::LOCATION_LINK adds a link to the file. Tracy\Dumper::LOCATION_CLASS adds a tooltip to every dumped object containing path to the file, in which the object's class is defined. All these constants can be set in Debugger::$showLocation variable before calling the dump(). You can set multiple values at once using the | operator.

Very handy alternative to dump() is dumpe() (ie. dump and exit) and bdump(). This allows us to dump variables in Tracy Bar. This is useful, because dumps don't mess up the output and we can also add a title to the dump.

bar dump

 <!---->

Stopwatch

Another useful tool is the debugger stopwatch with a precision of microseconds:

Multiple measurements at once can be achieved by an optional parameter.

 <!---->

Custom Logger

We can create a custom logger to log errors, uncatched exceptions, and also be called by Tracy\Debugger::log(). Logger implements the interface Tracy\ILogger.

And then we activate it:

If we use the full Nette Framework, we can set it in the NEON configuration file:

 <!---->

Monolog Integration

This package provides a PSR-3 adapter, allowing for integration of monolog/monolog.

 <!---->

Faster Loading

The basic integration is straightforward, however if you have slow blocking scripts in web page, they can slow the Tracy loading. The solution is to place `` into your template before any scripts:

 <!---->

AJAX and Redirected Requests

Tracy can display Debug bar and Bluescreens for AJAX requests and redirects. Tracy creates its own sessions, stores data in its own temporary files, and uses a tracy-session cookie.

Tracy can also be configured to use a native PHP session, which is started before Tracy is turned on:

In case starting a session requires more complex initialization, you can start Tracy immediately (so that it can handle any errors that occur) and then initialize the session handler and finally inform Tracy that the session is ready to be used using the dispatch() function:

The setSessionStorage() function has existed since version 2.9, before that Tracy always used the native PHP session.

 <!---->

Content Security Policy

If your site uses Content Security Policy, you'll need to add 'nonce-<value>' and 'strict-dynamic' to script-src for Tracy to work properly. Some 3rd plugins may require additional directives. Nonce is not supported in the style-src directive, if you use this directive you need to add 'unsafe-inline', but this should be avoided in production mode.

Configuration example for Nette Framework:

Example in pure PHP:

nginx

If Tracy does not work on nginx, it is probably misconfigured. If there is something like

change it to

 <!---->

Integrations

This is a list of unofficial integrations to other frameworks and CMS:

... feel free to be famous, create an integration for your favourite platform!


All versions of tracy with dependencies

PHP Build Version
Package Version
Requires php Version 8.0 - 8.4
ext-session Version *
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tracy/tracy contains the following files

Loading the files please wait ....