Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

500 error: Class 'ApplicationInsights\WordPress\Settings' not found #21

Open
maxleistner opened this issue Oct 24, 2018 · 3 comments
Open

Comments

@maxleistner
Copy link

I get the following error after activating the plugin:

Class 'ApplicationInsights\WordPress\Settings' not found on Line 13

 3:    Plugin Name: Application Insights
 4:    Description: Integrates a WordPress site with Microsoft Application Insights.
 5:    Version: 2.3
 6:    Author: ApplicationInsights
 7:    License:  MIT
 8:     */
 9:    
10:    require_once 'vendor/autoload.php';
11:    
12:    // Enables Admin configuration experience
13:    $mySettingsPage = new ApplicationInsights\WordPress\Settings();
14:    
15:    // Enables client-side instrumentation
16:    $clientInstrumentation = new ApplicationInsights\WordPress\Client_Instrumentation();
17:    add_action('wp_head', array($clientInstrumentation, 'addPrefix'));

WordPress 4.9.1
PHP 7.2.10-0ubuntu0.18.04.1
Apache/2.4.29 (Ubuntu)

@maxleistner
Copy link
Author

I found the problem :) We have a vendor folder in our system, because we do as well have several dependencies. As require_once 'vendor/autoload.php'; loads the autoloader file relative to the file which calls the require, it searches in our vendor folder. Therefore you should change the call to a more save function, which looks for the file in the right folder ;)

@atjensw
Copy link

atjensw commented Oct 31, 2018

I have the same issue.

@dulfe
Copy link
Contributor

dulfe commented Nov 2, 2018

I had the same problem... in my case only appeared when using OpCache... this fixed the issue.

Change

require_once 'vendor/autoload.php';

to

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

in ApplicationInsightsPlugin.php

I have sent a PR request with that fix (and some other code) yesterday.... you are welcome to test it :)

Hope it helps.

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

No branches or pull requests

3 participants