Jump to content

wxPHP

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Jgmdev (talk | contribs) at 05:40, 7 June 2012 (Added reference). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.


WxPHP
Developer(s)Mário Soares
Jefferson González
Stable release
2.9.4.0 / May 15, 2012; 13 years ago (2012-05-15)
Repository
Written inC/C++ / PHP
Operating systemCross-platform
LicensePHP Lincese
Websitewxphp.org

wxPHP stands for "wxWidgets for PHP" and is a PHP extension that wraps the powerful wxWidgets library, which allows to write native multi-platform graphical user interfaces, in order to create desktop applications on the three major operating systems: Windows, Linux and Mac OS X by using the PHP language.

History

Near 2003 a group of enthusiastic people started writing on mailing lists[1] and forums presenting the idea of a PHP extension that wrapped the wxWidgets library in a similar way that PHP-GTK does for GTK+. A SourceForge project was created[2] and many people joined[3] in an effort to move the cause forward and make it a reality. Despite the will of project members, the same wasn't going anywhere [4] until Mário Soares decided to join in. After Mário joined, the first commits were done to the CVS repository on sourceforge. The first commits consisted of wrapping the wxApp class, wxFrame and some other basic controls, this is when wxPHP first saw the light. Inspired on wrapper generators like SWIG, Mário started a simple code generator that read the output of GCCXML[5] ran over wxWidgets and transformed into a serialized PHP array. This helped save a lot of time on the monotonous task of writing the same code again and again for each class and its methods. After having some basic functionality and controls, Mário wrote an application using wxPHP itself, to assist the code generator on the selection of class methods that it could handle correctly.


In August 2011 Jefferson González wrote an email to Mário offering him to make a website in order to boost wxPHP presence as attract more people and contributors. Jefferson's wife Yaritza Luyando did a design using Inkscape and he wrote the html to make it work. When the website was up and running, Jefferson started playing with the wxPHP sources. He decided to enable more methods and classes, discovering on the way that many features weren't supported by the code generator and extension itself. After several emails Mário came with the idea of parsing the xml output generated by Doxygen from the wxWidget documentation. Jefferson took the task granted and started improving the code generator until he re-wrote it, adding lacking documentation and many features that would enable adding more wxWidgets functionality.

Present

wxPHP now supports around 400 wxWidgets classes and thousands of methods, making it pretty usable to develop a desktop commercial application. The project source code is now hosted on GitHub. A reference generator was written that serves as the documentation of the functionality supported by the wxPHP extension. Also an interface generator[6] has been written in order to get code completion on IDE's like NetBeans and Eclipse. Planning is undergoing to re-write the code generator yet again using a modular and object oriented approach that permits other people to use it to generate code for other PHP wrappers.

GUI Designer

Support for PHP code generation was added by Jefferson González to wxFormBuilder in order to easily create applications, and get people not familiar to the library to get up to speed on learning it.

Example

A minimal frame example that shows how to add a menu bar with menu items, button, status bar and connection of click events.

<?php

//Load the wxPHP module
if(!extension_loaded('wxwidgets'))
{
	dl('wxwidgets.' . PHP_SHLIB_SUFFIX);
}

class MyFrame extends wxFrame
{
	function onQuit()
	{
		$this->Destroy();
	}
	
	function onAbout()
	{
		wxMessageBox("Welcome to wxPHP!!\nBased on wxWidgets 2.9.4 SVN\n\nThis is a minimal wxPHP sample!","About box...");
	}

	function __construct()
	{
		parent::__construct(null ,null, "Minimal wxPHP App", wxDefaultPosition, wxDefaultSize);
		
		$mb = new wxMenuBar();
		
		$mn = new wxMenu();
		$mn->Append(2,"E&xit","Quit this program");
		$mb->Append($mn,"&File");
		
		$mn = new wxMenu();
		$mn->AppendCheckItem(4,"&About...","Show about dialog");
		$mb->Append($mn,"&Help");
		
		$this->SetMenuBar($mb);
		
		$this->m_btnHello = new wxButton($this, wxID_ANY, "Hello World!");

		$this->m_statusBar = $this->CreateStatusBar(2);
		$this->m_statusBar->SetStatusText("Welcome to wxPHP...");
		
		$this->Connect(2, wxEVT_COMMAND_MENU_SELECTED, array($this,"onQuit"));
		$this->Connect(4, wxEVT_COMMAND_MENU_SELECTED, array($this,"onAbout"));
	}
}


class MyApp extends wxApp 
{
	function OnInit()
	{
		$mainFrame = new MyFrame();
		$mainFrame->Show();
		
		return 0;
	}
	
	function OnExit()
	{
		
		return 0;
	}
}

$application = new MyApp();
wxApp::SetInstance($application);
wxEntry();	

?>

References

  1. ^ "wxPHP?". Retrieved 2012-06-06.
  2. ^ "wxPHP has Risen". Retrieved 2012-06-06.
  3. ^ "wxPHP SourceForge Mailing list". Retrieved 2012-06-06.
  4. ^ "wxPHP Progress". Retrieved 2012-06-06.
  5. ^ "GCC-XML". Retrieved 2012-06-06.
  6. ^ "Code Completion Interface File". Retrieved 2012-06-06.