Writing code
While you are practicing, use a simple text editor such as Geany.
sudo apt-get install geany
This has syntax highlighting for several languages including php and sql. I often use it to make a quick change to code because it loads quickly.
Once you become more advanced, it is better to use an IDE (Integrated Development Environment) for writing code. IDE's have loads of features - not only syntax highlighting but it will also check for errors as you are typing, completes code for you and most important of all - will allow you to debug your project.
The choice here is either Eclipse or Netbeans. Both are pretty equal in features, I've tried both and personally prefer Netbeans. To install Netbeans
EDIT 17-Jan-2011
Ubuntu 11.10 doesn't include Netbeans in the repository. So to install, download Netbeans with the PHP pack. Then open a terminal, change to the download directory cd ~/Downloads and run sudo bash [name of the netbeans download]
EDIT 17-Jan-2011
Ubuntu 11.10 doesn't include Netbeans in the repository. So to install, download Netbeans with the PHP pack. Then open a terminal, change to the download directory cd ~/Downloads and run sudo bash [name of the netbeans download]
sudo apt-get install netbeans
Ubuntu 11.04 uses Netbeans 6.9, to install the latest version download the PHP bundle from the Netbeans website. The default skin looks a bit naff on Ubuntu, so I've added a launcher to the top panel (right click the top bar/panel, select "add to panel", "Application Launcher", Programming, Netbeans) then changed the properties -> command to
/usr/bin/netbeans --laf Nimbus
This will use the Nimbus skin which is much nicer.
Launch Netbeans and assuming your project has an index.html file - go to file -> new project -> php -> php project from existing sources -> then choose your project folder, eg: /var/www/projectname. Or if you are starting from scratch, then simply create a new project.
There are tutorials for Netbeans at http://netbeans.org/kb/trails/php.html and in particular http://netbeans.org/kb/docs/php/editorguide.html.
The commands I use often are Ctrl+F (Find), Ctrl+H (Find and Replace), Ctrl+click name of function will take you to the source of the function, Ctrl+hover will show the parameters, code complete press Enter after typing a function, right click a folder in the folders pane for finding keywords and of course the debugger play button.
Debugging
For debugging you will need to install xdebug and modify your php.ini file - http://wiki.netbeans.org/HowToConfigureXDebug
Edit : 19-Jan-2012
To install xdebug use
sudo pecl install xdebug
Edit : 19-Jan-2012
To install xdebug use
sudo pecl install xdebug
These are the xdebug settings from my php.ini
; This setting is on by default - turned off here because it can interfere with xdebug
report_zend_debug = 0
; Settings from http://wiki.netbeans.org/HowToConfigureXDebug
; Settings from http://wiki.netbeans.org/HowToConfigureXDebug
zend_extension = /usr/lib/php5/20090626+lfs/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler="dbgp"
xdebug.remote_mode="req"
xdebug.remote_host="localhost"
xdebug.remote_port=9000
; also http://xdebug.org/docs/remote
; Which IDE to use
xdebug.idekey="netbeans-xdebug"
; Automatically debug
xdebug.remote_autostart=1;

MySql
You should have already installed phpmyadmin, this can be accessed via http://localhost/phpmyadmin PhpMyAdmin is a great tool for managing your databases. You should become familiar with it. There are other tools, but phpmyadmin is so widely used, including on web hosts. There is a basic tutorial here http://www.devshed.com/c/a/PHP/Doing-More-With-phpMyAdmin-Part-1/
If you are already familiar with SQL, phpmyadmin also allows you to run SQL commands from a window.
One the most useful features of phpmyadmin is being able to do a data dump - this can act as a backup but also allows you to transfer the database to another server. Just choose the export or import option from the toolbar - select which tables you want to export, then the format - SQL if you want a full dump.
Another tool you might to install is the MySql Workbench. This is similar to phpmyadmin, but is a graphical desktop application. It can be useful for designing your database and testing queries.
No comments:
Post a Comment