Fatal Error attempting to use Settings object. Bad Initialization


#1

Hi I am new to Piwik . It is for this reason that I am following the Piwik tutorial . I am following Getting Started Part III. Specifically speaking I am on “Using the new setting”
This is the structure of my Project
MyPlugin
–Reports
----GetMyPlugin.php
–API.php
–Settings.php

When making use of the settings on API.php I am able to do it with just the following line
$settings = new Settings(‘MyPlugin’);

But when attempting the use the Settings object in GetMyPlugin.php class I get an error:


Fatal error: Class 'Piwik\Plugins\MyPlugin\Reports\Settings' not found in C:\xampp\htdocs\piwik\plugins\MyPlugin\Reports\GetMyPlugin.php on line 82

The issue seems to be that when initialization the Settings object it is expecting to find the Settings.php in the Reports folder when it is on root folder. What can I do to solve this issue?


(Matthieu Aubry) #2

Hi there,
maybe you can write
new Piwik\Plugins\MyPlugin\Settings();

or you can use the namespace feature of PHP and declare at the top the namespace for the class you’re using.