I have folder structure like this
https://i.stack.imgur.com/azW2z.png
And i try to include my classes which is this
Base Class
<?php
namespace koperasi\conn;
use PDO;
use \Exception;
class connection{
public $conn;
private $host = "localhost";
private $uname = "root";
private $pass = "";
private $port = "3306";
private $db = "db_koperasi_sp";
public function __construct(){
try{
$this->getConnection();
} catch(Exception $e){
echo $e->getMessage();
}
}
public function getConnection(){
try{
$make = new PDO('mysql:host='.$this->host.';dbname='.$this->db, $this->uname, $this->pass);
$this->conn = $make;
} catch(PDOException $e){
throw $e;
}
}
public function chkConn(){
}
}
?>
Child Class
<?php
namespace koperasi\conn;
class query extends connection{
public function doQuery($query){
try{
$this->conn->query($query);
$this->conn->execute();
} catch(PDOException $e){
throw $e;
}
}
public function doFetchQuery($query){
try{
$a = $this->conn->query($query);
$a->execute();
return $a->fetchAll();
} catch(PDOException $e){
throw $e;
}
}
}
?>
Testing script
<?php
require "vendor/autoload.php";
use koperasi\conn\query;
use koperasi\conn\connection;
$a = new query();
?>
Composer.json
{
"name": "radito/koperasiproj",
"description": "xxx",
"type": "project",
"license": "GPL",
"authors": [
{
"name": "radito",
"email": "xxxx"
}
],
"minimum-stability": "dev",
"require": {
"dompdf/dompdf": "dev-master"
},
"autoload": {
"psr-4": {
"koperasi\\": "lib/koperasi",
"koperasi_conn\\": "lib/koperasi/conn"
}
}
}
And when i run my program with my testing script it says
Fatal error: Class 'koperasi\conn\connection' not found in E:\htdocs\koperasic\lib\koperasi\conn\query.php on line 5
something seems wrong but I was looking for it and i couldn't find it. I've tried with another script with the same namespace inside the lib\koperasi\conn folder and it runs fine.
thank you