Homestead Welcomes Z-Ray by Zend
Joe • February 6, 2018
devops laravel linux php projects zend zraySince the release of Homestead version 7.1.0 and base box version 5.1.0 Homestead now supports the Zend Z-Ray plugin for PHP 7.2. You can start leveraging the power of Z-Ray in your application with a small changes to your Homestead project.
First make sure you have updated Homestead to v7.1.0 of the Homestead repo and version 5.1.0 of the base box. You can check what versions of the base box you have by running `vagrant box list`, or upgrade automatically by running `vagrant box update` you should see similar output to below:
==> homestead: Checking for updates to 'laravel/homestead'
homestead: Latest installed version: 5.0.1
homestead: Version constraints: >= 4.0.0
homestead: Provider: virtualbox
==> homestead: Updating 'laravel/homestead' with provider 'virtualbox' from version
==> homestead: '5.0.1' to '5.1.0'...
==> homestead: Loading metadata for box 'https://vagrantcloud.com/laravel/homestead?access_token=YLPhovCPR0G9Lgbs9U'
==> homestead: Adding box 'laravel/homestead' (v5.1.0) for provider: virtualbox
homestead: Downloading: https://vagrantcloud.com/laravel/boxes/homestead/versions/5.1.0/providers/virtualbox.box
==> homestead: Successfully added box 'laravel/homestead' (v5.1.0) for 'virtualbox'!
Now we're ready to add the Z-Ray flag to our Homestead.yaml file for the site we want to use Z-Ray with.
Homestead.yaml:
---
ip: "192.168.10.10"
memory: 2048
cpus: 2
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/PhpstormProjects/quickstart-5.5
to: /home/vagrant/qs
sites:
- map: qs.test
to: /home/vagrant/qs/public
zray: 'true'
databases:
- homestead
Note that true must be enclosed in quotes as a string or you will get configuration file errors when running vagrant commands.
Make sure you have run `vagrant destroy` so the next step picks up the new version of the base box.
The next step is to run `vagrant up`:
Bringing machine 'homestead-7' up with 'virtualbox' provider...
==> homestead-7: Importing base box 'laravel/homestead'...
==> homestead-7: Matching MAC address for NAT networking...
==> homestead-7: Checking if box 'laravel/homestead' is up to date...
==> homestead-7: Setting the name of the VM: homestead-7
==> homestead-7: Clearing any previously set network interfaces...
==> homestead-7: Preparing network interfaces based on configuration...
homestead-7: Adapter 1: nat
homestead-7: Adapter 2: hostonly
==> homestead-7: Forwarding ports...
homestead-7: 80 (guest) => 8000 (host) (adapter 1)
homestead-7: 443 (guest) => 44300 (host) (adapter 1)
homestead-7: 3306 (guest) => 33060 (host) (adapter 1)
homestead-7: 4040 (guest) => 4040 (host) (adapter 1)
homestead-7: 5432 (guest) => 54320 (host) (adapter 1)
homestead-7: 8025 (guest) => 8025 (host) (adapter 1)
homestead-7: 27017 (guest) => 27017 (host) (adapter 1)
homestead-7: 22 (guest) => 2222 (host) (adapter 1)
==> homestead-7: Running 'pre-boot' VM customizations...
==> homestead-7: Booting VM...
==> homestead-7: Waiting for machine to boot. This may take a few minutes...
homestead-7: SSH address: 127.0.0.1:2222
homestead-7: SSH username: vagrant
homestead-7: SSH auth method: private key
homestead-7: Warning: Connection reset. Retrying...
homestead-7:
homestead-7: Vagrant insecure key detected. Vagrant will automatically replace
homestead-7: this with a newly generated keypair for better security.
homestead-7:
homestead-7: Inserting generated public key within guest...
homestead-7: Removing insecure key from the guest if it's present...
homestead-7: Key inserted! Disconnecting and reconnecting using new SSH key...
==> homestead-7: Machine booted and ready!
==> homestead-7: Checking for guest additions in VM...
homestead-7: The guest additions on this VM do not match the installed version of
homestead-7: VirtualBox! In most cases this is fine, but in rare cases it can
homestead-7: prevent things such as shared folders from working properly. If you see
homestead-7: shared folder errors, please make sure the guest additions within the
homestead-7: virtual machine match the version of VirtualBox you have installed on
homestead-7: your host and reload your VM.
homestead-7:
homestead-7: Guest Additions Version: 5.0.18_Ubuntu r106667
homestead-7: VirtualBox Version: 5.2
==> homestead-7: Setting hostname...
==> homestead-7: Configuring and enabling network interfaces...
==> homestead-7: Mounting shared folders...
homestead-7: /vagrant => /Users/joeferguson/PhpstormProjects/homestead
homestead-7: /home/vagrant/qs => /Users/joeferguson/PhpstormProjects/quickstart-5.5
==> homestead-7: Running provisioner: file...
==> homestead-7: Running provisioner: shell...
homestead-7: Running: inline script
==> homestead-7: Running provisioner: shell...
homestead-7: Running: inline script
homestead-7:
homestead-7: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDBeub1sTnpX7Tp7f0ukLAz7dMn7CS9w6eHmc1wtJNp/iXHzyBRKZ+ov8z+voCVJOrSDyTsG0IKcby8+UxwpzR2nyqiBPw+oaSD1elIHFS48h7Wd5f41S6QeHUlhac20fa5EHTnNw9jphtxDuYPa+xiaNdbdvJKC1jZuipsqc4qlcDC1LISOtIsAzMF1fnByWEe3JBvRxvCmegruu424chIGG23elIoBHsOvY/6BI+5G2BNSBvqzHxfQ2mK6j4tEj2K2s+4M3r4FrgZIYgHxxZtADdNGwditFu5ipfaQSc1n5YFQiI87iTO5OZCBdffMY3qQWaE3ne+hAVDSdJLWFDn halo@mobile-rage-work
==> homestead-7: Running provisioner: shell...
homestead-7: Running: inline script
==> homestead-7: Running provisioner: shell...
homestead-7: Running: /var/folders/7s/nblvjylx1l1ch16cg6cgsh7r0000gp/T/vagrant-shell20180206-6038-l2fuxq.sh
==> homestead-7: Running provisioner: shell...
homestead-7: Running: script: Creating Certificate: qs.test
==> homestead-7: Running provisioner: shell...
homestead-7: Running: script: Creating Site: qs.test
==> homestead-7: Running provisioner: shell...
homestead-7: Running: inline script
==> homestead-7: Running provisioner: shell...
homestead-7: Running: script: Checking for old Schedule
==> homestead-7: Running provisioner: shell...
homestead-7: Running: script: Clear Variables
==> homestead-7: Running provisioner: shell...
homestead-7: Running: script: Restarting Cron
==> homestead-7: Running provisioner: shell...
homestead-7: Running: script: Restarting Nginx
==> homestead-7: Running provisioner: shell...
homestead-7: Running: script: Creating MySQL Database: homestead
==> homestead-7: Running provisioner: shell...
homestead-7: Running: script: Creating Postgres Database: homestead
==> homestead-7: Running provisioner: shell...
homestead-7: Running: script: Update Composer
homestead-7: You are running composer as "root", while "/home/vagrant/.composer" is owned by "vagrant"
homestead-7: You are already using composer version 1.6.3 (stable channel).
==> homestead-7: Running provisioner: shell...
homestead-7: Running: /var/folders/7s/nblvjylx1l1ch16cg6cgsh7r0000gp/T/vagrant-shell20180206-6038-no2tdf.sh
==> homestead-7: Running provisioner: shell...
homestead-7: Running: /var/folders/7s/nblvjylx1l1ch16cg6cgsh7r0000gp/T/vagrant-shell20180206-6038-hjcd.sh
Now we can run `vagrant ssh` to enter the machine and look at our mapped folder in `/home/vagrant/qs`. Since this is a Laravel application I have a `public` folder which is the HTTP entry point into the application. When Z-Ray is set to true Homestead will create a symbolic link in this public root folder pointing to where the Z-Ray files are in the virtual machine:
vagrant@homestead:~/qs$ cd public/
vagrant@homestead:~/qs/public$ ll
total 16
drwxr-xr-x 1 vagrant vagrant 352 Feb 6 16:56 ./
drwxr-xr-x 1 vagrant vagrant 1088 Jan 9 01:29 ../
drwxr-xr-x 1 vagrant vagrant 96 Nov 6 19:07 css/
-rw-r--r-- 1 vagrant vagrant 0 Nov 6 19:07 favicon.ico
drwxr-xr-x 1 vagrant vagrant 96 Nov 6 20:07 fonts/
-rw-r--r-- 1 vagrant vagrant 597 Nov 6 19:07 .htaccess
-rw-r--r-- 1 vagrant vagrant 1833 Feb 5 20:06 index.php
drwxr-xr-x 1 vagrant vagrant 96 Nov 6 19:07 js/
-rw-r--r-- 1 vagrant vagrant 70 Nov 6 20:07 mix-manifest.json
-rw-r--r-- 1 vagrant vagrant 24 Nov 6 19:07 robots.txt
lrwxr-xr-x 1 vagrant vagrant 20 Feb 6 16:56 ZendServer -> /opt/zray/gui/public/
vagrant@homestead:~/qs/public$
Now we can browse our site's url and see Z-Ray in action:
An important note is that you must use your application's URL from the Homestead.yaml configuration file. Navigating to localhost on port 8000 will cause Z-Ray to throw errors.
For my test application I have a basic authentication scheme set up where we can register a new user and load a page. Once we register we can see the home screen that a logged in user is presented with and Z-Ray shows us a lot of data about this page load. One of the things I use Z-Ray for is to make sure my page loads are not doing a large number of queries. In this screenshot you can see the queries that the application ran to build the page:
Now we're free to explore the many other features Z-Ray has. We've only scratched the surface here but you can find out much more about Z-Ray on the Zend Z-Ray site.
As Seen On
Recent Posts
- PHP to Rust via Copilot
- Compiling Python 3.12 from Source Tarball on Linux
- HTML Form Processing with PHP - php[architect] Magazine August 2014
- The Workshop: Local Dev with Lando - php[architect] Magazine November 2022
- Getting back into the swing of things
- All Posts
Categories
- ansible
- apache
- applesilicon
- aws
- blackwidow
- cakephp
- community
- composer
- conferences
- copilot
- data-storage
- day-job
- devops
- docker
- fpv
- general
- github
- givecamp
- homestead
- jigsaw
- joindin
- keyboard
- laravel
- learning
- linux
- maker
- mamp
- mentoring
- music
- nonprofit
- opensource
- packages
- php
- phparch
- projects
- provisioning
- python
- razer
- rust
- s3
- security
- slimphp
- speaking
- static-sites
- storage
- testing
- tiny-whoop
- today-i-learned
- training
- ubuntu
- vagrant
- version-control
- windows
- writing
- wsl
- wsl2
- zend-zray