Class not found showing Php

懵懂的女人 提交于 2019-12-12 23:04:01

问题


My index.php file exist in public_html/myapp/files directory,And i am trying to use library which exist in same directory public_html/myapp/files. But I am getting error

Class 'SightengineClient' not found in /home/public_html/myapp/files/index.php on line 7

Where i am wrong ? Here is my code

namespace Tests;
use SightengineClient;
$client = new SightengineClient('myapikey', 'secretkey');
$output = $client->check(['nudity'])->set_url('https://d3m9459r9kwism.cloudfront.net/img/examples/example7.jpg');
echo "<pre>";print_R($output);

回答1:


Using the use kewyord will not include the class if you are not managing your project with composer(generating the autoload ) will you can require the file in this way :

require_once('path to SightengineClient file');

$t = new SightengineClient;

Using require_once will ensure that you are include only one time the file .



来源:https://stackoverflow.com/questions/55511242/class-not-found-showing-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!