public function downCommand(): int
    {
        $url = $this->input->getArg('url');

        if (!$url) {
            $this->output->liteError('Please input you want to downloaded file url, use: url=[url]', 1);
        }

        $saveAs = $this->input->getArg('saveAs');
        $type   = $this->input->getArg('type', 'text');

        if (!$saveAs) {
            $saveAs = __DIR__ . '/' . basename($url);
        }

        $goon = Interact::confirm("Now, will download $url \nto dir $saveAs, go on");

        if (!$goon) {
            Show::notice('Quit download, Bye!');
            return 0;
        }

        Download::file($url, $saveAs, $type);
        // $d = Download::down($url, $saveAs, $type);
        // echo Helper::dumpVars($d);

        return 0;
    }
public function downCommand(): int
    {
        $url = $this->input->getArg('url');

        if (!$url) {
            $this->output->liteError('Please input you want to downloaded file url, use: url=[url]', 1);
        }

        $saveAs = $this->input->getArg('saveAs');
        $type   = $this->input->getArg('type', 'text');

        if (!$saveAs) {
            $saveAs = __DIR__ . '/' . basename($url);
        }

        $goon = Interact::confirm("Now, will download $url \nto dir $saveAs, go on");

        if (!$goon) {
            Show::notice('Quit download, Bye!');
            return 0;
        }

        Download::file($url, $saveAs, $type);
        // $d = Download::down($url, $saveAs, $type);
        // echo Helper::dumpVars($d);

        return 0;
    }
public function downCommand ( ) : int { $ url = $ this -> input -> getArg ( 'url' ) ; if ( ! $ url ) { $ this -> output -> liteError ( 'Please input you want to downloaded file url, use: url=[url]' , 1 ) ; } $ saveAs = $ this -> input -> getArg ( 'saveAs' ) ; $ type = $ this -> input -> getArg ( 'type' , 'text' ) ; if ( ! $ saveAs ) { $ saveAs = __DIR__ . '/' . basename ( $ url ) ; } $ goon = Interact :: confirm ( "Now, will download $url \nto dir $saveAs, go on" ) ; if ( ! $ goon ) { Show :: notice ( 'Quit download, Bye!' ) ; return 0 ; } Download :: file ( $ url , $ saveAs , $ type ) ; // $d = Download::down($url, $saveAs, $type); // echo Helper::dumpVars($d); return 0 ; }
This is a demo for download a file to local
@usage {command} url=url saveTo=[saveAs] type=[bar|text]
@example {command} url=https://github.com/inhere/php-console/archive/master.zip type=bar
This is a demo for download a file to local