Sybio / ImageWorkshop

ImageWorkshop is a PHP5.3+ library that helps you to manage images based on GD library
http://phpimageworkshop.com/
Other
861 stars 189 forks source link

PHP Fatal error: Uncaught Error: Class "packages\PHPImageWorkshop\ImageWorkshop" not found #137

Closed mapattacker closed 3 years ago

mapattacker commented 3 years ago
Q A
Bug report? no
Feature request? no
Usage question? yes
PHP version used 8.0.7

I think this should be something basic, but as I am a somewhat novice PHP user, would greatly appreciate your advice.

Below is how I structure my directory.

image

This is the test.php which I used to try to call the package.

<?php
    use packages\PHPImageWorkshop\ImageWorkshop;
    // require_once('packages/PHPImageWorkshop/Core/ImageWorkshopLayer.php');
    // require_once('packages/PHPImageWorkshop/Exception/ImageWorkshopException.php');

    $norwayLayer = ImageWorkshop::initFromPath('images/acacia_auriculiformis1.jpg');
     $watermarkLayer = ImageWorkshop::initFromPath('../copyright.jpg');
 
    // $norwayLayer->addLayer(1, $watermarkLayer, 12, 12, "LB");
    //  
    // $image = $norwayLayer->getResult();
?>

However, I got an error saying

PHP Fatal error:  Uncaught Error: Class "packages\PHPImageWorkshop\ImageWorkshop" not found in /opt/lampp/htdocs/uforest/test.php:6
jdecool commented 3 years ago

I think this code will be more correct:

<?php

use PHPImageWorkshop\ImageWorkshop;

require_once('packages/PHPImageWorkshop/Core/ImageWorkshopLayer.php');
require_once('packages/PHPImageWorkshop/Exception/ImageWorkshopException.php');

$norwayLayer = ImageWorkshop::initFromPath('images/acacia_auriculiformis1.jpg');
$watermarkLayer = ImageWorkshop::initFromPath('../copyright.jpg');

// $norwayLayer->addLayer(1, $watermarkLayer, 12, 12, "LB");
//  
// $image = $norwayLayer->getResult();

I close this issue as it's not an ImageWorkshop issue.

I can recommend you to learn PHP.