Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions
HtaccessAnalyzer Class Reference
Inheritance diagram for HtaccessAnalyzer:

Public Member Functions

 __construct (ObjectManagerInterface $objectManager, CurlTransport $curl)
 

Protected Member Functions

 configure ()
 
 execute (InputInterface $input, OutputInterface $output)
 

Detailed Description

Checks if .htaccess is identical to .htaccess.sample.

Definition at line 18 of file HtaccessAnalyzer.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( ObjectManagerInterface  $objectManager,
CurlTransport  $curl 
)
Parameters
ObjectManagerInterface$objectManager
CurlTransport$curl

Definition at line 45 of file HtaccessAnalyzer.php.

48  {
49  parent::__construct();
50  $this->objectManager = $objectManager;
51  $this->curl = $curl;
52  }
$objectManager
Definition: bootstrap.php:17

Member Function Documentation

◆ configure()

configure ( )
protected

Configure command.

Returns
void

Definition at line 59 of file HtaccessAnalyzer.php.

60  {
61  parent::configure();
62  $this->setName('troubleshooting:check-htaccess')
63  ->setDescription('Check .htaccess file is present. It is needed to run cli commands via browser url.');
64  }

◆ execute()

execute ( InputInterface  $input,
OutputInterface  $output 
)
protected

Execute command.

Parameters
InputInterface$input
OutputInterface$output
Returns
void @SuppressWarnings(PHPMD.UnusedFormalParameter)

Definition at line 74 of file HtaccessAnalyzer.php.

75  {
76  \PHPUnit\Util\Configuration::getInstance(MTF_PHPUNIT_FILE)->handlePHPConfiguration();
77  $output = $this->objectManager->create(
78  \Magento\Mtf\Console\Output::class,
79  ['output' => $output]
80  );
81  try {
82  $output->writeln("Checking .htaccess file...");
83  $this->curl->write($_ENV['app_frontend_url'] . $this->commandPath, [], CurlInterface::GET);
84  $this->curl->read();
85  $responseCode = $this->curl->getInfo(CURLINFO_HTTP_CODE);
86  if ($responseCode != 200) {
87  $message['error'][] = 'Your .htaccess file doesn\'t exist. '
88  . 'Please, create it from to .htaccess.sample.';
89  $output->outputMessages($message);
90  }
91  $this->curl->close();
92  } catch (\Exception $e) {
93  $output->outputMessages(['error' => [$e->getMessage()]]);
94  }
95  $output->writeln(".htaccess check finished.");
96  }
$message

The documentation for this class was generated from the following file: