flightphp / core

An extensible micro-framework for PHP
https://docs.flightphp.com
MIT License
2.62k stars 409 forks source link

Call to private Requests::__construct() - register requests class #191

Closed fatihmert closed 9 years ago

fatihmert commented 9 years ago

Hello,

I want register this class to flight, http://requests.ryanmccue.info/

require_once 'lib/Requests.php'; //Request s

Flight::register('requests',"Requests");
$requests = Flight::requests();

//use example
//$requests->get('http://ryanmccue.info/', array('Accept' => 'text/html'));

Error this; Fatal error: Call to private Requests::__construct() from context 'flight\core\Loader' in /opt/lampp/htdocs/flightphp-learn/flight/core/Loader.php on line 123

If It can be override flightphp request class, It's ok.

Thank you for interest.

philo23 commented 9 years ago

It looks like methods on that class are used statically, so I don't think it would make sense to register it with Flight.

If you're using composer you're better off installing Requests that way and then you can just use the class without having to load or register it.

fatihmert commented 9 years ago

Hmm, @philo23 thank you. I am not using composer.

fatihmert commented 9 years ago

So @philo23 How can I do get sample url address with flight request method? Can you show me a sample pattern?

Thank you again.

tamtamchik commented 9 years ago

@fatihmert Flight::request return you request from the browser to your application. In other words, if your user visits / it will give you all information about this request, like headers, path, method, parameters passed, etc.

fatihmert commented 9 years ago

@tamtamchik ok. I understood.

Thank you for fast answer.

tamtamchik commented 9 years ago

@fatihmert try this out. You don't need to do extra lines to make it work with Flight. It should work out of the box.

require_once 'lib/Requests.php'; //Request 

Requests::get('http://ryanmccue.info/', array('Accept' => 'text/html'));

Also as a tip. Try Guzzle.

gerbz commented 8 years ago

In what situation would you register a class vs just including/using it as is?