PHP Classes

Tiny PHP Address Book: Manage address book stored in a database with PDO

Recommend this page to a friend!
  Info   View files Example   View files View files (35)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 242 All time: 8,001 This week: 83Up
Version License PHP version Categories
tiny-address-book 1.0.0BSD License5.4PHP 5, Databases, AJAX
Description 

Author

This package can manage address book stored in a database with PDO.

It can store in a database contact information records with first and last name, street, post code and city.

The package provides a AJAX based user interface to display and edit the contacts in an address book database table.

Innovation Award
PHP Programming Innovation award nominee
March 2017
Number 10
Address books are useful to keep track of user contacts in a database.

This package provides an AJAX based user interface to manage the information of an address book.

Manuel Lemos
Picture of Vallo Reima
  Performance   Level  
Innovation award
Innovation award
Nominee: 3x

 

Example

<?php

/**
 * the entry
 *
 * @package System
 * @author Vallo Reima
 * @copyright (C)2013
 */
define('SGN', 'aBook'); /* signature */
define('APP', 'abk'); /* application token */
define('DEV', 1); /* development status */

if (version_compare(PHP_VERSION, '5.4', '<')) {
  die(
'System requires PHP 5.4 or newer version');
} else {
 
error_reporting(-1);
 
ini_set('display_errors', true);
 
ini_set('log_errors', false);
}

define('DS', DIRECTORY_SEPARATOR); /* directory separator */
define('PRID', 'pri' . DS); /* system directory */
define('PUBD', 'pub' . DS); /* assets directory */
define('EXT', '.php'); /* default extension */

require_once(PRID . 'startup' . EXT); /* bootstrap */
$application = new Frontal(); /* front controller */
$application->Run(); /* perform action */
?>


Details

Tiny Address Book

This demo application shows the design and programming techniques used in my projects. Some of the components of vRegistry framework are used. All the code is original (except some standard functions).

Functionality

The database consists of contacts and towns tables containing First & Last Name, Street, Postcode and Town data. The records can be added, deleted or modified. The table can be browsed and saved in XML format. Double-clicking on the row selects the record for editing. The towns list must be edited outside.

The demo is uploaded on [arc.vregistry.com].

Design & programming

OOP MVC principles are followed both on the back and front end. The AJAX is used for client-server communications. See [app.vregistry.com] regarding the techniques.

Requirements

  • Webserver: Apache or IIS supporting PHP and MySql
  • PHP: version 5.4+, PDO mysql and sqlite extensions
  • MySql: version 5+, Innodb engine
  • JavaScript: 1.5+ version
  • Browser: any common (IE, FF, Chrome, Safari, Opera,...), newer version

Installation

Unpack the abk.zip to your local/remote webserver retaining the folder structure. Create and load the MySql database from the sql files supplied. Find/change the connection properties in the configuration file /pri/abk/abk.xml (node db):

  • nme - database name
  • usr - access username
  • pwd - access password
  • pfx - database and username prefix (if hosting requires)

File structure

The files are arranged in folders according to their scope and functionality.

Folders

The root folder contains default startup. The folders:

  • pri - private server-side files; subfolders: + abk - application files + sys - framework files + tmp - temporary workfiles
  • pub - public client-side files; subfolders: + js - JavaScript code + css - stylesheets + pic - images
  • dev - miscellaneous development data

The abk and sys folders (may) have the subfolders:

  • _act - actions PHP code *.php
  • _css - dynamic CSS code *.css
  • _js - dynamic JavaScript code *.js
  • _lib - PHP classes *.php
  • _srv - action's PHP services *.inc
  • _tpl - htm templates *.phtml

Files

  • index.php - startup
  • php.php - check PHP version
  • pri/.htaccess - deny access
  • pri/gateway - common data gateway
  • pri/startup - bootstrap
  • dev/abook_data.sql - MySql data loading queries
  • dev/abook_struc.sql - MySql structure queries
  • pri/abk/abk.db - dictionary
  • pri/abk/abk.xml - configuration
  • pri/abk/_act/abook.php - main panel creator
  • pri/abk/_act/browse.php - browse panel creator
  • pri/abk/_act/finish.php - bye panel creator
  • pri/abk/_act/shell.php - layout creator
  • pri/abk/_css/shell.css - layout style
  • pri/abk/_js/abook.js - editor/browser class
  • pri/abk/_lib/Frontal.php - front controller class
  • pri/abk/_srv/abook.inc - data manipulation
  • pri/abk/_srv/browse.inc - browse services
  • pri/abk/_tpl/abook.phtml - panel template
  • pri/abk/_tpl/browse.phtml - browse template
  • pri/abk/_tpl/shell.phtml - layout template
  • pri/sys/_act/download.php - file download dialogue
  • pri/sys/_lib/Base.php - base functionality class
  • pri/sys/_lib/Common.php - common methods & properties class
  • pri/sys/_lib/Database.php - database abstraction layer class
  • pri/sys/_lib/IData.php - database I/O layer interface
  • pri/sys/_lib/Mypdo.php - PDO I/O layer
  • pri/sys/_lib/Texts.php - multilingual texts class
  • pri/sys/_tpl/exit.phtml - finish/error panel template
  • pri/sys/_tpl/exits.phtml - exit panel shell template

ChangeLog

  • Mar 2017 - shell design correction

[app.vregistry.com]: http://app.vregistry.com/hlp/en/spgm [arc.vregistry.com]: http://arc.vregistry.com/abk/


  Files folder image Files  
File Role Description
Files folder imagedev (2 files)
Files folder imagepri (3 files, 2 directories)
Files folder imagepub (3 directories)
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file php.php Aux. Auxiliary script
Accessible without login Plain text file readme.md Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 100%
Total:242
This week:0
All time:8,001
This week:83Up