Skip to content

Jsnrkd/Walleye

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WALLEYE - An MVC style PHP framework based on PHP 5.3.0

  • Uses MySQLi

  • Server-side logging through the javascript console object and a the database

  • Messages can be sent to the browser via WalleyeConsole::alert() and gritter

  • Secure session management

  • Includes basic sql

  • Uses the Walleye namespace

  • Includes phpDoc

  • Unit tests can be found in the tests folder

How to use the framework

Set up the configuration options in walleye.config.php.

Everything starts with index.php in the httpdocs folder. The .htaccess file routes all requests (excluding css, images, and js) to index.php.

The file creates a new instance of Walleye, sets the options found in walleye.config.php, and starts the app. This should always be the same process.

The Walleye class (walleye.php) is found in includes/core. The Walleye class is a singleton and is final. Its main job is to perform the routes found in walleye.config.php. The routes are key/value pairs. The key is a regular expression and the value is the controller that should handle that route (aka url). So, the Walleye class performs the route by looping through the routes array until it finds a match then passes control over to a specific controller.

Each controller extends includes/core/walleye.controller.php which requires each controller to have a doHandler() function. There is a generic doHandler() function in Controller that can be used.

ex. /user/login will go to the user controller and should perform the handler login.

The specific controller does not attempt to handle the business logic. This is handled by a model. In the case of logging in a user, the User (walleye.user.php) model will be used. The controller attempts to create a new Walleye_user by passing a username/password pair to the constructor (it’s a static function that returns an instance of self). If a new User is correctly authenticated then the the controller will set the logged in user with a function in User.

After the login is finished server-side, the browser needs a page to be rendered to the user. This is handled by Controller (walleye.controller.php). Each controller you create should extend this class. The class Controller contains a function called view($view, $values). When you call this function you need to pass a specific view that should be defined in the Walleye class and the necessary values for that view.

Once the controller calls view, the view is rendered through the php includes function. The application is finished server-side.

Database

A class in /includes/core/ called walleye.database.php is used for all interaction with the database. Before using this class the server, user, password, and database must be set in includes/core/walleye.config.php.

The Walleye_database class itself is simply an extension of MySQLi and can be created with the following line:

$db = new WalleyeDatabase();

Now you have all the functions available to you through MySQLi. You can change the database that you are connecting to by passing the name as a parameter.

$db = new WalleyeDatabase(‘test_db’);

Logging

Server-side logging is performed through the Console class (walleye.console.php). The file and line should be passed with each log unless you are logging an error (the Exception object will contain that information).

WalleyeConsole::log(‘this is a message to be logged’, __FILE__, __LINE__); WalleyeConsole::logError(‘this is an error’); WalleyeConsole::alert(‘this is a message to be sent to the browser’);

Email

Email can be sent via a template or a simple string. The values in a template (greeting.txt for example) should be marked as follows: #{value}

Hello #{username}, How are you? love, #{admin} After creating your template file you can send the email with the following code:

$email = WalleyeEmail::withTemplate($to, $subject, ‘greeting.txt’, array(‘username’ => ‘Jon’, ‘admin’ => ‘Bob’)); $email->send();

or without a template:

$email = WalleyeEmail($to, $subject, ‘This is an email’); $email->send();

About

A MVC style PHP 5.3.0 Framework

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%