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

Class 'jamesiarmes\\PhpEws\\Client' not found #388

Closed
gtorassa opened this issue Jan 16, 2017 · 13 comments
Closed

Class 'jamesiarmes\\PhpEws\\Client' not found #388

gtorassa opened this issue Jan 16, 2017 · 13 comments

Comments

@gtorassa
Copy link

Version (e.g. 1.0.0 dev-master): installed with composer

Microsoft Exchange version: 2010 SP3 RU12

Description of problem: I'm trying to use an example PHP file but I get "Class 'jamesiarmes\PhpEws\Client' not found" error

Example request:

I'm using the find.php example.
I put the file in the home directory of the LAMP server (the same with the "vendor" directory)

Example response:

Nothing happens, in the Apache log file I see the "Class 'jamesiarmes\PhpEws\Client' not found" error

Additional details:

@jamesiarmes
Copy link
Owner

Did you adjust the require_once at the top of the example to point to your autoload file? The examples assume the vendor director is two parent folders up (i.e. the same directory as the the src directory).

@gtorassa
Copy link
Author

Yes, I would have a file not found otherwise

@gtorassa
Copy link
Author

Do I need to put my php file in a specific directory?

@gtorassa
Copy link
Author

If useful I can add that the apache log says that the error is related to the "$version = Client::VERSION_2016;" command, no error is provided for the "use \jamesiarmes\PhpEws\Client;" command

@jamesiarmes
Copy link
Owner

use statements don't generate an error if the namespace can't be found. It sounds like composer isn't finding the library to include it. Can you include a copy of your composer.json?

@gtorassa
Copy link
Author

Here it is:

{
  "name": "php-ews/php-ews",
  "description": "Library for communicating with Exchange Web Services.",
  "homepage": "http://jamesarmes.com/php-ews/",
  "license": "MIT",
  "authors": [
    {
      "name": "James Armes",
      "email": "jamesiarmes@gmail.com"
    }
  ],
  "minimum-stability": "dev",
  "prefer-stable": true,
  "require": {
    "php": ">=5.3.9",
    "ext-soap": "*",
    "jamesiarmes/php-ntlm": "~1.0.0"
  },
  "require-dev": {
    "mustache/mustache": "~2.0"
  },
  "config": {
    "bin-dir": "bin"
  },
  "autoload": {
    "psr-4": {
      "jamesiarmes\\PhpEws\\": "src/"
    }
  },
  "extra": {
    "branch-alias": {
      "dev-master": "1.0.x-dev"
    }
  }
}

@jophut
Copy link

jophut commented Jan 17, 2017

I had the same issue.
Did you run the example from the command line, as mentioned in the README.md?

php find.php

If yes did you noticed a message:

PHP Fatal error: Uncaught SoapFault exception: [Client] Call to undefined function jamesiarmes\PhpNtlm\curl_init() in /home/....

If yes then maybe you do not have the php-curl package installed?

@jamesiarmes
Copy link
Owner

In your issue summary, you said you had installed this library via composer, but your composer.json seems to indicate you're running the example directly from a checkout of php-ews. If this is the case, the examples should work as long the composer autoloader is being required properly. Have you tried running the example directly from it's home within the examples directory?

@gtorassa
Copy link
Author

I'm sorry, I'm not used to install PHP libraries from GitHub. I thought that composer installed all the files needed to use the library.
Now I have copied the directories in my web site (src, script, templates) and I get a different error (after having installed php-curl as suggested by jophuttenhuis):

[:error] [pid 18769] [client 151.28.230.122:54590] PHP Fatal error: Uncaught SoapFault exception: [a:ErrorInvalidServerVersion] The specified server version is invalid. in /home/web/php-ews-master/src/Client.php:1631\nStack trace:\n#0 /home/web/php-ews-master/src/Client.php(1631): SoapClient->__call('FindItem', Array)\n#1 /home/web/php-ews-master/src/Client.php(1631): jamesiarmes\PhpNtlm\SoapClient->FindItem(Object(jamesiarmes\PhpEws\Request\FindItemType))\n#2 /home/web/php-ews-master/src/Client.php(670): jamesiarmes\PhpEws\Client->makeRequest('FindItem', Object(jamesiarmes\PhpEws\Request\FindItemType))\n#3 /home/web/connect_to_exchange.php(78): jamesiarmes\PhpEws\Client->FindItem(Object(jamesiarmes\PhpEws\Request\FindItemType))\n#4 {main}\n thrown in /home/web/php-ews-master/src/Client.php on line 1631

@gtorassa
Copy link
Author

I have changed the Version of Outlook and I get another error:

[:error] [pid 18767] [client 151.28.230.122:54851] PHP Fatal error: Uncaught SoapFault exception: [a:ErrorSchemaValidation] The request failed schema validation: The required attribute 'Traversal' is missing. in /home/web/php-ews-master/src/Client.php:1631\nStack trace:\n#0 /home/web/php-ews-master/src/Client.php(1631): SoapClient->__call('FindItem', Array)\n#1 /home/web/php-ews-master/src/Client.php(1631): jamesiarmes\PhpNtlm\SoapClient->FindItem(Object(jamesiarmes\PhpEws\Request\FindItemType))\n#2 /home/web/php-ews-master/src/Client.php(670): jamesiarmes\PhpEws\Client->makeRequest('FindItem', Object(jamesiarmes\PhpEws\Request\FindItemType))\n#3 /home/web/connect_to_exchange.php(78): jamesiarmes\PhpEws\Client->FindItem(Object(jamesiarmes\PhpEws\Request\FindItemType))\n#4 {main}\n thrown in /home/web/php-ews-master/src/Client.php on line 1631

@jamesiarmes
Copy link
Owner

composer will install all of the dependencies for your project, so you need to add php-ews to your composer.json like so: https://github.com/jamesiarmes/php-ews#installation. This is the preferred way of managing dependencies and installing this library as it allows you to keep them up to date and avoids the necessity of adding those dependencies to your project's source control. See https://getcomposer.org/ for more informaiton on using composer.

Have you altered the example you are trying to use? You said that you're using one of the find examples, but you didn't specify which one. You may want to have a look at #385, as it may be similar to the issue you are now having.

@gtorassa
Copy link
Author

The example I used is "examples/message/find.php".
I've added $request->Traversal = ItemQueryTraversalType::SHALLOW; and now is working.
Thanks to everybody for the help and to you, James, for this library

@SaraG7
Copy link

SaraG7 commented Mar 14, 2018

I generate the "vendor" folder from composer, but the folder "PhpEws" in folder "jamesiarmes" does not generate, so I don't have any Client Object.
I used the same composer.json file which is in your files.
Would you mind helping me with this case?
Thanks

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

No branches or pull requests

4 participants