我正在尝试配置xdebug以在PhpStorm中使用我的Vagrant VM。我尝试使用this guide,但无济于事。 我已经在我的Vagrant盒子上安装了xdebug,盒子也注册并配置了PhpStorm
我尝试使用Laravel设置断点并在此基本测试函数上运行调试器:
Route::get('/test', function()
{
$a = [1, 2, 3, 4, 5];
array_pop($a);
return 'hello';
});
但它失败并显示以下错误消息:
vagrant://C:\Users\johndoe\Desktop\myproject/usr/bin/php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=10.0.2.2 /vagrant/app/routes.php
PHP Fatal error: Class 'Route' not found in /vagrant/app/routes.php on line 6
PHP Stack trace:
PHP 1. {main}() /vagrant/app/routes.php:0
Process finished with exit code 255
我也试过在我的一个控制器上的一个函数上运行它但是它给出了类似的错误
vagrant://C:\Users\johndoe\Desktop\myproject/usr/bin/php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=10.0.2.2 /vagrant/app/controllers/MyController.php
PHP Fatal error: Class 'BaseController' not found in /vagrant/app/controllers/MyController.php on line 15
PHP Stack trace:
PHP 1. {main}() /vagrant/app/controllers/MyController.php:0
Process finished with exit code 255
/etc/php5/conf.d/20-xdebug.ini:
zend_extension=/usr/lib/php5/20100525/xdebug.so
xdebug.remote_enable = on
xdebug.remote_connect_back = on
xdebug.idekey = "vagrant"
Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Config Github Settings
github_username = "johndoe"
github_repo = "myrepo"
github_branch = "master"
# Server Configuration
# Set a local private network IP address.
# See http://en.wikipedia.org/wiki/Private_network for explanation
# You can use the following IP ranges:
# 10.0.0.1 - 10.255.255.254
# 172.16.0.1 - 172.31.255.254
# 192.168.0.1 - 192.168.255.254
server_ip = "192.168.22.10"
server_memory = "384" # MB
server_timezone = "UTC"
# HHVM Options
hhvm_use_fastcgi = "false" # Use HHVM as FastCGI (over php-fpm)
hhvm_over_php = "false" # Symlink HHVM to PHP, so calls to PHP run via HHVM
# PHP Options
php_version = "previous" # Options: latest|previous|distributed For 12.04. latest=5.5, previous=5.4, distributed=5.3
public_folder = "" # If installing Symfony or Laravel, leave this blank to default to the framework public directory
laravel_version = "4.1.27"
laravel_root_folder = "/vagrant/laravel" # Where to install Laravel. Will `composer install` if a composer.json file exists
symfony_root_folder = "/vagrant/symfony" # Where to install Symfony.
Vagrant.configure("2") do |config|
# Set server to Ubuntu 12.04
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
# Create a hostname, don't forget to put it to the `hosts` file
# This will point to the server's default virtual host
# TO DO: Make this work with virtualhost along-side xip.io URL
config.vm.hostname = "vaprobash.dev"
# Create a static IP
config.vm.network :private_network, ip: server_ip
# If using VirtualBox
config.vm.provider :virtualbox do |vb|
# Set server memory
vb.customize ["modifyvm", :id, "--memory", server_memory]
# Set the timesync threshold to 10 seconds, instead of the default 20 minutes.
# If the clock gets more than 15 minutes out of sync (due to your laptop going
# to sleep for instance, then some 3rd party services will reject requests.
vb.customize ["guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 10000]
end
# If using VMWare Fusion
config.vm.provider "vmware_fusion" do |vb, override|
override.vm.box_url = "http://files.vagrantup.com/precise64_vmware.box"
# Set server memory
vb.vmx["memsize"] = server_memory
end
# If using Vagrant-Cachier
# http://fgrehm.viewdocs.io/vagrant-cachier
if Vagrant.has_plugin?("vagrant-cachier")
# Configure cached packages to be shared between instances of the same base box.
# Usage docs: http://fgrehm.viewdocs.io/vagrant-cachier/usage
config.cache.scope = :box
config.cache.synced_folder_opts = {
type: :nfs,
mount_options: ['rw', 'vers=3', 'tcp', 'nolock']
}
end
####
# Base Items
##########
# Provision Base Packages
config.vm.provision "shell", path: "https://raw.github.com/#{github_username}/#{github_repo}/#{github_branch}/scripts/base.sh"
# Provision PHP
config.vm.provision "shell", path: "https://raw.github.com/#{github_username}/#{github_repo}/#{github_branch}/scripts/php.sh", args: [php_version, server_timezone]
####
# Web Servers
##########
# Provision Apache Base
config.vm.provision "shell", path: "https://raw.github.com/#{github_username}/#{github_repo}/#{github_branch}/scripts/apache.sh", args: [server_ip, public_folder]
####
# Frameworks and Tooling
##########
# Provision Composer
config.vm.provision "shell", path: "https://raw.github.com/#{github_username}/#{github_repo}/#{github_branch}/scripts/composer.sh", privileged: false, args: composer_packages.join(" ")
# Provision Laravel
#config.vm.provision "shell", path: "https://raw.github.com/#{github_username}/#{github_repo}/#{github_branch}/scripts/laravel.sh", privileged: false, args: [server_ip, laravel_root_folder, public_folder, laravel_version]
end
PhpStorm版本:8.0.2
似乎xdebug无法读取任何Laravel类/外观。我该怎么做才能解决这个问题,以便我可以使用xdebug?