php-rest-service icon indicating copy to clipboard operation
php-rest-service copied to clipboard

passing a parameter to a __construct

Open dlangille opened this issue 9 years ago • 1 comments
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();

dlangille avatar Nov 10 '16 03:11 dlangille

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.

marcj avatar Mar 06 '19 14:03 marcj