Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate and add instructions for using without composer #165

Open
richleland opened this issue May 4, 2017 · 6 comments
Open

Investigate and add instructions for using without composer #165

richleland opened this issue May 4, 2017 · 6 comments
Assignees
Labels

Comments

@richleland
Copy link
Contributor

Several users have asked for the ability to use the library without composer. One example would be for simple standalone scripts. We need to investigate what's involved and add docs/update code as necessary to address.

@rajumsys rajumsys self-assigned this May 5, 2017
@rajumsys
Copy link
Contributor

rajumsys commented May 5, 2017

I'm looking into this

@rajumsys
Copy link
Contributor

rajumsys commented May 6, 2017

So upon spending some time behind it, I feel like we should not try to use it without composer as resolving the dependency manually is a real pain. Here is my current library inclusion looks like

require_once('./message-factory-master/src/RequestFactory.php');
require_once('./message-factory-master/src/ResponseFactory.php');
require_once('./message-factory-master/src/MessageFactory.php');

require_once('./discovery/src/Exception.php');
require_once('./discovery/src/Exception/StrategyUnavailableException.php');
require_once('./discovery/src/Exception/PuliUnavailableException.php');
require_once('./discovery/src/Exception/NotFoundException.php');
require_once('./discovery/src/NotFoundException.php');
require_once('./discovery/src/Exception/DiscoveryFailedException.php');
require_once('./discovery/src/Strategy/DiscoveryStrategy.php');
require_once('./discovery/src/Strategy/PuliBetaStrategy.php');
require_once('./discovery/src/Strategy/CommonClassesStrategy.php');

// require_once('./message/src/MessageFactory/DiactorosMessageFactory.php');
// require_once('./message/src/MessageFactory/SlimMessageFactory.php');
// require_once('./message/src/MessageFactory/GuzzleMessageFactory.php');
require_once('./discovery/src/ClassDiscovery.php');
require_once('./discovery/src/MessageFactoryDiscovery.php');

require_once('./guzzle/src/HandlerStack.php');
require_once('./guzzle/src/Handler/Proxy.php');
require_once('./guzzle/src/Handler/CurlFactoryInterface.php');
require_once('./guzzle/src/Handler/CurlFactory.php');
require_once('./guzzle/src/Handler/CurlHandler.php');
require_once('./guzzle/src/Handler/CurlMultiHandler.php');
require_once('./guzzle/src/Handler/StreamHandler.php');
require_once('./guzzle/src/Middleware.php');
require_once('./guzzle/src/RedirectMiddleware.php');
require_once('./guzzle/src/ClientInterface.php');
require_once('./guzzle/src/Client.php');
require_once('./guzzle/src/functions_include.php');
//

require_once('./promise-master/src/Promise.php');
require_once('./httplug/src/HttpClient.php');
require_once('./httplug/src/HttpAsyncClient.php');


require_once('./guzzle6-adapter/src/Client.php');
require_once('./guzzle6-adapter/src/Promise.php');

require_once('./php-sparkpost/lib/SparkPost/SparkPost.php');
require_once('./php-sparkpost/lib/SparkPost/ResourceBase.php');
require_once('./php-sparkpost/lib/SparkPost/Transmission.php');

And it's not working due to following error:

PHP Fatal error: Uncaught exception 'Http\Discovery\Exception\DiscoveryFailedException' with message 'Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#common-errors

  • Puli Factory is not available

While I believe we can fix the above error (just need to read some more docs/codes) but it's already going insane.

It's due to our library's dependency on pluggable http library.

@rajumsys
Copy link
Contributor

rajumsys commented May 8, 2017

So, finally got it working. The require'ing still looks insane.


require_dir('./http-message-master/src');
require_once('./psr7-master/src/StreamDecoratorTrait.php');
require_dir('./psr7-master/src');
require_once('./httplug/src/Exception.php');
require_once('./httplug/src/Exception/TransferException.php');
require_once('./httplug/src/Exception/RequestException.php');
require_dir('./httplug/src/Exception');
require_dir('./httplug/src');
require_once('./promise-master/src/Promise.php');
require_dir('./promise-master/src');
require_once('./message-factory-master/src/RequestFactory.php');
require_once('./message-factory-master/src/ResponseFactory.php');
require_once('./message-factory-master/src/MessageFactory.php');
require_dir('./message-factory-master/src');
require_dir('./php-stream-filter-master/src');

require_dir('./promise-master/src');
require_once('./message/src/MessageFactory/GuzzleMessageFactory.php');
require_dir('./message/src');
require_once('./discovery/src/Exception.php');
require_once('./discovery/src/Exception/StrategyUnavailableException.php');
require_dir('./discovery/src/Exception');
require_once('./discovery/src/Strategy/DiscoveryStrategy.php');
require_once('./discovery/src/Strategy/CommonClassesStrategy.php');
require_once('./discovery/src/Strategy/PuliBetaStrategy.php');
require_dir('./discovery/src');

require_once('./guzzle-promises-master/src/PromiseInterface.php');
require_once('./guzzle-promises-master/src/RejectionException.php');
require_once('./guzzle-promises-master/src/PromisorInterface.php');
require_once('./guzzle-promises-master/src/TaskQueueInterface.php');
require_dir('./guzzle-promises-master/src');

require_once('./guzzle/src/Handler/CurlFactoryInterface.php');
require_once('./guzzle/src/Handler/CurlFactory.php');
require_dir('./guzzle/src/Handler');
require_once('./guzzle/src/ClientInterface.php');
require_once('./guzzle/src/Exception/GuzzleException.php');
require_once('./guzzle/src/Exception/TransferException.php');
require_once('./guzzle/src/Exception/RequestException.php');
require_dir('./guzzle/src/Exception');
require_dir('./guzzle/src');
require_dir('./guzzle6-adapter/src');

require_once('./php-sparkpost/lib/SparkPost/ResourceBase.php');
require_dir('./php-sparkpost/lib/SparkPost');


use SparkPost\SparkPost;
use GuzzleHttp\Client;
use Http\Adapter\Guzzle6\Client as GuzzleAdapter;


$httpClient = new GuzzleAdapter(new Client());

require_dir is a small function to include all files in a dir. we can't use it always though (where sequence is needed)

if you still believe we should have instructions to use it, i'll probably write a bash script to download all these repo (git or zip), extract so that they can just copy the require_once lines in their script.

@richleland
Copy link
Contributor Author

Some ideas:

  • We write one file that has all the requires in it and then the user can require that
  • We write a bash script that can be run manually
  • Possibly update CI to run the bash script to download the libraries, create a zip of everything, and commit that zip back to the repo

It's also worth looking at how other services handle this to see if we can learn anything from them.

@rajumsys
Copy link
Contributor

rajumsys commented May 8, 2017

We write one file that has all the requires in it and then the user can require that

Yeah, that's what I implied. If we write the bash script to download all libs in a directory, then a giant php file will require them (as path is known, it'll work) and then user just requires that file.

@nosilver4u
Copy link

Other services tend to do things one of two ways:

  1. Have a .zip file available with all dependencies and some sort of autoloader.php file that one can require which in turn requires all the external dependencies. It almost seems that some of them are basically bundling the results of using Composer. So it's almost like a Composer "snapshot" of sorts. But as I'm one of those folks that has never used Composer, I couldn't say for sure if that is the case. It does "appear" to be some sort of auto-generated package usually. Here's one example: https://mandrillapp.com/api/docs/index.php.html
  2. Others have a separate git repository so that you can clone the repo (nice for staying up to date). This approach has the side-effect of automatically making a .zip file available for download if someone is unfamiliar with git.

@tuck1s tuck1s added the wontfix label Mar 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants