# TODO List

## NetBeans PHP Sample Application

### What is TODO List?

TODO List is a personal list of things that are to be done. This PHP application is created to highlight PHP features supported by NetBeans IDE.

This sample is not intented to be used on a production server without any changes.

### This sample demonstrates the following features:

- OOP concepts
- preventing public access to your scripts
- configuration your application
- accessing your database data
- changing your database data (with redirect-after-post pattern)
- validating your data
- splitting scripts and templates
- handling expected and unexpected exceptions

### Requirements

Follow these before you run the sample:

- Install NetBeans IDE with PHP support
- Install and configure PHP Runtime
- Install and configure MySQL database

### What is included?

- NetBeans PHP Application Project
- Database SQL Script - Use this script to populate tables and sample records
- Additional Stylesheet, JavaScript

### Before the start

- If you want to try the sample out, follow Getting Started guidelines.
- In case of you want to try debugging features of the NetBeans IDE, follow the Debugging guidelines.

### Getting Started

1. Firstly, we set database authentication in config/config.ini, which is stored in TODO List Project directory.
   Just update login and password fields in the configuration file, so they are the same as MySQL ones.
2. Secondly, we create the database and populate it with data:
   1. Create new MySQL database named todolist in phpMyAdmin (or any other MySQL administration tool).
   2. Run db/mysql.sql script stored in TODO List Project directory. The script creates table and fills it with sample data.
3. The strongly preferred way is to create all your PHP applications underneath the documents directory (htdocs) of your web server (so the web server can access them directly, e.g. http://localhost/TodoList/web/). If it is not your case, then set project properties to deploy project sucessfully to it:
   1. Right-click on the TodoList project node and select Properties.
   2. Check the option Copy files from Sources Folder to another location.
   3. In Copy to Folder field specify the path of the documents directory (htdocs) of your web server.
   4. Specify the Project URL to be appropriate with your settings from previous field and also with Web Server setup.
   5. Confirm the settings.
4. Finally, we can run the project. Right-click the project node again and select Run Project or use the Run Project icon in the main menu toolbar. The sample PHP application should open in the Web browser.
5. Play futher with the sample :)

### Debugging

These steps should enable you the debugging option at the sample project, if you already have PHP debugger installed and configured.
For demonstrating the PHP debugger in NetBeans we have to put the project to the web server documents directory (htdocs):

1. Create new TODO ListSample Application with following settings:
2. Set the Project Folder to your web server documents (htdocs) directory, for example: C:\Program Files\Apache2.2\htdocs\TodoList
3. In project properies (right-click the project node and select Properties.) set the Project URL to be appropriate with previous setting, for example: http://localhost/TodoList/web/
4. To debug, right-click the project node and select Debug Project or use the Debug Project icon in the main menu toolbar.

### Project folder's structure

- config - Contains configuration file config.ini where you can edit the DB connection settings.
- dao - Contains DAO (Data Access Object) classes.
- db - Contains SQL dump for creating the database.
- exception - Contains custom exceptions.
- layout - Contains layout common for all web pages.
- mapping - Contains classes used for mapping from database to model classes.
- model - Contains model classes.
- page - Contains pages of the TodoList application.
- util - Contains utility classes.
- validation - Contains validation classes.
- web - Contains publicly accessible files (PHP scripts, CSS, JS, images).

### Credits

This sample application uses great SILK icons created by Mark James.