src/ScanCommand.php
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $baseUrl = $input->getArgument('url');
        $crawlProfile = $input->getOption('dont-crawl-external-links') ? new CrawlInternalUrls($baseUrl) : new CrawlAllUrls();

        $output->writeln("Start scanning {$baseUrl}");
        $output->writeln('');

        $crawlLogger = new CrawlLogger($output);

        if ($input->getOption('output')) {
            $outputFile = $input->getOption('output');

            if (file_exists($outputFile)) {
                $helper = $this->getHelper('question');
                $question = new ConfirmationQuestion(
                    "The output file `{$outputFile}` already exists. Overwrite it? (y/n)",
                    false
                );

                if (! $helper->ask($input, $output, $question)) {
                    $output->writeln('Aborting...');

                    return 0;
                }
            }

            $crawlLogger->setOutputFile($input->getOption('output'));
        }

        $clientOptions = [
            RequestOptions::TIMEOUT => $input->getOption('timeout'),
            RequestOptions::VERIFY => ! $input->getOption('skip-verification'),
            RequestOptions::ALLOW_REDIRECTS => false,
        ];

        $clientOptions = array_merge($clientOptions, $input->getOption('options'));

        if ($input->getOption('user-agent')) {
            $clientOptions[RequestOptions::HEADERS]['user-agent'] = $input->getOption('user-agent');
        }

        $crawler = Crawler::create($clientOptions)
            ->setConcurrency($input->getOption('concurrency'))
            ->setCrawlObserver($crawlLogger)
            ->setCrawlProfile($crawlProfile);

        if ($input->getOption('ignore-robots')) {
            $crawler->ignoreRobots();
        }

        $crawler->startCrawling($baseUrl);

        return 0;
    }
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $baseUrl = $input->getArgument('url');
        $crawlProfile = $input->getOption('dont-crawl-external-links') ? new CrawlInternalUrls($baseUrl) : new CrawlAllUrls();

        $output->writeln("Start scanning {$baseUrl}");
        $output->writeln('');

        $crawlLogger = new CrawlLogger($output);

        if ($input->getOption('output')) {
            $outputFile = $input->getOption('output');

            if (file_exists($outputFile)) {
                $helper = $this->getHelper('question');
                $question = new ConfirmationQuestion(
                    "The output file `{$outputFile}` already exists. Overwrite it? (y/n)",
                    false
                );

                if (! $helper->ask($input, $output, $question)) {
                    $output->writeln('Aborting...');

                    return 0;
                }
            }

            $crawlLogger->setOutputFile($input->getOption('output'));
        }

        $clientOptions = [
            RequestOptions::TIMEOUT => $input->getOption('timeout'),
            RequestOptions::VERIFY => ! $input->getOption('skip-verification'),
            RequestOptions::ALLOW_REDIRECTS => false,
        ];

        $clientOptions = array_merge($clientOptions, $input->getOption('options'));

        if ($input->getOption('user-agent')) {
            $clientOptions[RequestOptions::HEADERS]['user-agent'] = $input->getOption('user-agent');
        }

        $crawler = Crawler::create($clientOptions)
            ->setConcurrency($input->getOption('concurrency'))
            ->setCrawlObserver($crawlLogger)
            ->setCrawlProfile($crawlProfile);

        if ($input->getOption('ignore-robots')) {
            $crawler->ignoreRobots();
        }

        $crawler->startCrawling($baseUrl);

        return 0;
    }
protected function execute ( InputInterface $ input , OutputInterface $ output ) { $ baseUrl = $ input -> getArgument ( 'url' ) ; $ crawlProfile = $ input -> getOption ( 'dont-crawl-external-links' ) ? new CrawlInternalUrls ( $ baseUrl ) : new CrawlAllUrls ( ) ; $ output -> writeln ( "Start scanning {$baseUrl}" ) ; $ output -> writeln ( '' ) ; $ crawlLogger = new CrawlLogger ( $ output ) ; if ( $ input -> getOption ( 'output' ) ) { $ outputFile = $ input -> getOption ( 'output' ) ; if ( file_exists ( $ outputFile ) ) { $ helper = $ this -> getHelper ( 'question' ) ; $ question = new ConfirmationQuestion ( "The output file `{$outputFile}` already exists. Overwrite it? (y/n)" , false ) ; if ( ! $ helper -> ask ( $ input , $ output , $ question ) ) { $ output -> writeln ( 'Aborting...' ) ; return 0 ; } } $ crawlLogger -> setOutputFile ( $ input -> getOption ( 'output' ) ) ; } $ clientOptions = [ RequestOptions :: TIMEOUT => $ input -> getOption ( 'timeout' ) , RequestOptions :: VERIFY => ! $ input -> getOption ( 'skip-verification' ) , RequestOptions :: ALLOW_REDIRECTS => false , ] ; $ clientOptions = array_merge ( $ clientOptions , $ input -> getOption ( 'options' ) ) ; if ( $ input -> getOption ( 'user-agent' ) ) { $ clientOptions [ RequestOptions :: HEADERS ] [ 'user-agent' ] = $ input -> getOption ( 'user-agent' ) ; } $ crawler = Crawler :: create ( $ clientOptions ) -> setConcurrency ( $ input -> getOption ( 'concurrency' ) ) -> setCrawlObserver ( $ crawlLogger ) -> setCrawlProfile ( $ crawlProfile ) ; if ( $ input -> getOption ( 'ignore-robots' ) ) { $ crawler -> ignoreRobots ( ) ; } $ crawler -> startCrawling ( $ baseUrl ) ; return 0 ; }
@param \Symfony\Component\Console\Input\InputInterface $input
@param \Symfony\Component\Console\Output\OutputInterface $output

@return int
@param \ Symfony \ Component \ Console \ Input \ InputInterface $input @param \ Symfony \ Component \ Console \ Output \ OutputInterface $output