PHP Classes

Boiler Framework: Web application framework that implements MVC

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 480 All time: 5,950 This week: 71Up
Version License PHP version Categories
boiler 1.0GNU General Publi...5.3PHP 5, Libraries, Code Generation, De...
Description 

Author

This package is a Web application framework that implements MVC.

It provides base controller and router classes to make requests be handled by controller classes based on the request URL.

A base database object is provided to be extended by actual implementation model classes that define how to access the respective database table records. Model classes and database confuguration scripts are generated using the ant tool.

Views are regular PHP template scripts that can be loaded by controllers using the base router class.

Picture of Will Tinsdeall
Name: Will Tinsdeall <contact>
Classes: 1 package by
Country: United Kingdom
Age: ???
All time rank: 3326146 in United Kingdom
Week rank: 206 Up12 in United Kingdom Up

Documentation

To install simply move htdocs to your public html directory, then set BOILER_LOCATION on line 3 of index to point to the framework folder.

Controllers are the start point of your page.

Testing and Building

Building and testing (optional) is done with a build.xml make file for "ant". You may also consider using the following to help test your code.

The following tools have a config shipped with ant targets, and are fully compatible with Hudson/Jenkins CI

  • PHP Mess Detector

pear channel-discover pear.phpmd.org pear channel-discover pear.pdepend.org pear install --alldeps phpmd/PHP_PMD

  • PHP CodeSniffer

pear install PHP_CodeSniffer

  • PHP Copy and Paste detector

pear channel-discover components.ez.no pear install phpunit/phpcpd

  • PHPUnit

pear channel-discover pear.phpunit.de pear channel-discover pear.symfony-project.com pear install phpunit/PHPUnit

  • PHPUnit skelgen

pear install phpunit/PHPUnit_SkeletonGenerator

CONTROLLERS

-Namespacing follows folder structure to allow PHP lazy loading (please see php.net for Namespacing and __autoload) -All classes must be namespaced with Controller. This is to allow you to have a controller and model, for example, with the same name. -Functions being called must be public -First letter only of class is capitalized

Examples:

http://localhost/class/function/args1/args2/args3

Would execute: $c = new \Controller\Class(); $c->function(args1, args2, args3);

http://localhost/ns1/ns2/ns3/class/function

Would Execute: $c = new \Controller\ns1\ns2\ns3\Class(); $c->function();

MODELS

-Models should extend DBObject normally for MySQL objects -Models must be namespaced -DBObject class (found in application/model/DBObject.php) must have login details entered for PHP

<?php namespace Model; class MySQLTable extends DBObject {

public static function getTable($read=true) {
	return "mysql_table_name";
}

public static function getPrimaryKey() {
	return "mysql_primary_key";
	OR
	return array("concat", "key");
}

} //That's it! No SQL! Your MySQL settings are retrieved from a config.php file, built by ant. This stops you committing your MySQL details to git - pretty irritating! ?>

More advanced functions: N.B. This is a demo which came from when the framework was not namespaced.

<?php

ini_set('display_errors', "On"); include "Linq.php"; include "DBObject.php"; /* Employee */ class Employee extends DBObject {

public static function getPrimaryKey() {
	//Use an array for concatinated keys
	return "id";
}

public static function getTable($read=true) {
	//$read variable gives the class a "heads up" about what is going to be done. Sometimes I have created a
	//MySQL view for reading (which of course is read only) and therefore have had to specify a table as well
	//for write operations
	return "employee";
}

public static function getDB() {
	return LinqDB::getDB("mysql.bcslichfield.com", "star241_6", "devpasswd123=", "bcslichfield_dev");
}

//Some nice utility functions
public function getJobs() {
	return EmployeeJob::getJobsByEmployee($this);
}

public function giveJob(Job $j) {
	EmployeeJob::giveJob($this, $j);
}

}

/* LINK TABLE to stop many-to-many between Employee and Job */

class EmployeeJob extends DBObject {

public static function getPrimaryKey() {
	//Use an array for concatinated keys
	return array("employee", "job");
}

public static function getTable($read=true) {
	//$read variable gives the class a "heads up" about what is going to be done. Sometimes I have created a
	//MySQL view for reading (which of course is read only) and therefore have had to specify a table as well
	//for write operations
	return "employee_job";
}

public static function getDB() {
	return LinqDB::getDB("mysql.bcslichfield.com", "star241_6", "devpasswd123=", "bcslichfield_dev");
}

//Some nice function we'll just add in because they are nice to use in a link table
public static function getJobsByEmployee(Employee $e) {
	return self::getByAttribute("employee", $e->id);
}

public static function getEmployeesByJob(Job $j) {
	return self::getByAttribute("job", $j->id);
}

public static function giveJob(Employee $e, Job $j) {
	self::Create(array('employee'=>$e->id, 'job'=>$j->id));
}

}

/* Jobs table */ class Job extends DBObject {

public static function getPrimaryKey() {
	//Use an array for concatinated keys
	return array("id");
}

public static function getTable($read=true) {
	//$read variable gives the class a "heads up" about what is going to be done. Sometimes I have created a
	//MySQL view for reading (which of course is read only) and therefore have had to specify a table as well
	//for write operations
	return "job";
}

public static function getDB() {
	return LinqDB::getDB("mysql.bcslichfield.com", "star241_6", "devpasswd123=", "bcslichfield_dev");
}

//A nice little function to aid us
public function getEmployees() {
	return EmployeeJob::getEmployeesByJob($this);
}

}

// class LinqDB extends mysqli, so feel free to use it as mysqli too!

//Lets use it to setup some temp tables $db = LinqDB::getDB("mysql.bcslichfield.com", "star241_6", "devpasswd123=", "bcslichfield_dev"); $db->query("CREATE TEMPORARY TABLE IF NOT EXISTS employee ( id INT AUTO_INCREMENT, name varchar(50) NOT NULL, male tinyint(1) NOT NULL DEFAULT 1, dob DATETIME, PRIMARY KEY (id) ) ENGINE=InnoDB");

$db->query("CREATE TEMPORARY TABLE IF NOT EXISTS job ( id INT AUTO_INCREMENT, name varchar(50) NOT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB");

$db->query("CREATE TEMPORARY TABLE IF NOT EXISTS employee_job ( employee INT NOT NULL, job INT NOT NULL, PRIMARY KEY (employee, job)

) ENGINE=InnoDB");

/* For debug (not applicable on temporary tables):

FOREIGN KEY (employee) REFERENCES employee (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (job) REFERENCES job (id) ON DELETE CASCADE ON UPDATE CASCADE */

/* Once upon a time, in a factory far away there were three workers! */ $me = Employee::Create(array("name"=>"Will Tinsdeall")); $bob = Employee::Create(array("name"=>"Bob Bloggs")); $joe = Employee::Create(array("name"=>"Joe Bloggs"));

/* And my AUTO_INCREMENT ID was: */ echo "TEST 1: ".$me->id."\r\n";

/* In the factory there were many jobs */ $joba = Job::Create(array('name'=>'A very hard job')); $jobb = Job::Create(array('name'=>'An average job')); $jobc = Job::Create(array('name'=>'An easy job'));

/* And we all had jobs */ $me->giveJob($joba); $me->giveJob($jobb);

$bob->giveJob($joba); $bob->giveJob($jobc);

$joe->giveJob($jobb); $joe->giveJob($jobc);

/* First of all the boss wanted to know all the jobs that were being done */ foreach (Job::getAll() as $j) {

echo "Job {$j->id}: {$j->name}"."\r\n";

}

/* Next, he decided to quickly call me */ $me = new Employee("1");

/* And asked me to check to see who was working well. */ $db->Select(Employee); /* This consisted of people

EITHER: */ $db->getOrFilter();

/* Those doing a medium job only */

$jobs = $db->Select(EmployeeJob); $jobs->addCount("jobs"); $jobs->addField("employee"); $jobs->addField("job"); $jobs->setGroup("employee"); /SELECT COUNT() as jobs, employee FROM employee_job GROUP BY employee */ $j = $jobs->Select(); $jFilter = $db->getAndFilter(); $jFilter->eq("job","2")->eq("jobs", "1"); $j->setFilter($jFilter); //SELECT FROM (SELECT COUNT() as jobs, id FROM employee_job GROUP BY employee) WHERE jobs=1 AND job=2

/* Or those doing an easy job and a very hard job */ $jobsB = $db->Select(EmployeeJob); $jobsB->addField("employee"); $jBFilter = $db->getAndFilter(); $jBFilter->eq('job', 1)->eq("job", 3); $jobsB->setFilter($jBFilter);

//XXX this would work if the tables weren't temporary! /* $u = $db->Union(); $u->addSelect($jobsB)->addSelect($jobs); echo $u->getSQL(); */

$out = array(); foreach (array_merge($jobsB->Exec(), $jobs->Exec()) as $a) {

var_dump($a);
$out[$a->employee] = new Employee($a->employee);

} var_dump($out);

/* Lastly he wanted a to assess everyone at their jobs (simple JOIN) */ $qEmployee = $db->Select(Employee); $qEmployeeJob = $db->Select(EmployeeJob); $qJob = $db->Select(Job);

$qEmployeeJob->joinLeft("employee", $qEmployee, "id"); $qEmployeeJob->joinLeft("job", $qJob, "id");

var_dump($qEmployeeJob->Exec()); ?>


  Files folder image Files (91)  
File Role Description
Files folder imagebuild (12 files, 4 directories)
Files folder imageconfig (2 files)
Files folder imageframework (2 directories)
Files folder imagehtdocs (2 files, 1 directory)
Files folder imagetests (2 files)
Files folder imagewebsocket (2 files, 4 directories)
Accessible without login Plain text file .buildpath Data Auxiliary data
Accessible without login Plain text file .project Data Auxiliary data
Accessible without login Plain text file build.xml Data Auxiliary data
Accessible without login Plain text file README Doc. Auxiliary data

  Files folder image Files (91)  /  build  
File Role Description
Files folder imagegeneration (4 files)
Files folder imagegit (2 files)
Files folder imagePHPCS (3 files)
Files folder imagephpunit (1 file, 1 directory)
  Accessible without login Plain text file build.sh Data Auxiliary data
  Accessible without login Plain text file dbconfig.sh Data Auxiliary data
  Accessible without login Plain text file doxyfile.cfg Data Auxiliary data
  Accessible without login Plain text file phpunit.php Aux. Auxiliary script
  Accessible without login Plain text file post-merge Data Auxiliary data
  Accessible without login Plain text file pre-commit Data Auxiliary data
  Accessible without login Plain text file schema.sql Data Auxiliary data
  Accessible without login Plain text file schema_load.php Aux. Auxiliary script
  Accessible without login Plain text file schema_save.php Aux. Auxiliary script
  Accessible without login Plain text file testdata.sql Data Auxiliary data
  Accessible without login Plain text file testdata_load.php Aux. Auxiliary script
  Accessible without login Plain text file testdata_save.php Aux. Auxiliary script

  Files folder image Files (91)  /  build  /  generation  
File Role Description
  Accessible without login Plain text file api.php Appl. Auxiliary script
  Accessible without login Plain text file common.php Aux. Auxiliary script
  Accessible without login Plain text file models-clean.php Appl. Auxiliary script
  Accessible without login Plain text file models.php Appl. Auxiliary script

  Files folder image Files (91)  /  build  /  git  
File Role Description
  Accessible without login Plain text file create_insert.php Aux. Auxiliary script
  Accessible without login Plain text file create_schema.php Aux. Auxiliary script

  Files folder image Files (91)  /  build  /  PHPCS  
File Role Description
  Accessible without login Plain text file Ivebeenlinuxed_Sni...osingBraceSniff.php Test Unit test script
  Accessible without login Plain text file Ivebeenlinuxed_Sni...copeIndentSniff.php Test Unit test script
  Accessible without login Plain text file ruleset.xml Data Auxiliary data

  Files folder image Files (91)  /  build  /  phpunit  
File Role Description
Files folder imageBindings (6 files, 2 directories)
  Accessible without login Plain text file phpunit.php Aux. Auxiliary script

  Files folder image Files (91)  /  build  /  phpunit  /  Bindings  
File Role Description
Files folder imageincludes (2 files)
Files folder imageWebDriver (10 files)
  Accessible without login Plain text file bootstrap.php Aux. Unit test script
  Accessible without login Plain text file phpunit_coverage.php Aux. Unit test script
  Plain text file Selenium2BrowserTestSuite.php Class Unit test script
  Plain text file Selenium2TestCase.php Class Unit test script
  Plain text file Selenium2TestDriver.php Class Unit test script
  Plain text file Selenium2TestSuite.php Class Unit test script

  Files folder image Files (91)  /  build  /  phpunit  /  Bindings  /  includes  
File Role Description
  Accessible without login Plain text file append.php Aux. Auxiliary script
  Accessible without login Plain text file prepend.php Aux. Auxiliary script

  Files folder image Files (91)  /  build  /  phpunit  /  Bindings  /  WebDriver  
File Role Description
  Accessible without login Plain text file CWebDriverTestCase.php Test Unit test script
  Plain text file Keys.php Class Unit test script
  Plain text file LocatorStrategy.php Class Unit test script
  Plain text file MouseButton.php Class Unit test script
  Plain text file NoSuchElementException.php Class Unit test script
  Accessible without login Plain text file WebDriver.php Test Unit test script
  Plain text file WebDriverBase.php Class Unit test script
  Plain text file WebDriverException.php Class Unit test script
  Plain text file WebDriverResponseStatus.php Class Unit test script
  Plain text file WebElement.php Class Unit test script

  Files folder image Files (91)  /  config  
File Role Description
  Accessible without login Plain text file haproxy.cfg Data Auxiliary data
  Accessible without login Plain text file supervisor-rachet.conf Data Auxiliary data

  Files folder image Files (91)  /  framework  
File Role Description
Files folder imageapplication (4 directories)
Files folder imagesystem (5 directories)

  Files folder image Files (91)  /  framework  /  application  
File Role Description
Files folder imagecontroller (2 files, 1 directory)
Files folder imagecore (1 file)
Files folder imagelibrary (2 files, 1 directory)
Files folder imagemodel (1 file)

  Files folder image Files (91)  /  framework  /  application  /  controller  
File Role Description
Files folder imageapi (1 file)
  Plain text file BaseController.php Class Unit test script
  Plain text file Home.php Class Class source

  Files folder image Files (91)  /  framework  /  application  /  controller  /  api  
File Role Description
  Plain text file ModelController.php Class Class source

  Files folder image Files (91)  /  framework  /  application  /  core  
File Role Description
  Plain text file Router.php Class Class source

  Files folder image Files (91)  /  framework  /  application  /  library  
File Role Description
Files folder imagewidget (1 file)
  Plain text file ACL.php Class Class source
  Plain text file FieldProperties.php Class Class source

  Files folder image Files (91)  /  framework  /  application  /  library  /  widget  
File Role Description
  Plain text file Widget.php Class Class source

  Files folder image Files (91)  /  framework  /  application  /  model  
File Role Description
  Plain text file DBObject.php Class Class source

  Files folder image Files (91)  /  framework  /  system  
File Role Description
Files folder imagecontroller (1 file, 1 directory)
Files folder imagecore (1 file)
Files folder imagelibrary (6 files, 1 directory)
Files folder imagemodel (1 file)
Files folder imageview (4 files)

  Files folder image Files (91)  /  framework  /  system  /  controller  
File Role Description
Files folder imageapi (1 file)
  Plain text file Framework.php Class Class source

  Files folder image Files (91)  /  framework  /  system  /  controller  /  api  
File Role Description
  Plain text file ModelController.php Class Class source

  Files folder image Files (91)  /  framework  /  system  /  core  
File Role Description
  Plain text file Router.php Class Class source

  Files folder image Files (91)  /  framework  /  system  /  library  
File Role Description
Files folder imagedata (2 files)
  Plain text file ACL.php Class Class source
  Plain text file BoilerException.php Class Class source
  Plain text file FieldProperties.php Class Class source
  Plain text file Lexical.php Class Class source
  Plain text file Security.php Class Class source
  Plain text file StdLib.php Class Class source

  Files folder image Files (91)  /  framework  /  system  /  library  /  data  
File Role Description
  Plain text file DataStream.php Class Class source
  Plain text file InputModule.php Class Class source

  Files folder image Files (91)  /  framework  /  system  /  model  
File Role Description
  Plain text file DBObject.php Class Class source

  Files folder image Files (91)  /  framework  /  system  /  view  
File Role Description
  Accessible without login Plain text file error.php Aux. Class source
  Accessible without login Plain text file framework_licence.php Aux. Sample output
  Accessible without login Plain text file home.php Aux. Sample output
  Accessible without login Plain text file landing.php Aux. Sample output

  Files folder image Files (91)  /  htdocs  
File Role Description
Files folder imageplugins (3 directories)
  Accessible without login Plain text file .htaccess Data Auxiliary data
  Accessible without login Plain text file index.php Example Sample output

  Files folder image Files (91)  /  htdocs  /  plugins  
File Role Description
Files folder imageboiler (1 file)
Files folder imagejquery-pjax (1 file)
Files folder imagejquery (1 file)

  Files folder image Files (91)  /  htdocs  /  plugins  /  boiler  
File Role Description
  Accessible without login Plain text file utils.js Data Auxiliary data

  Files folder image Files (91)  /  htdocs  /  plugins  /  jquery-pjax  
File Role Description
  Accessible without login Plain text file jquery.pjax.js Data Auxiliary data

  Files folder image Files (91)  /  htdocs  /  plugins  /  jquery  
File Role Description
  Accessible without login Plain text file jquery-1.9.1.min.js Data Auxiliary data

  Files folder image Files (91)  /  tests  
File Role Description
  Accessible without login Plain text file DBObjectTest.php Test Unit test script
  Accessible without login Plain text file StdLibTest.php Test Unit test script

  Files folder image Files (91)  /  websocket  
File Role Description
Files folder imagebin (1 file)
Files folder imagesrc (1 directory)
Files folder imagetest (2 files)
Files folder imagevendor (1 file, 1 directory)
  Accessible without login Plain text file composer.json Data Auxiliary data
  Accessible without login Plain text file composer.lock Data Auxiliary data

  Files folder image Files (91)  /  websocket  /  bin  
File Role Description
  Accessible without login Plain text file chat-server.php Example Auxiliary script

  Files folder image Files (91)  /  websocket  /  src  
File Role Description
Files folder imageMyApp (2 files)

  Files folder image Files (91)  /  websocket  /  src  /  MyApp  
File Role Description
  Plain text file Chat.php Class Class source
  Plain text file Pusher.php Class Class source

  Files folder image Files (91)  /  websocket  /  test  
File Role Description
  Accessible without login Plain text file index.html Data Documentation
  Accessible without login Plain text file server.php Aux. Auxiliary script

  Files folder image Files (91)  /  websocket  /  vendor  
File Role Description
Files folder imagecomposer (6 files)
  Accessible without login Plain text file autoload.php Aux. Auxiliary script

  Files folder image Files (91)  /  websocket  /  vendor  /  composer  
File Role Description
  Accessible without login Plain text file autoload_classmap.php Aux. Auxiliary script
  Accessible without login Plain text file autoload_namespaces.php Aux. Auxiliary script
  Accessible without login Plain text file autoload_psr4.php Aux. Auxiliary script
  Accessible without login Plain text file autoload_real.php Aux. Auxiliary script
  Plain text file ClassLoader.php Class Class source
  Accessible without login Plain text file installed.json Data Auxiliary data

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:480
This week:0
All time:5,950
This week:71Up