Last Updated: February 25, 2016
·
835
· gjerokrsteski

Creating new command interface action at PIMF

Yes, we programmers are lazy and pragmatic guys. Therefore PIMF gives us the posibillity to create our own interactive PHP Command Line Interface actions. That is the easiest way to make some possibility for scaffolding or manipulating data without implementing a whole HTML backend interface.

A action at the controller for inserting a blog-article via command line interface.

public function insertCliAction()
  {
    $title   = Pimf_Cli_Io::read('article title');
    $content = Pimf_Cli_Io::read('article content');

    $entry = new MyFirstBlog_Model_Entry();

    $entry->setTitle($title);
    $entry->setContent($content);

    $res = Pimf_Registry::get('em')->entry->insert($entry);

    var_dump($res);
}

Start your command line interface, go to your PIMF root directory, type following command and follow the instructions:

php pimf blog:insert

Retrieving a list of available app or core commands:

php pimf list

Chose the command you desire:

PIMF v1.6 PHP Command Line Interface by Gjero Krsteski
+------------------------------------------------------+
controller: blog

 action: insert

 action: update

 action: delete

 action: create_blog_table

+------------------------------------------------------+
controller: core

 action: init

 action: create_session_table

 action: create_cache_table

+------------------------------------------------------+

Please find more here https://github.com/gjerokrsteski/pimf