php-rest-service
php-rest-service copied to clipboard
passing a parameter to a __construct
trafficstars
If I have this:
<?php
namespace freshportsAPISearch;
require_once($_SERVER['DOCUMENT_ROOT'] . '/../classes/ports.php');
#GLOBAL $db;
class Search {
protected $db;
function __contructor($db) {
$this->db = $db;
echo 'into __contructor';
}
How can I pass a value to that function?
e.g. if I'm doing this:
Server::create('/--/api/search/', 'freshportsAPISearch\Search')
->setDebugMode(DEBUG)
->collectRoutes()
->run();
That's currently not support. Maybe we could allow to pass in a factory as second argument for Server::create. If you provide a pull-request, I'll merge.