I am trying to create a basic class and running it from CLI using this command :
php -r 'include "src/main.php"; main::count_by_vendor_id();'
In the constructor of this main class I am initializing another class, but its showing me this error.
PHP Fatal error: Uncaught Error: Class 'App\HttpRequestData' not found in
/var/www/MetroLiveCodingChallenge/src/main.php:12
Stack trace:
#0 /var/www/MetroLiveCodingChallenge/src/main.php(34): App\main->__construct()
#1 Command line code(1): include('/var/www/MetroL...')
#2 {main}
thrown in /var/www/MetroLiveCodingChallenge/src/main.php on line 12
This is my main class :
<?php
namespace App;
require 'vendor/autoload.php';
class main{
private $dataReader;
public function __construct(){
$request = new \App\HttpRequestData();
$response = $request->fetchData();
$this->dataReader = new JsonReader();
$this->collection = $this->dataReader->read($response);
}
public function count_by_price_range(int $minPrice, int $maxPrice): void
{
}
public function count_by_vendor_id(): void
{
echo
print('I am inside count by vendor');
}
}
new main();
This is my HTTPRequestData class :
<?php
namespace App;
class HttpRequestData
{
}