jacwright / RestServer

A PHP REST server for providing a very light-weight REST API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extend the Class with another class

samuelkaufmann opened this issue · comments

Is it possible to add more functionality via the extends in the main API Class controller
class apiController extends dbController {}

Possibly... what are you trying to accomplish by doing so?

I got a DB-Controller and would like to 'extend' the class with the following Class:
'

config = parse_ini_file(__DIR__.'/config/dbconfig.ini'); $this->pdo = new PDO($this->config['engine'].':host='.$this->config['host'].';dbname='.$this->config['dbname'], $this->config['user'],$this->config['password']); } public static function instance() { if(Database::$instance == null) { Database::$instance = new Database(); } return Database::$instance; } public function connection() { return $this->pdo; } } ?>

'

It may work... have you tested it to see? It's not something I've tested myself, but as long as the actual api endpoints are defined in the child class, I think it should work.

Let me know if you get any errors while trying.