Configure PHP for Web Development using Eclipse - rajivkanaujia/alphaworks GitHub Wiki

Getting Eclipse Ready for Ruby Development

Ruby is shipped with MacOS.

Prerequisite

You have configured Apache and validated PHP via instructions at Configure Apache for Web Development

Enable debugging in PHP via Xdebug

The debugger will be used for debugging PHP code when used in conjunction with Eclipse IDE See Enable debugging in PHP via Xdebug

Restart Apache

    $ sudo apachectl restart 

TEST using inprivate mode or inprivate browsing --> Visit http://localhost/~rajiv/phpinfo.php and check for following values.

If the values are same as mentioned below, you have configured the debugger accurately.

Don't forget to replace the localhost url with your actual URL (http://localhost/~/phpinfo.php)

    xdebug.remote_enable     On         On
    xdebug.remote_handler    dbgp       dbgp
    xdebug.remote_host       localhost	localhost
    xdebug.remote_port       9000       9000

Add PHP Development Tools (PDT) to Eclipse

Go to Help --> Marketplace and search for PHP Development

Install PDT

php_001.png

Configuring PHP installation in Eclipse

It is assumed that you have successfully configured Apache to enable PHP development and installed PDT in Eclipse. Create a folder/directory ~/Sites/AlphaWorksPHP/ This is the location where all sample PHP code will be written/deployed.

Open Eclipse Preference.

Configure PHP Server

Preference --> PHP --> Servers

php_002.png

Select the top one and click Edit. Update the "Document Root"

php_003.png

Configure Debugger

Go to Debugger Tab. Select Xdebug and confirm the port. Click "Finish" button once done.

php_004.png

Configure Path Mapping

Go to Path Mapping tab and select the location where sample PHP code will be written or deployed. Click the Add button Add right "Path in File System" and associated "Path on Server" Click the OK button

php_005.png

Click Finish button

php_006.png

Check Debug Configuration

Preference --> PHP --> Debug Check Server Settings. Ensure right PHP Server is selected

php_007.png

Configure PHP Executable

Using Terminal, execute following command to find the location of PHP executable and php.ini

    $ which php
    /usr/bin/php

    $ php -i | grep "php.ini"
    Configuration File (php.ini) Path => /etc
    Loaded Configuration File => /etc/php.ini

Go to Eclipse Preference --> PHP --> PHP Executables Click Add button to add PHP executable

php_008.png

Click Next button to review Debugger to be used

php_009.png

You can also use the Search button to find default PHP executable

php_010.png

Configure eclipse to use external browser Go to Preference --> General --> Web Browser Select Use external web browser and select the browser Click OK to finish

php_011.png

Next Steps

In subsequent wikis, I will show how to use Eclipse to build and debug your first Hello World example in PHP


Note: If you like the instructions here, please refer it on your posts/documentation. Contact me if there are corrections needed.

⚠️ **GitHub.com Fallback** ⚠️