Create and run presentation from Php.

dev-master 2019-11-09 19:48 UTC

This package is auto-updated.

Last update: 2024-05-10 05:32:26 UTC


PhPresent is a library allowing to create a slideshow program in Php, in the same way that RevealJs for Javascript. It is possible thanks to the Php-SDL extension and Imagick extension.

⚠️ This library is freshly new, it mays not work as expected in your particular environment. Give it a try, and feel free to give some feedback about it.


Be sure to have required extensions:

⚠️ Sometimes, we may need some features of Php-SDL not released yet. Be aware that some versions might need to compile the extension directly from the sources.

The create your project and install this library through Composer.

composer require bviguier/phpresent


ℹ️ Have a look to the examples directory to quickly check that all is working fine for you. When your program is running, press h to obtain some help about available commands.

Bootstrapping your presentation


require __DIR__.'/../vendor/autoload.php';

// Contains specific implementation.
use PhPresent\Adapter;
// All stuff related to mathematics.
use PhPresent\Geometry;
// Here we speak about bitmaps, colours, fonts…
use PhPresent\Graphic;
// The heart of the matter, the tools to create a presentation.
use PhPresent\Presentation;

* You need 2 things to create a slideshow:
*  * A theme, to share some graphic expectations between slides (fonts, colors…)
*  * A background slide, that will be displayed… in the background!
$presentation = new Presentation\SlideShow(
    new Presentation\Template\Simple\FullscreenColor(Graphic\Color::white())

// Here, we will have to insert some slides (see next step)

* The Screen class gives information about the rendering area.
* Although the window will be resizeable, this initial screen ratio will be used to define the *safe* zone.
* The safe zone is the larger available area in the screen with the expected size ratio.
* It will guarantee the final rendering of your slides whatever the actual screen size. 
$screen = Presentation\Screen::fromSizeWithExpectedRatio(Geometry\Size::fromDimensions(640, 480));

* The engine that will render your presentation, thanks to SDL extension.
$engine = new Adapter\SDL\Render\Engine($screen);

* The drawer let you create complex images or texts.
* Current implementation uses Imagick extension.
$drawer = new Adapter\Imagick\Graphic\Drawer();

// Let's start the show!
$engine->start($presentation, $drawer);

Using existing slides templates

Some templates are provided in the PhPresent\Presentation\Template\Simple namespace.

    ->addSlide(new Presentation\Template\Simple\TitleAndSubtitle(
        'PhPresent', 'A Slideshow tool'
    ->addSlide(new Presentation\Template\Simple\FullscreenAnimatedImage(
    ->addSlide(new Presentation\Template\Simple\BigTitle(

Creating your own slides templates

Provided templates are very generic, and you may quickly want to create your own. Check 02-creating-slide.php example to see how it works.

Creating animated slides

Here the funny part! Have a look to 03-animating-slide.php example for more details.


  • composer analyse: static code analysis
  • composer cs: code style (composer cs-fix to automatically fix it)
  • composer deps: check dependencies between namespaces
  • composer ci: run all previous commands for CI