- Switch board (framework)
Switch Board is a MVC framework written for
PHP. Its original concepts were taken from a preexisting ColdFusion/PHP framework called Fusebox. Its evolution through development has greatly changed its structure to have very little resemblance to Fusebox other than slight functionality of the switch, settings and template files.
The current release of Switch Board is Switch Board with Routing 2.0.1. This version was released on December 25th, 2006 by the developer [http://www.danielslaughter.com Daniel Slaughter] .
Switch Board has three sub-directories from its root. These sub-directories are the control, model and view. When a page is called from a Browser the PHP Server executes the control, model and then view file before displaying the resulting content to the called Browser. This separation of MVC is seamless to the end user.
;CoreThe core file is the brains behind everything. This file (sb_core.php) consists of 66 lines of code. The core file executes in the following manner::1. The URL is parsed to determine what circuit and page to gather the control/model/view pages from.:2. The Settings file is then included which contains any global variables. If a circuit other than the root was found in the URL then its settings file is as well included here.:3. The Switch file from the root or circuit is included (but not both).:4. PHP determines if control/"page".php exists and includes it (where "page" equals the file the browser is attempting to access):5. PHP determines if model/"page".php exists and includes it:6. PHP determines if view/"page".php exists and includes it:7. Any content generated from the control/model/view is then embedded in the template and displayed to the Browser. If no content was generated, the designated error page is included instead (specified in the settings file).
;SettingsThe settings is held in a file called sb_settings.php in the root of the Switch Board files. This file is where any global variables are held. For instance, the configuration variables of Switch Board are located here. You may add any additional variables you wish to this file that your application will use. The settings file are called prior to any other file from the sb_core.php file.
;SwitchThe switch is held in a file called sb_switch.php in the root of the Switch Board files. This file is a simple PHP switch-case that handles any global variables to the individual page (such as the page title, if the page redirects, and exit actions: links from this page). Please note: you do not need to have include statements for the control/model/view files here. Switch Board assumes if they exist they should be included (this greatly increases development time and ensures file naming schemes). The switch file is called before the control/model/view files are included.
;ControlProcesses and responds to events, typically user actions, and may invoke changes on the model.In Switch Board the control is meant to make inserts/updates to a database or other file structure. These pages are typically called from the posting of a form.
;ModelThe model is another name for the domain layer. The model in Switch Board is where database select statements are pooled. Calculations can also be done here to data before it is presented to the view file for display.
;ViewRenders the model into a form suitable for interaction, typically a user interface element. In Switch Board the view page contains the display generated from the data retrieved in the model. Only the information physically presented to the Browser should be held here (such as XHTML, HTML, CSS). However, for debugging purposes content can be displayed to the Browser through the control and model but is not suggested for final release.
;TemplateThe template is held in a file called sb_template.php in the root of the Switch Board files. This template file contains the wrapper XHTML/HTML for the content generated from a page call to Switch Board from the Browser. The template is the last file to include. There are parameters you can use to ignore the template (ie: $sb ['useTemplate'] = false).
Advantages of Switch Board
* Switch Board gets away from the
Object-oriented programmingapproach to MVC Frameworks.
* The current core file of Switch Board contains 66 lines of code.
* No configuration is required to add a page. Switch Board includes files in the /control/, /model/ and /view/ folder (in that order) if they exist with the same name as the routed file called. So, if /helloworld.htm was called, /control/helloworld.php, /model/helloworld.php, and /view/helloworld.php would be included if they exist.
* A global sb_settings.php file is used to define global variables like those used in the configuration of Switch Board.
* Any content generated is embedded into the sb_template.php file for display. If a circuit is called, its content it generated within its template, and then generated within the root's template.
* Switch Board is very fast to develop in because no additional configuration is required in the switch to add a page. A simple Hello World application would require you to create a file called helloworld.php in the /view/ folder from the root with the following text:
You can then access this Hello World application by going to an address such as:Hello World
Built in capabilities
* Simple redirecting is a built in feature which allows a developer to specify to Switch Board what page to redirect to after processing the controller file:$sb ['redirect'] = "
* Authentication allows a developer to restrict page access to only those guests who have a session variable, defined in the sb_settings.php file:// turn on/off authentication$sb ['useAuthentication'] = true// what variable to check if it exists (such as a session that only exists if they're "logged in")$sb ['hasAuthentication'] = isSet($_SESSION ['auth'] );// the array of pages you should only be able to access without authentication: include circuitpath/extension$sb ['noAuthentication'] = array("index.htm","apple.htm");// you will be redirected here if you attempt to access an internal page that you do not have authentication to$sb ['noAuthenticationRedirect'] = "/sb_20/index.htm?error=authentication"; // if you are authenticated and attempt to access a non-authenticated page, redirect to here (such as the login page)$sb ['authenticationRedirect'] = "/sb_20/hasauthentication.htm";
* Enabling or disabling the template, control, model, or view call:$sb ['useTemplate'] = true;$sb ['useControl'] = true;$sb ['useModel'] = true;$sb ['useView'] = true;
* Custom error page (404: "file" not found):// this page will be included if someone types in an incorrect page address.$sb ['errorPage'] = "error404";
* Personalization of routing file appearance in both the file extension and default page:$sb ['fileExt'] = ".htm";$sb ['defaultPage'] = "index";
* [http://www.danielslaughter.com/projects/ Switch Board Home Page]
Wikipedia contributors, "Model-view-controller," Wikipedia, The Free Encyclopedia, (accessed December 26, 2006).
Wikimedia Foundation. 2010.
Look at other dictionaries:
Model-view-controller — (MVC) is an architectural pattern used in software engineering. Successful use of the pattern isolates business logic from user interface considerations, resulting in an application where it is easier to modify either the visual appearance of the … Wikipedia
Model–view–controller — A general representation of the MVC design pattern. Model view controller concept. The solid line represents a direct as … Wikipedia
Switchboard — The term switchboard, when used by itself, may refer to:*Telephone switchboard *Electric switchboard *Printed circuit board *In computing, Switch board (framework) … Wikipedia
PKP class ET21 — Infobox Locomotive Auto name = ET21 powertype = Electric caption = ET22 351 locomotive builder = Pafawag serialnumber = buildmodel = 3E, 3E/1 builddate = 1957 1971 totalproduction = 726 whytetype = aarwheels = uicclass = Co Co gauge =… … Wikipedia
environment — environmental, adj. environmentally, adv. /en vuy reuhn meuhnt, vuy euhrn /, n. 1. the aggregate of surrounding things, conditions, or influences; surroundings; milieu. 2. Ecol. the air, water, minerals, organisms, and all other external factors… … Universalium
Economic Affairs — ▪ 2006 Introduction In 2005 rising U.S. deficits, tight monetary policies, and higher oil prices triggered by hurricane damage in the Gulf of Mexico were moderating influences on the world economy and on U.S. stock markets, but some other… … Universalium
Abkürzungen/Computer — Dies ist eine Liste technischer Abkürzungen, die im IT Bereich verwendet werden. A [nach oben] AA Antialiasing AAA authentication, authorization and accounting, siehe Triple A System AAC Advanced Audio Coding AACS … Deutsch Wikipedia
Liste der Abkürzungen (Computer) — Dies ist eine Liste technischer Abkürzungen, die im IT Bereich verwendet werden. A [nach oben] AA Antialiasing AAA authentication, authorization and accounting, siehe Triple A System AAC Advanced Audio Coding AACS … Deutsch Wikipedia
Social Protection — ▪ 2006 Introduction With medical costs skyrocketing and government programs scaled back, citizens bore more responsibility for their health care costs; irregular migration, human trafficking, and migrant smuggling posed challenges for… … Universalium
Agriculture and Food Supplies — ▪ 2007 Introduction Bird flu reached Europe and Africa, and concerns over BSE continued to disrupt trade in beef. An international vault for seeds was under construction on an Arctic island. Stocks of important food fish species were reported… … Universalium