marcj / php-rest-service

Php-Rest-Service is a very simple and fast PHP class for server-side RESTful JSON APIs.
MIT License
216 stars 74 forks source link

passing a parameter to a __construct #30

Open dlangille opened 7 years ago

dlangille commented 7 years ago

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();
marcj commented 5 years ago

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.