Eclipse PDT PHP Web Application Run Configuration

Haidong Ji 2016-01-02 13:39

I had some trouble setting up Run Configurations in Eclipse for PHP (PDT plugin). Here is my note for future reference.

Machine: Ubuntu 15 64-bit, with Eclipse Mars. sudo apt-get install php5 installed apache2 for me, so no additional web server install is necessary.

  • Enable userdir mod:
    sudo a2enmod userdir
  • Your /etc/apache2/mods-enabled/userdir.conf should look like this, if not, make it so:
    <ifmodule mod_userdir.c>
            UserDir public_html
            UserDir disabled root
    
            <directory /home/*/public_html>
                    AllowOverride FileInfo AuthConfig Limit Indexes
                    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
                    <limit GET POST OPTIONS>
                            Require all granted
                    </limit>
                    <limitexcept GET POST OPTIONS>
                            Require all denied
                    </limitexcept>
            </directory>
    </ifmodule>
    
    
  • Comment out the user directories section in /etc/apache2/mods-available/php5.conf, like so:
    # Running PHP scripts in user directories is disabled by default
    # 
    # To re-enable PHP in user directories comment the following lines
    # (from <ifmodule ...> to </ifmodule>.) Do NOT set it to On as it
    # prevents .htaccess files from disabling it.
    #<ifmodule mod_userdir.c>
        #<directory /home/*/public_html>
            #php_admin_flag engine Off
        #</directory>
    #</ifmodule>
    
  • Create a public_html directory under your home directory;
  • Run sudo apt-get install php5-xdebug;
  • Run sudo apt-get install php5-mysql, as necessary;
  • Modify /etc/php5/mods-available/xdebug.ini so it has the following lines:
    zend_extension=xdebug.so
    xdebug.remote_enable=1
    
  • In Eclipse, create your PHP web application project under public_html in your home directory;
  • In Eclipse, while under PHP Perspective, click the drop down next to the green run button, and select “Run Configurations…”;
  • Create a new configuration for PHP Web Application. Pay attention to the following two things:
    a. In the Server tab, Server section, the PHP Server should be “Default PHP Web Server”, this is fine.
    eclipsePDT1
    b. Click the “Configure…” button, you’ll see this. Fill in proper “Document Root” value, in my case, /home/haidong/public_html
    eclipsePDT2
    c. Click the Debugger tab, and pick “XDebug”
    eclipsePDT3
    d. Go back to the original configuration screen, pick the proper file, and fill in th URL info, like below
    eclipsePDT1

By the way, Happy 2016 all!

[返回] [原文链接]