2017 © Pedro PelĂĄez
 

library phlip

Embeddable scripts for PHP

image

webgraphe/phlip

Embeddable scripts for PHP

  • Wednesday, March 7, 2018
  • by jpleveille
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Embeddable scripts for PHP

Total Downloads Latest Stable Version License, (*1)

Phlip (pronounced \ˈflip\) is an embeddable scripting language for PHP based on s-expressions., (*2)

How does it work?

A lexer tokenizes scripts and a parser assembles data structures. A script's behavior originates from data and code elements resolved from a controlled scope., (*3)

Integration is simpler with the Phlipy dialect., (*4)

Refer to Webgraphe\Phlip\Tests\Unit\ReadmeTest for the example below:, (*5)

<?php

use Webgraphe\Phlip\Phlipy;
use Webgraphe\Phlip\Program;

// Tokenize and parse code into a program
$program = Program::parse('(lambda (x) (* x x))');
// Bootstrap a new scope with different level of Phlipy dialects
$scope = Phlipy::basic()->getScope();
// Execute program within said scope
$square = $program->execute($scope);

// In this case, return value is an anonymous function - a lambda - calculating the square of a number
// as per source code "(* x x)"
var_dump($square(M_PI)); // (double)9.8696044010894

How to install

Add a dependency on your projects with Composer, using composer require webgraphe/phlip. You may also install it globally with composer global require webgraphe/phlip., (*6)

Why use Phlip

  • Embeddable scripts mean data becomes code
  • Easy to use
  • Easy to learn
  • Build your own dialect!
  • Interoperable with PHP Classes
  • Create test suites with phlipunit (built on top of PHPUnit)
  • Ships with a literal REPL (loop (print (eval (read))))

DISCLAIMER, (*7)

Lisp is a often considered a Homoiconic (code as data) language. Despite Phlip's usage of S-expressions and a somewhat successful attempt at reproducing McCarthy's eval, as the author I do not consider Phlip be an homoiconic language as it relies on PHP's internal data structures such as array, stdClass, native scalars, Closure and invokable classes for performance and convenience., (*8)

Phlip is embeddable in PHP and was built to allow transportation of code and data in a manner that can stay relatively secure, provided that functionalities interoperable with PHP stay in check., (*9)

For reference: Webgraphe\Phlip\Tests\System\LispTest::testMcCarthyEval(), (*10)

The Versions

07/03 2018

dev-master

9999999-dev https://github.com/webgraphe/phlip

Embeddable scripts for PHP

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

by Jean-Philippe Léveillé

lisp dialect embeddable s-expression

07/03 2018

v0.3.0

0.3.0.0 https://github.com/webgraphe/phlip

Embeddable scripts for PHP

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

by Jean-Philippe Léveillé

lisp dialect embeddable s-expression

24/02 2018

v0.2.0

0.2.0.0 https://github.com/webgraphe/phlip

A dialect for PHP in the form of s-expressions like LISP

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

by Jean-Philippe Léveillé

lisp dialect s-expression

18/02 2018

v0.1.2

0.1.2.0 https://github.com/webgraphe/phlip

A dialect for PHP in the form of s-expressions like LISP

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

by Jean-Philippe Léveillé

lisp dialect s-expression

10/02 2018

v0.1.1

0.1.1.0 https://github.com/webgraphe/phlip

A dialect for PHP in the form of s-expressions like LISP

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

by Jean-Philippe Léveillé

lisp dialect s-expression

09/02 2018

v0.1.0

0.1.0.0 https://github.com/webgraphe/phlip

A dialect for PHP in the form of s-expressions like LISP

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

by Jean-Philippe Léveillé

lisp dialect s-expression