after trying different ways of using the API from sightengine I can' get it to work, I followed the instructions on their site , installing via composer, but when I try to use it, I get the Class not found error in apache:
PHP Fatal error: Uncaught Error: Class 'Sightengine\\SightengineClient' not found in /var/www/html/photobooth/app.php
PHP file:
<?php
use Sightengine\SightengineClient;
$client = new SightengineClient('xxxxxxx', 'xxxxxxxxx');
Missed to include the file.
When installing using composer, we have to include the file in our code
require_once 'vendor'.DIRECTORY_SEPARATOR.'autoload.php';
This will help you to include the file in code, so you can start using the class/objects
Related
When I tray to access my neo4j-DB via Graphaware's php-client using http-protocol, I get the following error message:
Fatal error: Class 'GraphAware\Common\Result\AbstractRecordCursor' not found in ...
On the other hand when I'm using the bolt-protocol t says:
Fatal error: Uncaught Error: Call to undefined method GraphAware\Bolt\Result\Result::getResult() in...
At the beginning of my code I have used
require_once 'vendor/autoload.php';
use GraphAware\Neo4j\Client\ClientBuilder;
so I thought the classes should be autoloaded which is obviously not the case.
What's wrong?
I have solved this issue by replacing the respective syntax for queries of the example-files by one out of the README.
I am creating wordpress custom plugin and in that i will use 'imagick' class. Here are the sample code that is use in my custom plugin php file:
$imagick = new Imagick();
$imagick->readImage($b);
$imagick->writeImage('output.jpg');
but in that code i have an error like:
Fatal error: Uncaught Error: Class 'Imagick' not found...
Fatal error: Uncaught Error: Class 'Imagick' not found
It means that this class is not defined and therefore cannot be found.
Imagick is a native php extension.
You need to make sure that this extension exists on your server and configured.
You might need your hosting provider assistance for this or in case you have a full access to the server install it by yourself.
Create a php file with the following code:
<?php
phpinfo();
Run it. It should show you all the existing and available extensions on your server. Check that value for Imagick.
I'm writing a web app, and I created a scraper to get data from my own site.
I have a few dependencies, so they're being extended, but now that I'm trying to run this php script from exec, and it doesn't work, I get the error:
PHP Fatal error: Uncaught Error: Class 'App\Helpers\ScraperHelper' not found in /home/username/public_html/App/Libraries/Scraper/execute.php:6.
Begin.php
This is how I'm calling my script:
exec('/usr/bin/php/ home/username/public_htm/App/Libraries/Scraper/execute.php');
Execute.php
namespace App\Libraries\Scraper;
use \App\Helpers\ScraperHelper;
$recipe = new ScraperHelper();
$recipe->fromFeed();
fromFeed() runs the script that's included in the ScraperHelper class, scrape the information from the site and inserts it into the database.
I've tried removing all the namespaces, and using require with full server path, but there are a 4 other dependencies that doesn't allow me to access them.
require_once '/home/username/public_html/App/Helpers/ScraperHelper.php';
require_once '/home/username/public_html/App/Models/Food.php';
require_once '/home/username/public_html/Core/Model.php';
Composer is autoloading two folders. Core and App, but I figure that the exec function ignores it which is why I keep getting Uncaught Error.
I believe exec isn't being able to process the namespaces and use calls, I included all the files with require_once and it worked, but It's not what I need still, I really need to know how to make exec process namespaces, use calls.
I have aws sdk in current directory. I have included sdk in file like this..
include("Aws/S3/S3Client.php");
use Aws\S3\S3Client;
class myClass{
}
It gives me fatal error like..
Fatal error: Class 'Aws\Common\Client\AbstractClient' not found in /somePath/Aws/S3/S3Client.php on line 117
Please help.
To avoid all these error while sending request or getting response from AWS, set up AWS SDK using http://aws.amazon.com/developers/getting-started/php/, or use
git clone https://github.com/awslabs/aws-php-sample.git
curl -sS https://getcomposer.org/installer | php
php composer.phar install
By installing AWS SDK in this way, you'll get a file at vendor/autoload.php
It'll take care of all the required files into the script.
I had the exact same issue and wasn't able to find an answer anywhere. So, in case anyone has the same problem in the future, for me it was simply a matter of using a version of AWS SDK that was incompatible with my PHP version.
Once I upgraded my server's PHP version it all worked fine.
I am trying to use Swift_Validate::email($email) and I get a php error: PHP Fatal error: Class 'Swift_Validate' not found.
I have the latest version of swiftmailer. Is there some preference settings I need to do?
I have tried including the Validate.php file, but then I get the error: PHP Fatal error: Class 'Swift_DependencyContainer' not found.
I include DependencyContainer.php and I get the error PHP Fatal error: Class 'Swift_DependencyException' not found.
I include DependencyException.php and I get the error: Class 'Swift_SwiftException' not found.
I include SwiftException.php and I still get the same error.
I think I must not have the preferences set up correctly. I am calling:
"require_once($dir.'/swift/swift_required.php');"
The code I am using for the validation is:
if (!Swift_Validate::email($email))
{ $error = true; }
Any help would be greatly appreciated. Using latest Apache and PHP.
Try require_once dirname( __FILE__) . '/lib/swift_required.php'; to use the built-in autoloader, where lib is subfolder of folder where is the current file ( for default directory structure of the library )