PHP code example of daspors / shellphp
1. Go to this page and download the library: Download daspors/shellphp library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
daspors / shellphp example snippets
$cli = \ShellPHP\CmdLine\CmdLine::Make("ShellPHP Test Script","Version 0.0.0.2")
->command('list')
->opt('-f','none')->map('filter')
->arrayArg('folder')
->handler(function($args)
{
extract($args);
var_dump($args);
var_dump(get_defined_vars());
echo "\n --> $filter $folder\n\n";
})
->end()
->command('add')
->opt('-p')->map('path')->text('Local folder to add')
->handler(function($args)
{
extract($args);
echo "Add --> $path\n\n";
})
->end();
$cli->command('remove')->opt('-f');
$cli->go();
class MyModel extends \ShellPHP\Storage\StoredObject
{
public $id = 'int primary autoinc';
public $name = 'text unique';
public $desc = 'text';
}
\ShellPHP\Storage\Storage::Make('my_app_database.sqlite');
$obj1 = MyModel::Make(array('name'=>'obj1'));
$obj1->Save();
MyModel::Make()->set('name','obj2')->Save();
var_dump(MyModel::Select()->like('name','obj%')->results());
$obj1->Delete();
var_dump(MyModel::Select()->results());
$webinterface = \ShellPHP\WebInterface\WebInterface::Make()
->index(__DIR__."/web")
->handler('list',function($request){ return \ShellPHP\WebInterface\WebResponse::Json(array('hello'=>'world')); } )
->go();