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

Please add installation instructions to the README.md #3

Closed
sblandford opened this issue Dec 1, 2016 · 3 comments · Fixed by #24
Closed

Please add installation instructions to the README.md #3

sblandford opened this issue Dec 1, 2016 · 3 comments · Fixed by #24

Comments

@sblandford
Copy link

sblandford commented Dec 1, 2016

I'm a bit new to using composer and despite my best efforts to figure it out I'm not able to get any of the examples to work since none of the classes are ever found. I would really appreciate some basic install instructions even if I should be able to find them elsewhere.

The steps I am following are:

  • Install composer. Tried both "apt install composer" and downloading the current composer.phar.
  • Create a composer.json file with the following contents...
{
    "require": {
        "jstewmc/rtf": ">=0.4.3"
    }
}
  • Type composer install, or "php composer.phar install". Library seems to install OK.
  • Create a php file, test.php, with the following at the top...
<?php

require __DIR__ . '/vendor/autoload.php';
  • Paste in one of the examples from README.md
  • Try to run it from the command line using "php test.php"
  • Get some error message such as "PHP Fatal error: Uncaught Error: Class 'Jstewmc\Stream\Text' not found in /home/user/Documents/jstewmc/test.php:11"

Would love to know where I am going wrong.

Using PHP 7.0.8-0ubuntu0.16.04.3 (cli) ( NTS ).

@sblandford
Copy link
Author

Update: I managed to get one example to work. It seems that the use statement path must extend to explicitly include the name of the class to be used and the "getFirstElement" and "getLastElement" methods don't exist. They should, AFAIK, be getFirstChild and getLastChild.

Here is some working code...

<?php

require __DIR__ . '/vendor/autoload.php';

use Jstewmc\Rtf\Snippet;

$snippet = new Snippet('\cxds ing');

echo $snippet . "\n"; 
echo $snippet->getFirstChild() . "\n";  // prints "\cxds "
echo $snippet->getLastChild() . "\n";   // prints "ing"

@jstewmc
Copy link
Owner

jstewmc commented Dec 5, 2016

Oh, man. Sorry for the trouble.

Yes, you are correct. The examples' use statements should include the full classname (e.g., use Foo/Bar/Baz and in the code new Baz()) or the instantiations should include the last imported namespace (e.g., use Foo/Bar and in the code new Bar\Baz()). The wrong method names were just my fault. I probably forgot to update them after I changed a method name early on. I'm sorry about that!

I'm about to create a new major version: breaking the classes up into separate repositories, adding PHP7 compatibility, removing old type-checking code, etc. Hopefully, it'll be a little easier to manage and update (but don't worry I'll still bring them all together into jstewmc/rtf). When I do all that, I'll update the README as well and add installation instructions.

Thank you for the heads up!

@ggutierrezbarbeito
Copy link

Hello, I´m trying to use RTF Files as reports, so I need to load one template form an rtf file and change some specific parametrized fields, how can i iterate to find the needed one??

$document = new Document();
$document->load(DIR . '\filename.rtf');
$childs = $document->getRoot()->getFirstChild()->getNextSibling();
while?????
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants