GraPHP

GraPHP is a lightweight PHP framework that uses a graph abstraction as your data model. It's full MVC and has almost zero boilerplate. Your models are code and work seamlessly without migrations or scripts. Prototype fast without having to worry about altering the DB. Adding or removing nodes, edges, and fields is as easy as chaning a few lines of code. GraPHP is currently in development but ready enough to try out.

See on Github »

Graph Abstraction

All your data is represented as nodes and edges. Nodes are your objects. They can have arbitrary data which can be indexed so that you can retrieve a node by its data. Your nodes can also be connected by typed edges. An edge represents an association between two nodes.

Nodes, the data they hold, and the edges that connect them are all coding time decisions. Most changes (including adding index fields) can be done withtout modifying the DB or running a migration. In practice, this means prototyping is blazing fast, and no decision has to be permanent. If you forgot to add something to your model, adding a new field is a single line of code.

User Node

class User extends GPNode {
  protected static function getDataTypesImpl() {
    return [
      new GPDataType('name', GPDataType::GP_STRING, true),
    ];
  }
  protected static function getEdgeTypesImpl() {
    return [
      new GPEdgeType(BankAccount::class),
    ];
  }
}

Bank Account Node

// No need to declare data if you don't want to index it.
class BankAccount extends GPNode {}

Magic Methods on objects

Your Node objects will have super-powers. Instead of tons of codegen boilerplate, your objects will respond to intuitive methods. e.g. If you node has a name as a declared data field, it will also have methods getName() and setName(). If you node has a friend edge it will have methods like addFriend(), loadFriend(), and getFriend(). If you index a data field, you also get static loader methods like User::getByName(). All of this happens without the need to run scripts or write tons of boilerplate.

Create instances:

$user = (new User(['name' => 'Jane Doe']))->save();
$bank_account = new BankAccount(['accountNumber' => 123, 'balance' => 125.05]);
$bank_account->save();
$user->addBankAccount($bank_account)->save();

…and load them later:

$user = User::getOneByName('Jane Doe');
$account = $user->loadBankAccount()->getOneBankAccount();
echo $account->getData('balance'); // 125.05

Full MVC

Use your models with simple controllers and create reusable views by embeding php in the html.

Controllers

class MyController extends GPController {

  public function helloWorld() {
    GP::view('admin/explore_view', ['title' => 'Hello World']);
  }
}

Views

<html>
  <title>
    <?= $title ?>
  </title?
  <body>
    <a href="<?= OtherController::getURI('some method') ?>">
      Go to other controller
    </a>
  </body>
<html>

Status

GraPHP is in active development. It's not ready for production, but it's functional enough to try out. For now, you can only get it on Github but once it is stable enough you will be able to download it here.