1 Star 0 Fork 1

dwdcth / php-gui

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

php-gui

Extensionless PHP Graphic User Interface library

made with PHP S2

Build Status Latest Stable Version Software License Packagist

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.

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.

This project aims to solve the most common problems of existing "GUI Projects":

  • 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:

  • PHP 5.6
  • PHP 7
  • HHVM

And OS:

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

Usage

Download the library using composer:

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!

Create the file 'myapp.php':

<?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:

php myapp.php

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

Documentation

We have a Documentation Page

But, if you want to see some examples, just follow the instructions below.

# 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.

PHP <=> Stdin/Stdout Pipes <=> Lazarus Application <=> GUI

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...):

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

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).

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

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.

Examples:

  • 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.

For compiling the lazarus binary:

lazbuild phpgui.lpr

Using Docker

If you are generating the Linux binary, you can use Docker:

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

Test

First install the dependencies, and after you can run:

bin/phing

TO-DO

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

Credits

@gabrielrcouto

@reisraff

License

MIT License

Sponsor

<p align="center"><img src="https://cloud.githubusercontent.com/assets/2197005/14036936/f3457ba0-f21c-11e5-886a-f754e8109c28.png" alt="php-gui" /></p> <p align="center">Extensionless PHP Graphic User Interface library</p> <p align="center"><img src="https://cloud.githubusercontent.com/assets/2197005/14338716/85ef00a2-fc4f-11e5-8ae8-7a0d5be74723.gif" alt="made with PHP S2" /></p> [![Build Status](https://travis-ci.org/gabrielrcouto/php-gui.svg?branch=master)](https://travis-ci.org/gabrielrcouto/php-gui) [![Latest Stable Version](https://poser.pugx.org/gabrielrcouto/php-gui/v/stable)](https://packagist.org/packages/gabrielrcouto/php-gui) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](http://gabrielrcouto.mit-license.org/) [![Packagist](https://img.shields.io/badge/packagist-install-brightgreen.svg)](https://packagist.org/packages/gabrielrcouto/php-gui) ## Table of Contents + [Why](#why) + [Requirements](#requirements) + [Usage](#usage) + [Documentation](#documentation) + [How it works](#how-it-works) + [Contributors Guide](#contributors-guide) + [TO-DO](#to-do) + [Credits](#credits) + [License](#license) ## 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. For many years, GUI projects are being developed for PHP, like [PHP-GTK](http://gtk.php.net/), [PHP-QT](https://sourceforge.net/projects/php-qt/), [wxPHP](http://wxphp.org/) and so many others, but none of them became popular. This project aims to solve the most common problems of existing "GUI Projects": - 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: + PHP 5.6 + PHP 7 + HHVM And OS: + Linux x64 + Windows x64 + Mac OSX (tested on 10.10.x and 10.11.x) ## Usage Download the library using [composer](https://packagist.org/packages/gabrielrcouto/php-gui): #### Stable version ```bash $ composer require gabrielrcouto/php-gui ``` #### Latest version (development) ```bash $ composer require gabrielrcouto/php-gui:dev-master ``` Now, you can build a GUI application. Let's do a Hello World! Create the file 'myapp.php': ```php <?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: ```bash php myapp.php ``` Simple? :clap: You don't need to compile anything, just download the library via composer and use it! :smile: ## Documentation We have a [Documentation Page](https://gabrielrcouto.github.io/php-gui/dist/#/home) But, if you want to see some examples, just follow the instructions below. ```bash # 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. PHP <=> Stdin/Stdout Pipes <=> Lazarus Application <=> GUI 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...): <p align="center"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/6/65/LCLArchitecture.png/440px-LCLArchitecture.png" alt="LCL graph, showing that LCL will use an interface for building the GUI according to the operation system" /></p> 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). The communication (IPC) between PHP and Lazarus is performed using a protocol based on JSON RPC. You can view the specification [here](PROTOCOL.md). ## 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. Examples: - 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](http://www.lazarus-ide.org/index.php?page=downloads). For compiling the lazarus binary: ```bash lazbuild phpgui.lpr ``` #### Using Docker If you are generating the Linux binary, you can use Docker: ```bash lazarus/linux-docker.sh cd lazarus/ lazbuild phpgui.lpr ``` ### Test First install the dependencies, and after you can run: ```bash bin/phing ``` ## TO-DO The "Issues" page from this repository is being used for TO-DO management, just search for the "to-do" tag. ## Credits [@gabrielrcouto](http://www.twitter.com/gabrielrcouto) [@reisraff](http://www.twitter.com/reisraff) ## License [MIT License](http://gabrielrcouto.mit-license.org/) <a target='_blank' rel='nofollow' href='https://app.codesponsor.io/link/bvezX9B9cTJTidmcB4iikNff/gabrielrcouto/php-gui'> <img alt='Sponsor' width='888' height='68' src='https://app.codesponsor.io/embed/bvezX9B9cTJTidmcB4iikNff/gabrielrcouto/php-gui.svg' /></a>

简介

Extensionless PHP Graphic User Interface library 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/dwdcth/php-gui.git
git@gitee.com:dwdcth/php-gui.git
dwdcth
php-gui
php-gui
master

搜索帮助