Category Archives: PHP

NetBeans installation

netbeansDownload NetBeans at here. This script will install the Java JRE and NetBeans in one go.

After installation start up the NetBeans IDE. If you are running under gnome the fontsize is a bit big.

You can change this by adding

–laf javax.swing.plaf.metal.MetalLookAndFeel –fontsize 14

to your desktop shortcut. Th desktop shortcut is located at ~/.local/share/applications/. Change the line that starts with Exec to:

Now it is time to install the PHP plugin. Go to Tools -> Options; order by name and search for the PHP plugin. Select it and press install. Accept the dependencies and the license and press install. Choose restart the IDE now and press Finish.

Install also the PHPUnit plugin to help you create Unit testing classes.

Share

phpStorm 7 / XDebug environment configuration

The phpStorm 7 IDE is an excellent tool to write your PHP code in. This post describes the step to take to debug your PHP website with phpStorm 7 and XDebug. This post only describes the installation of XDebug and the use of phpStorm 7. You can also find posts about installing Apache and Mysql on this blog.

Configure phpStorm 7 / XDebug environmentFirst of all download a copy of phpStorm 7 and unpack it to a directory of your choice. PhpStorm 7 depends on java so you should also install java onto your system.

Next thing to do is configure XDebug and Apache to work together. First step is to determine the active php.ini . This can easily be done by creating a PHP script with a call to phpinfo();.

Copy the contents of this page (not the page source) and paste it into the textbox found at http://xdebug.org/wizard.php.

Download the XDebug archive at http://xdebug.org/files/xdebug-2.2.3.tgz. Unzip the archive with

Goto the directory created by the unzip command:

Run the phpize command (prepare PHP extension for compiling); the output should be something like:

When you see something like the text above you know you’re good to go.

Execute ./configure to configure the make script

When configure runs ok execute the make command:

After the make command has finished you have a compiled xdebug.so  module in the modules directory.

Copy the xdebug.so  module to  /usr/lib/php5/[Zend Extension value from phpinfo(); call]

Now in the output of the phpinfo()  call search for the value Loaded Configuration File. The second column shows the active php.ini . Edit this file and add the lines below (uncomment any [zend] section if it exists):

Change the location of zend_extension as needed!

Restart your apache server:
sudo service apache2 restart

Rerun your phpinfo() script and paste it again into the textbox at http://xdebug.org/wizard.php

Check for a line that says something like “ You're already running the latest Xdebug version “, If it is there you have configured PHP to use the XDebug extension.

Now it is time to startup phpStorm 7 and create our first PHP project. Start your copy of phpStorm 7.

Select “Create New Project” (choose “Empty project for now; be sure that the location is in or below the DocumentRoot of your apache site) and follow the steps below:

  1. Add a new file index.php  and add a call to phpinfo()  to it (right click the project title on the left; select New -> PHP File).
  2. Select Run -> Edit configurations
  3. Select the + sign at the top left and select “Php Web Application”
  4. Name it for example “WebAppDebugConfig”
  5. Press the “…” after “Server” to add a server.
  6. Press the + sign at the top left.
  7. Change the servername to the name of your development host (both Name and Host) and press Ok
  8. Select the Server Name in the “Run/Debug Configurations” to make the error go away
  9. Fill out your start URL;  /index.php 
  10. Press Ok

 

Share

Send email with PHP script

So you want to send an email through a PHP script. Well that is dead simple (provided you have your smtp server setup correctly). See the code fragment below:

 

Share