The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

Installing Zend Z-Ray on Homestead

Published on by

Installing Zend Z-Ray on Homestead image

For the past week or so I have been running Zend Z-Ray in Laravel Homestead. Every time using it, new features come to light that are fantastic for debugging your apps in development! What follows is a quick preview of Z-Ray, along with all the steps necessary to install it on Laravel Homestead.

Overview

Z-Ray installs on the server, and will automatically load on all your projects on that particular server (in our case Homestead) automatically. Even better, it supports many major frameworks right out of the box, including: WordPress, ZendFramework (1 & 2), Magento, Drupal, with Symfony support on the way. (You can even extend it for your own Framework, if you like!)

This is very exciting for developers who have all their client sites in Homestead, regardless of the framework. The bottom line is that Z-Ray saves time and provides debugging tools without requiring you to install them in each project.

General Features of Z-Ray

![Page Requests lets you specify the context of the ZRay panel, allowing inspection of AJAX requests.](https://i2.wp.com/wp.laravel-news.com/media/2015/08/Screen-Shot-2015-08-21-at-13.34.52-e1440263274504.png?resize=525%2C142&ssl=1)
Page Requests lets you specify the context of the ZRay panel, allowing inspection of AJAX requests.
![Execution Time and Memory peak give you insight into server usage.](https://i1.wp.com/wp.laravel-news.com/media/2015/08/Screen-Shot-2015-08-21-at-13.37.33-e1440263685730.png?resize=525%2C145&ssl=1)
Execution Time and Memory peak give you insight into server usage.
![Errors & Warnings is pretty self-explanitory. However, notice that you can inspect @-silenced errors here as well!](https://i0.wp.com/wp.laravel-news.com/media/2015/08/Screen-Shot-2015-08-21-at-13.42.22-e1440263771998.png?resize=525%2C136&ssl=1)
Errors & Warnings is pretty self-explanitory. However, notice that you can inspect @-silenced errors here as well!
![Database Queries is one of the most useful features. And remember, you can inspect the queries of AJAX calls as well](https://i1.wp.com/wp.laravel-news.com/media/2015/08/Screen-Shot-2015-08-21-at-13.43.26-e1440263954118.png?resize=525%2C134&ssl=1)
Database Queries is one of the most useful features. And remember, you can inspect the queries of AJAX calls as well
![The Functions view lists all functions that are processed on any given request, providing insight into the execution chain.](https://i1.wp.com/wp.laravel-news.com/media/2015/08/Screen-Shot-2015-08-21-at-13.46.36-e1440264005108.png?resize=525%2C133&ssl=1)
The Functions view lists all functions that are processed on any given request, providing insight into the execution chain.
![Request Info tab displays the usual request information we can see in modern browser inspection panels. It also includes PHP super-globals, which is super helpful!](https://i0.wp.com/wp.laravel-news.com/media/2015/08/Screen-Shot-2015-08-21-at-13.51.00-e1440264037105.png?resize=525%2C135&ssl=1)
Request Info tab displays the usual request information we can see in modern browser inspection panels. It also includes PHP super-globals, which is super helpful!
### Laravel Features in Z-Ray
![General Laravel project information.](https://i0.wp.com/wp.laravel-news.com/media/2015/08/Screen-Shot-2015-08-21-at-13.52.57-e1440264174768.png?resize=525%2C151&ssl=1)
General Laravel project information.
![Route inspection providing you with everything you need to know about the route hit by the selected request.](https://i0.wp.com/wp.laravel-news.com/media/2015/08/Screen-Shot-2015-08-21-at-13.54.55-e1440264214331.png?resize=525%2C151&ssl=1)
Route inspection providing you with everything you need to know about the route hit by the selected request.
![The Session inspector lists all the pertinent data, including any errors or messages.](https://i0.wp.com/wp.laravel-news.com/media/2015/08/Screen-Shot-2015-08-21-at-13.56.06-e1440264241436.png?resize=525%2C151&ssl=1)
The Session inspector lists all the pertinent data, including any errors or messages.
![User Information — while self-explanatory, definitely useful for debugging and inspecting anything Auth::user related.](https://i1.wp.com/wp.laravel-news.com/media/2015/08/Screen-Shot-2015-08-21-at-13.57.55-e1440264281426.png?resize=525%2C151&ssl=1)
User Information — while self-explanatory, definitely useful for debugging and inspecting anything Auth::user related.
![Views gives you insight into which views are rendered, including details as to the path of the view, and which variables are passed into the views (along with the values, of course).](https://i2.wp.com/wp.laravel-news.com/media/2015/08/Screen-Shot-2015-08-21-at-13.59.15-e1440264310511.png?resize=525%2C150&ssl=1)
Views gives you insight into which views are rendered, including details as to the path of the view, and which variables are passed into the views (along with the values, of course).
![Events Log makes event debugging easy! Check out which events were fired, and in which order](https://i1.wp.com/wp.laravel-news.com/media/2015/08/Screen-Shot-2015-08-21-at-14.00.45-e1440264337722.png?resize=525%2C150&ssl=1)
Events Log makes event debugging easy! Check out which events were fired, and in which order
### Admin Panel

The admin panel can be easily accessed from the Z-Ray bar itself via the right hamburger menu and selecting “Settings”, or you can browse any of your homestead sites with the admin port 10081, for example http://example.dev:10081/.

![Z-Ray’s admin panel provides a wealth of information and configuration options. The home page gives a nice overview of the features.](https://i2.wp.com/wp.laravel-news.com/media/2015/08/Screen-Shot-2015-08-22-at-08.04.50-e1440264405326.png?resize=525%2C343&ssl=1)
Z-Ray’s admin panel provides a wealth of information and configuration options. The home page gives a nice overview of the features.
![Z-Ray Live! is an interesting features that lets you monitor live activity on your site. This could be useful for behind-the-scenes monitoring of events on live servers.](https://i2.wp.com/wp.laravel-news.com/media/2015/08/Screen-Shot-2015-08-22-at-08.05.12-e1440264483653.png?resize=525%2C160&ssl=1)
Z-Ray Live! is an interesting features that lets you monitor live activity on your site. This could be useful for behind-the-scenes monitoring of events on live servers.
![Access Mode lets you configure how you want Z-Ray to appear on your server, including hiding it from the site front-end, while still collecting data in Z-Ray Live!](https://i2.wp.com/wp.laravel-news.com/media/2015/08/Screen-Shot-2015-08-22-at-08.05.29-e1440264513411.png?resize=525%2C243&ssl=1)
Access Mode lets you configure how you want Z-Ray to appear on your server, including hiding it from the site front-end, while still collecting data in Z-Ray Live!
![Here you can inspect previous HTTP requests.](https://i0.wp.com/wp.laravel-news.com/media/2015/08/Screen-Shot-2015-08-22-at-08.05.44-e1440264539717.png?resize=525%2C130&ssl=1)
Here you can inspect previous HTTP requests.
![The Settings page lets you further fine-tune how Z-Ray operates on your server.](https://i0.wp.com/wp.laravel-news.com/media/2015/08/Screen-Shot-2015-08-22-at-08.05.58-e1440264565900.png?resize=525%2C249&ssl=1)
The Settings page lets you further fine-tune how Z-Ray operates on your server.
Installation ------------

Requirements

Guide

SSH into your homestead environment, and make sure you are in your home folder:

homestead ssh
cd ~

Let’s download Z-Ray:

wget http://downloads.zend.com/zray/1208/zray-php5.6-Ubuntu-14.04-x86_64.tar.gz

Enter super-user mode:

sudo su

Unzip the archive:

tar xvfz zray-php5.6-Ubuntu-14.04-x86_64.tar.gz -C /opt

Create a new file /etc/nginx/conf.d/zray.conf:

server {
listen 10081 default_server;
server_name _;
server_name_in_redirect off;
root /opt/zray/gui/public;
index index.php index.html index.htm;
location ~ ^/ZendServer/(.+)$ {
try_files /$1 /index.php?$args;
}
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}

Create symlinks to PHP configurations:

ln -sf /opt/zray/zray.ini /etc/php5/cli/conf.d/zray.ini
ln -sf /opt/zray/zray.ini /etc/php5/fpm/conf.d/zray.ini

Verify Z-Ray is running:

php -v

Inside the with sections you should see Z-Ray listed:

with Zend Server Z-Ray v8.5.0

Now, we need to set permissions on the Z-Ray files so the web server can access them:

chown -R vagrant:vagrant /opt/zray

And finally, lets restart NGINX:

service nginx restart

You can now exit out of super-user mode (CTRL-D). Before we leave Homestead, let’s clean up after ourselves:

cd ~
rm -rf zray*

And now exit out of homestead (CTRL-D again). We’re almost there. We just need to edit the Homestead configuration to open the Z-Ray admin port:

homestead edit

And add the following lines under the cpus directive:

ports:
- send: 10081
to: 10081

Let’s restart and provision Homestead:

homestead halt
homestead up --provision

Now simply access any of your homestead sites like you normally would under port 8000, and you should see the Z-Ray bar at the bottom.

If Z-Ray does not load and you are getting a 500 error in your browser console, it may be necessary to re-apply the permissions to the Z-Ray folder:

homestead ssh
sudo chown -R vagrant:vagrant /opt/zray

When done, hit CTRL-D or type exit to leave homestead, and try loading it in your browser again. This should fix it.


Uninstallation

To uninstall it, we simply reverse the process:

sudo -i
rm /etc/php5/cli/conf.d/zray.ini
rm /etc/php5/fpm/conf.d/zray.ini
rm /etc/nginx/conf.d/zray.conf
rm -rf /opt/zray

Now exit out of Homestead and remove the 10081 port from your Homestead.yml file. After that, halt and restarting Homestead should be the finishing touch.

homestead halt && homestead up

I want to thank Zeev Suraski from Zend for inviting me to test-drive their tech preview of the stand-alone version of Z-Ray.

We would love to hear about your experiences with Z-Ray! Do you like it? Does it improve your development workflow? Let us know.

Mike Bronner photo

Husband. Genealogist. Web Designer. Translator. German-American.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Jump24 - UK Laravel Agency

Laravel Developers that Click into Place. Never outsourced. Never offshored. Always exceptional.

Visit Jump24 - UK Laravel Agency
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit

The latest

View all →
The Laravel Community Mobile App Helps You Discover Events and Connect With Developers image

The Laravel Community Mobile App Helps You Discover Events and Connect With Developers

Read article
A PHP Package for Concurrent Website Crawling image

A PHP Package for Concurrent Website Crawling

Read article
A Clean API for Reading PHP Attributes image

A Clean API for Reading PHP Attributes

Read article
Serve Markdown Versions of Your Laravel Pages to AI Agents image

Serve Markdown Versions of Your Laravel Pages to AI Agents

Read article
The Inertia v3 Beta is Here image

The Inertia v3 Beta is Here

Read article
Polyscope Is an Ai-First Dev Environment for Orchestrating Agents image

Polyscope Is an Ai-First Dev Environment for Orchestrating Agents

Read article