2017 © Pedro Peláez
 

library php-gui

Extensionless PHP Graphic User Interface library

image

gabrielrcouto/php-gui

Extensionless PHP Graphic User Interface library

  • Friday, April 13, 2018
  • by gabrielrcouto
  • Repository
  • 135 Watchers
  • 1961 Stars
  • 2,093 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 154 Forks
  • 19 Open issues
  • 4 Versions
  • 6 % Grown

The README.md

php-gui, (*1)

Extensionless PHP Graphic User Interface library, (*2)

made with PHP S2, (*3)

Build Status Latest Stable Version Software License Packagist, (*4)

Table of Contents

Why

PHP can be more than a "Web Language", it's a fast language, with a cross platform interpreter and a good CLI. GUI is a natural step for completing this ecosystem., (*5)

For many years, GUI projects are being developed for PHP, like PHP-GTK, PHP-QT, wxPHP and so many others, but none of them became popular., (*6)

This project aims to solve the most common problems of existing "GUI Projects":, (*7)

  • The need for installing an extension
  • Cross platform
  • No external dependencies
  • Easy to install (composer require php-gui) / Easy to use ($button = new Button)

Requirements

The following PHP versions are supported:, (*8)

  • PHP 5.6
  • PHP 7
  • HHVM

And OS:, (*9)

  • Linux x64
  • Windows x64
  • Mac OSX (tested on 10.10.x and 10.11.x)

Usage

Download the library using composer:, (*10)

Stable version

$ composer require gabrielrcouto/php-gui

Latest version (development)

$ composer require gabrielrcouto/php-gui:dev-master

Now, you can build a GUI application. Let's do a Hello World!, (*11)

Create the file 'myapp.php':, (*12)

<?php
require 'vendor/autoload.php';

use Gui\Application;
use Gui\Components\Button;

$application = new Application();

$application->on('start', function() use ($application) {
    $button = (new Button())
        ->setLeft(40)
        ->setTop(100)
        ->setWidth(200)
        ->setValue('Look, I\'m a button!');

    $button->on('click', function() use ($button) {
        $button->setValue('Look, I\'m a clicked button!');
    });
});

$application->run();

Now, run it:, (*13)

php myapp.php

Simple? :clap: You don't need to compile anything, just download the library via composer and use it! :smile:, (*14)

Documentation

We have a Documentation Page, (*15)

But, if you want to see some examples, just follow the instructions below., (*16)

# clone the repository
git clone https://github.com/gabrielrcouto/php-gui.git
cd php-gui

# install dependencies
composer install

# run examples
php examples/01-basic/example.php
php examples/02-animation/example.php
php examples/03-window/example.php
php examples/04-multiple-windows/example.php
php examples/05-canvas/example.php
php examples/06-ping/example.php
php examples/07-php-internals/example.php
php examples/08-alert/example.php   
php examples/09-3d-perspective/example.php 

How it works

To create a GUI without the need for an extension, PHP executes a binary with proc_open and communicates with it using Stdin/Stdout Pipes--it's a fast and cross platform solution., (*17)

PHP = Stdin/Stdout Pipes = Lazarus Application = GUI, (*18)

The binary is created using Lazarus (Free Pascal). After much research, I found a large advantage by using Lazarus over other desktop languages (like C#, Java...):, (*19)

LCL graph, showing that LCL will use an interface for building the GUI according to the operation system, (*20)

It doesn't have any dependencies (except for Linux, which needs GTK), has a good component library, is compiled, open source and has a nice slogan (Write Once, Compile Anywhere)., (*21)

The communication (IPC) between PHP and Lazarus is performed using a protocol based on JSON RPC. You can view the specification here., (*22)

Contributors Guide

Components names

To be an easy to use library, this project will use HTML friendly names for the components, as PHP developers are more familiar with it., (*23)

Examples:, (*24)

  • On Lazarus, the property "caption" is for the text of a button. On php-gui, the property name is "value".
  • On Lazarus, "Edit" is the component for text input, on php-gui, it's "InputText".

Compiling Lazarus App

On your Local Machine

First, you need to install Lazarus., (*25)

For compiling the lazarus binary:, (*26)

lazbuild phpgui.lpr

Using Docker

If you are generating the Linux binary, you can use Docker:, (*27)

lazarus/linux-docker.sh
cd lazarus/
lazbuild phpgui.lpr

Test

First install the dependencies, and after you can run:, (*28)

bin/phing

TO-DO

The "Issues" page from this repository is being used for TO-DO management, just search for the "to-do" tag., (*29)

Credits

@gabrielrcouto, (*30)

@reisraff, (*31)

License

MIT License, (*32)

Sponsor, (*33)

The Versions

13/04 2018

dev-feature/socket

dev-feature/socket http://github.com/gabrielrcouto/php-gui

Extensionless PHP Graphic User Interface library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gabriel Rodrigues Couto

php gui graphic interface

24/02 2018

dev-master

9999999-dev http://github.com/gabrielrcouto/php-gui

Extensionless PHP Graphic User Interface library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gabriel Rodrigues Couto

php gui graphic interface

22/02 2017

dev-ng

dev-ng http://github.com/gabrielrcouto/php-gui

Extensionless PHP Graphic User Interface library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gabriel Rodrigues Couto

php gui graphic interface

08/04 2016

v0.1.0

0.1.0.0 http://github.com/gabrielrcouto/php-gui

Extensionless PHP Graphic User Interface library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gabriel Rodrigues Couto

php gui graphic interface