PHPlib is a PHP application development framework that provides you with an easy to manage Object Oriented way to handle sessions, authentication and permissions in your PHP application.
PHPlib also has serveral helper classes, prominent amongst them are the DB_sql, template, OOH forms and cart.
The library will help you to write medium to large sized data-driven web applications. "Medium to large sized applications" are applications that consist of multiple database queries, have to generate tables from database data, need a user interface that generates SQL queries or need a comfortable and user-friendly way to protect pages or functionality on pages. "Data-driven" applications are applications that make use of a supported SQL-database to create HTML content and that use HTML forms to drive database transactions.
- Get your MySQL database server up an running. Create an empty database for your application and make sure the owner of your web server processes can access this database with SELECT, INSERT, UPDATE and DELETE access. Don't forget the mysqladmin reload after changing the user and db tables.
- Create an include directory named php parallel to your web servers document root directory. Do not put the include directory below your web servers document root.
- Unpack your PHPlib distribution. Move the contents of the php distribution directory into the php directory you just created.
- Get to the php3.ini OR php.in file for your web servers PHP interpreter and update the include_path statement so that it points to that php directory. Update the auto_prepend_file statement so that it points to the prepend.php3 file in that include directory. If you do not have control over your php.ini file, you did not read the VERY IMPORTANT NOTE above.
- Also check that track_vars are enabled and that you have enabled magic_quotes_gpc. While you are at it, you might want to check sendmail_path, if you plan to send mail from your application. It has to be set to /usr/lib/sendmail -t on most UNIX systems to work. If you do not have control over your php.ini file, you did not read the VERY IMPORTANT NOTE above.
- cd into the php include directory. Edit local.inc. In class DB_Example supply the appropriate parameters for your database connection.
- For this database, run create_database.mysql from the distribution to create active_sessions and auth_user. auth_user will be populated with a sample user named kris with a password test.
- Move the contents of the pages directory and all its subdirectories into your document root directory.
- Access the "/" URL of your web server with cookies enabled. If no index.html is present, index.php3 will be displayed. If you reload that page, the number shown must increment. Access your database with the mysql command client and select * from active_sessions. Check that there is a single session record for your browser and see how the text in val changes when you reload the page and select * from active_sessions again. If this works, the session class is functional with cookie mode.
- Now access showoff.php3. Try to login as kris, password test. Check active_sessions again. You now should have a Example_Session entry (see the name column) and a Example_User entry in your table. Both should increment on reload.
- Try again with cookies disabled. You should get a new session (the cookie is lost) and you should be able to see your session id as the get parameter part of your URL.