Skip to content

SuperUserNameMan/popup.php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

popup.php

Displays native popup dialog boxes for PHP CLI on Linux/BSD and Windows desktops.

API :

// OK button
function popup_warning ( string $MESSAGE , string $TITLE = NULL ) : bool ;
function popup_error   ( string $MESSAGE , string $TITLE = NULL ) : bool ;

// YES / NO buttons
function popup_question( string $MESSAGE , string $TITLE = NULL ) : bool ;

// OK button
function popup_info( string $MESSAGE , string $TITLE = NULL , string $TYPE = POPUP_INFO ) : bool ;

If $TITLE is left to NULL, the name of the main PHP script will be used as title for the dialog box.

Example :

<?php
include("popup.php");

popup_warning( "I'm going to ask you a question!" , "WARNING" );

if ( popup_question( "Are you ready?", "The question is ..." ) )
{
  popup_info( "The user is ready.", "Confirmation" );
}
else
{
  popup_error( "The user is not ready." , "ERROR" );
}

Fallbacks :

If the script can't call a native OS or desktop dialog box, it will fallback to terminal user input.

On Windows :

  1. if the PHP module FFI is available, will call MessageBoxW() and will try to use iconv
  2. else, fallback to readline()
  3. else, error.

On Linux/BSD :

  1. try zenity
  2. else, kdialog
  3. else, xmessage
  4. else, readline
  5. else, read

TODO :

  • file selection dialog box
  • text input dialog box

About

Native popup dialog boxes for PHP in CLI mode.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages