singpolyma / openpgp-php

OpenPGP.php is a pure-PHP implementation of the OpenPGP Message Format (RFC 4880).
http://singpolyma.github.io/openpgp-php/
The Unlicense
180 stars 69 forks source link

Provide more guidance for understanding the examples. #76

Closed fabacab closed 5 years ago

fabacab commented 5 years ago

This commit adds an example/README.md file with a litle bit of guidance for running the examples themselves. This is helpful because the examples all rely on the presence of a phpseclib installation available to the PHP interpreter, and while there is a composer.json file to this effect, none of the examples included the Composer autoload.php file.

This commit makes no modifications to the example code itself, but does require_once() the Composer autoload script so that phpseclib loads and avoids causing a fatal error when a new user attempts to run the examples to learn how to use the library.

singpolyma commented 5 years ago

<?php

+require_once dirname(FILE).'/../vendor/autoload.php';

Can you leave the leading blank line, and make the autoload file optional for people not using composer?

Thanks for the readme file, looks great!

fabacab commented 5 years ago

Can you leave the leading blank line, and make the autoload file optional for people not using composer?

Sure! In 76a644a40a15595f3fe621a8f1fa32849ad5d0ad I changed require_once to include_once so the examples will warn rather than error without Composer's autoload.php. If this isn't sufficient I can also guard with an explicit file readability check.

Thanks for the readme file, looks great!

Sure! Thanks for the amazing library. :)

As you know, I have been using this in my WP PGP Encrypted Emails plugin for WordPress for several years and it has been very useful. I'm now returning to work on that plugin by intgrating OpenPGP.js, and so I'm trying to make sure that the keys generated by OpenPGP.js work with this library and vice versa. I am not an OpenPGP expert so I am running into some problems, but before I ask you for any help I want to double-check my own understanding of what's happening, hence my looking much more closely at the examples today.

singpolyma commented 5 years ago

In 76a644a40a15595f3fe621a8f1fa32849ad5d0ad I changed require_once to include_once so the examples will warn rather than error without Composer's autoload.php. If this isn't sufficient I can also guard with an explicit file readability check.

Just throwing an @ on the front of the include directive to suppress any warning is probably sufficient, yeah?

fabacab commented 5 years ago

Just throwing an @ on the front of the include directive to suppress any warning is probably sufficient, yeah?

Yeah, okay. :) Consider it done.

I've also squash-merged these various commits and updated the commit message to reflect all the changes so there is only one, not four, different commits for you to merge.