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

Very initial documentation doesn't seem to be accurate #2297

Closed
ghost opened this issue Mar 29, 2021 · 5 comments
Closed

Very initial documentation doesn't seem to be accurate #2297

ghost opened this issue Mar 29, 2021 · 5 comments

Comments

@ghost
Copy link

ghost commented Mar 29, 2021

So as per the instructions if you're not using Composer suggest, I have pointed to the require files and included the 'use' lines as instructed:

require 'phpmailer/src/Exception.php';
require 'phpmailer/src/PHPMailer.php';
require 'phpmailer/src/SMTP.php';

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

However, My editor is flagging this as a syntax error, and sure the PHP page doesn't run stating this:

Parse error: syntax error, unexpected 'use' (T_USE)

How can this go wrong at the very first step? There's something wrong with your documentation I';m sure.

Please help ASAP, I shouldn't be having problems with the very first few lines!

@NiklasBr
Copy link
Contributor

Which version of PHP are you using? Also check #1142

@Synchro
Copy link
Member

Synchro commented Mar 29, 2021

How can this go wrong at the very first step?

Very easily, by using a version of PHP that's so ancient (< 5.3) that it doesn't support namespaces... PHPMailer 6.x requires a minimum of PHP 5.5, as also stated in the docs.

Also the example code has these lines in a different order; the convention is to put use lines before anything else.

@Synchro Synchro closed this as completed Mar 29, 2021
@ghost
Copy link
Author

ghost commented Mar 29, 2021

Uh, why have you closed this? This hasn't been resolved....

My PHP Version is actually 7.4, so no idea what you're talking about there.

And the ordering, they were originally in the order you gave but that showed the issue (so I assumed it because your documentation was wrong and they needed declaring first - which would make sense). But that hasn't fixed it, apologies for that.

Can you re-open this and provide some more info for me please? Just closing the ticket is not very helpful at all. I have a genuine issue here where I believe your documentation to be either wrong, or unhelpful.

Just closing the issue is a slap in the face and not really the response I expected when asking for help.

@ghost
Copy link
Author

ghost commented Mar 29, 2021

For what it's worth, I ditched your code because it doesn't work, and went looking elsewhere. Glad I did now seeing your level of willingness (or not) to help those who ask for help.

Take care of yourself.

@Synchro
Copy link
Member

Synchro commented Mar 29, 2021

The error you're seeing means you have a syntax error somewhere in your own scripts. What the docs say is correct. If it's only an IDE error, it could be that your IDE is set to use the wrong language level.

Asserting that maintainers don't know how to write basic PHP syntax, and insulting their code and documentation isn't a great way to make us want to help you. You're clearly very new to PHP, and the issue you're describing is most likely explained exactly as I said – that you're running an old version of PHP. As such, this is not a PHPMailer problem, so I closed the issue, on which you can still comment.

If you're running PHP 7.4, this (and just this) should run without error (assuming paths are correct):

<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'phpmailer/src/Exception.php';
require 'phpmailer/src/PHPMailer.php';
require 'phpmailer/src/SMTP.php';

echo PHP_VERSION; //for good measure

If you get that same use error, you're running an old PHP version. Run that echo PHP_VERSION; by itself to check what version you're really using.

use statements are not declarations, they are local aliases for imported namespaced classes. They have no effect on the files you load.

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

No branches or pull requests

2 participants