Official packages

REPL



The Mako REPL package is a runtime developer console, interactive debugger and REPL built on top of the awesome Psy Shell.


Installation

Install the package using the following composer command:

composer require mako/repl

Next, add the mako\repl\ReplPackage package to your app/config/application.php config file.


Usage

Start the interactive shell using the following reactor command.

php app/reactor repl

You should see something similar to this:

----------------------------------------------
Type help to see a list of available commands.
----------------------------------------------
Psy Shell v0.8.0 (PHP 7.0.14 — cli) by Justin Hileman
>>>

There's an anonymous container aware class instance available as $mako by default. This allows you to easily interact with services registered in the dependency injection container.

The object also has a public method called getContainer() which, as the name suggests, allows you to access the container directly.

In the example below we're selecting all records from our tests column using the query builder.

>>> $mako->database->getConnection()->getQuery()->table('tests')->all()
=> mako\database\query\ResultSet {#229
	+0: mako\database\query\Result {#230
		+id: 1,
		+created_at: "2016-12-30 10:58:56",
	},
	+1: mako\database\query\Result {#231
		+id: 2,
		+created_at: "2016-12-31 01:21:20",
	},
}