Using The Library

The Gear Library:

  • The Gear library is an static object full of useful methods to speed up development
  • The example below demonstrates how to access the Gear library:
    • Gear::methodName();
  • The ” is used since the library is in the root namespace
  • The ‘::’ is used since the class is static, meaning there is no actual object instantiated

 

Library Sections:

  • Constructor
    • Prepares the libraries static members
  • Member Variables
    • Contains all of the attributes of the Gear library
  • Database Access
    • Allows you to quickly and easily perform CRUD operations
    • Automatically prevents SQL Injection with PDO prepared statements
    • Row data is returned as an associative array
  • Security
    • Data encryption and decryption
    • Tokenization for CSRF prevention
    • Cleanses $_POST and $_GET to prevent XSS and SQL Injection
    • Ability to bind a form in a view file to a controller and control – More on this here: Using MVC
  • Validation
    • Automatically validate user data against the MySQL table it is supposed to go into
  • Roles
    • Get a user’s roles
    • Compare if a user is one of provided roles
    • Allow or deny access to pages based on roles
    • Change the access denied message
  • Messages
    • Add messages to the error, success, and error feed that will automatically be displayed
    • Add messages to your various log files
  • Dates
    • Quickly format and adjust dates in a variety of formats
  • CSS and JS
    • Add, remove, and set which CSS and JS files will be used
  • Global Settings
    • Enable/Disable things like general debugging, query debugging, and post resubmission
  • View Helpers
    • Add new content directly before or after your applications output
    • Automate the creation of form drop downs and combo boxes
  • Miscellaneous
    • Redirect you application

 

Up Next: Constants and Globals