Add the file - require_once("/path/to/analytics-php/lib/Segment.php")
Initialise Class - Segment::init(“KEY”)
I am installing via Composer (composer require segmentio/analytics-php), but am not sure how to implement the Class. Currently I am receiving ‘Class ‘App\Segment’ not found’.
The question: How do I make the Class (Segment) available in my setup file? Is it auto loaded when added to the composer file?
You aren’t initializing the class with the correct namespace. If you look at the source files for that package, the class you’re trying to initialize has no namespace. When you try and initialize it as above PHP attempts to concatenate the App namespace, and that doesn’t work. You need to prefix the class with a \ to call it from the root namespace, i.e. \Segment::init('KEY').