OSEZNO PhP framework – Wikipedia, free encyclopedia

Osezno PHP Framework (OPF) is a Framework for PHP that implements its programming style in a web application, allowing the standardization of the code on an MVC design pattern (controlling view model); This pattern generates independent views based on the use of HTML templates, user event control and data modeling. The above added to an abstraction of the database using Active Record and clean access to information through the use of grids that are in turn capable of exporting this information to formats such as XLS, HTML and PDF. Data processing is processed by applying Ajax for asynchronous communication with the server. It is an initiative for Colombians that aims to reduce the development time of applications written in the PHP language.

  • Views supported by HTML templates defined with work areas.
  • Application of the MVC software construction pattern.
  • Data shipping and reception via Ajax.
  • Abstraction of the database to objects of the PHP programming language using Active Record.
  • Implementation of dynamic lists (Grids)
  • Generation of HTML forms.

Controlling View Model [ To edit ]

The use of the MVC pattern guarantees scalability as an attribute of quality of this project. The MVC separates the presentation layer data and the level of user events. To display the views, HTML templates defined by the programmer on which work areas are declared (see figure not II) are used that will be replaced by content of the data model of the module to which it applies and that in turn any user event That occurs in this view will be handled by an event controller that allows the user to interact with the application giving control to it. OSEZNO PHP Framework proposes the following implementation of the MVC: (see figure no)

  1. The model feeds the initial view.
  2. The user interacts with the view, makes a request.
  3. The controller is notified of the requested action. The controller accesses the model by updating or modifying it.
  4. The controller obtains the data of the processed model.
  5. The controller updates the model -based view view
Figure No 1:
Proposed MVC

Shipping and receiving data via Ajax [ To edit ]

Any change that manifests in the view of the module will have as the first option the use of Ajax to manipulate changes in that user view where it allows you quickly adding modifications to that view, saving on the consumption of connection resources to the server of the server applications allowing them only to update the area or objective of the operation of the event controller. If you do not decide to use Ajax it is possible to adopt traditional forms (post and get)

Abstraction of the database to objects of the PHP programming language via Active Record [ To edit ]

It allows to maintain control in the structures of the tables of the database to which it is connected as an organized way to access the data contained within them. Significantly decreases the writing of SQL code by changing it by PHP code in which names of tables of programming language and database fields are changed by attributes of these objects; From these objects it is possible to perform raw operations.

 $ books  =  new  books ();  $ books -> name  =  "Some value" ;  $ books -> price  =  12345 ;  $ books -> save ();  // This code would replace the SQL sentence: INSERT INTO BOOKS (NAME, PRICE) VALUES (‘SOME VALUE’, 12345);  

Implementation of dynamic lists (Grids) [ To edit ]

It allows the developer to visualize the content of a table or SQL query through the use of grids that we call dynamic lists in OPF. Using this utility, it is possible to filter through the use of rules very similar to SQL operators such as ‘Like’, paying the content of the consultation, limiting the record content per page, ordering in an ascending or descending way the columns associated with the Consult, execute events associated with a certain guided record by its ID (PK) or multiple previously selected records and as the final objective of these tasks the option to export to different file formats (PDF, XLS and HTML) the result of the sum of the sum of These operations.

How do you work [ To edit ]

The basic composition of a module consists of four files; three with PHP (.php) extension and one of extension (.tpl) where each fulfills a different function. It is then explained basically with example source code and the task that each file meets.

  • index.php
  • handlerEvent.php
  • DataModel.php

template.tpl [ To edit ]

An HTML template is declared with the following basic labels:

And work areas that will be replaced by content defined by the developer are predefined.

< html >  < head > head >  < nowiki >  < body > nowiki >   < div  align = "center" > {contents} div >  body >  html >  

index.php [ To edit ]

  • Within the file (Index.php) the contents are assigned to the pre-defined areas of the template and a call is made to the template.
  • Own content is assigned to the areas defined in the template and a call is made to the template to show it.
 include  'handlerEvent.php' ;  // We assign to the areas the contents  $obj -> assign ( 'content' , $data -> getForm ());  // We show the template  $obj -> call_template ( 'template.tpl' );  ?>  

DataModel.php [ To edit ]

  • The basis of the module on a data model (datamodel.php) is constructed appropriate according to the creation of the application module.
  • Within the data model, the necessary classes that create all the necessary objects to initially feed the view are created
 include  '../ ../config/configaplication.php' ;  class  Data Model  {  public  function  getForm  () {  $form  =  new  Opf_myform ( 'Form1' );  // We add objects to a form  $form -> addText ( 'Your name:' , 'name' );  $form -> addButton ( 'BTN1' , 'To send' );  // We add events to objects  $form -> addEvent ( 'BTN1' , 'onclick' , 'myEvent' );  return  $form -> getForm ();  }  }  $ data model  =  new  Data Model ;  ?>  

handlerEvent.php [ To edit ]

  • An event controller delegates the actions produced in the view (Index.php).
  • Any event produced in the main view is managed by a user event handling class that delegates the actions that the user wishes to perform again by the model to obtain an answer and feed the main view again
 include  'DataModel.php' ;  class  events  extends  Opf_Mycontroller  {  // We declare user events  public  function  myEvent  ( $dataForm ) {  $this -> alert ( 'Hour:' . $dataForm [ 'name' ]);  return  $this -> response ;  }  }  $ discovered  =  new  events ( $ OBJXAJAX );  $obj  =  new  Opf_oose ( $ OBJXAJAX , $theme );  $obj -> setPathFolderTemplates ( PATH_TEMPLATES );  $ OBJXAJAX -> processRequest ();  ?>  

external links [ To edit ]