Z-Ray Tip #4: Getting Rid of It!

      10 Comments on Z-Ray Tip #4: Getting Rid of It!

Now, why would any sane PHP developer want to do that?!

Well, while Z-Ray is a great friend to have when developing your apps, there are just some parties you don’t want it to show up at.

You might be using PHP scripts for accessing static pages. Or, you might not want Z-Ray to be displayed for one specific request. In production, you most definitely don’t want Z-Ray popping up for users using your app!

There are numerous ways to disable Z-Ray both in development and in production to make sure your development workflow is not interrupted and your live apps are not affected. Here are a few of them.

It’s worth mentioning that some of these methods merely disable the injection of Z-Ray into the page open in your browser but the actual data is still collected by Z-Ray behind the scenes and is available for inspection in other Z-Ray and Zend Server features. Other methods totally decapitate Z-Ray’s functionality, both removing Z-Ray from your browser but also stopping data collection.

In development

In development, you will most likely have Z-Ray in Enabled mode. This means that data is collected for any and every request made to the web server, and that Z-Ray is displayed on all pages open in a browser. Here are some ways to circumvent that setting.

Using API

If you have some pages that you do not need Z-Ray for – say a login page or a page you know is 100% bug proof (is there such a thing?), you can insert an API into your application’s code to disable Z-Ray.

You can either disable both the injection of Z-Ray into your browser and data collection using:

Or, you can disable the injection of Z-Ray into your browser but still retain data collection using:

The latter enables you to use additional Z-Ray features to debug your applications (Z-Ray Live!, URL Insight, and more).

Using a GET parameter

In some situations, Z-Ray might be disturbing your development process. For example, you may be working on the bottom section of a page and Z-Ray is blocking your view.  In these cases, you can easily disable Z-Ray for a specific request by passing the following GET parameter in the URL:

Using a header

Another way to disable Z-Ray is by sending the following request header:

From Z-Ray

You can of course also minimize Z-Ray or close it on the page open in your browser using the menu items in Z-Ray itself.

The “Disable” option in the menu is discussed in the next section.

closing_z-rayIn production

While Z-Ray is ideal for development, it can be used safely in production as well.

In Disabled mode,  Z-Ray data collection is disabled and Z-Ray is not displayed on pages open in a browser and or in  Z-Ray Live! This ensures your live apps are not affected, and your users will not get an unexpected component popping up at the bottom of their pages.

In Selective mode, Z-Ray is only displayed for requests made by specific IPs, for specific URLs and a defined time period. This allows you to safely inspect live client requests in production. More information on using this mode here.

These modes can be turned on and off from the Zend Server UI, or the Z-Ray management dashboard if you’re using the Z-Ray standalone tech preview (Z-Ray | Access Mode).