Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabled pi command line #1404

Open
linzongshu opened this issue Apr 2, 2016 · 3 comments
Open

Enabled pi command line #1404

linzongshu opened this issue Apr 2, 2016 · 3 comments

Comments

@linzongshu
Copy link
Member

Yii provide a command controller for developers to easily execute php script in server end. Just like:

./yii {controller}/{action}  {param1} {param2}

I look deep into Zend code, and find that Zend also provide a console mode, then we can extend its function and provides a convenient way for developers to develop command line action just like yii does, for example:

www/pi {module}/{controller}/{action} {param1}  {param2} ...

This will be very great for developers to execute script as well as use Pi api.

@taiwen @voltan @Marc-pi

linzongshu added a commit to linzongshu/pi-1 that referenced this issue Apr 2, 2016
@linzongshu
Copy link
Member Author

The function has been achieved in commit 4b552a6

Then how to start a command controller, please following this brief document:

  1. Change the php install path:

Open the www/pi file, and change the php file path in the first line to your php installed path. for example, your php installed in /data/lib/php, the first line should be changed to:

#!/usr/bin/env /data/lib/php/bin/php

Or leaves this file unchanged, and execute the command line by:

/data/php/bin/php  www/pi  {module}/{controller}/{action} {params1}  {params2}
  1. Create a command controller:

Create a 'Command' folder under src/Controller folder of your module.

Add a new controller, for example TestController, and add following codes:

<?php
namespace Module\Merchant\Controller\Command;

use Pi;
use Pi\Mvc\Controller\CommandController;

class TestController extends CommandController
{
    public function indexAction($param1, $param2)
    {
        $module = $this->getModule();
        $model   = $this->getModel('test');
        ...
    }
}

And do what you want to do like you do with front/admin actions. Note that you can output result just with
var_dump and echo other than $this->view()->assign().

@voltan
Copy link
Member

voltan commented Apr 2, 2016

@linzongshu
Hello

I will check it , very interesting , good to see you send pull request on core , hope you will have more time to work on pi on next weeks

@linzongshu
Copy link
Member Author

@voltan
I have spent too much time on my work these times and didn't care much about Pi develop. But it also help me to find things should to be done of the Pi. Such as supporting master-slave mysql, some security issues.
I will continue to focus on these issues and fix them.

taiwen added a commit that referenced this issue Apr 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants