PHP Fatal error: Class 'Swift_Validate' not found - php

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 )

Related

php Uncaught Error: Class 'BitWasp\Bitcoin\Key\PrivateKeyFactory' not found

im trying to add a library to my php. I already downloaded all the files from composer but a fatal error happended. here is my code :
require_once('vendor/autoload.php');
use BitWasp\Bitcoin\Bitcoin;
use BitWasp\Bitcoin\Address\AddressCreator;
use BitWasp\Bitcoin\Key\PrivateKeyFactory;
use BitWasp\Bitcoin\Key\KeyToScript\Factory\P2pkhScriptDataFactory;
//Rest of my code
ERROR 1 -> Uncaught Error: Class 'BitWasp\Bitcoin\Key\PrivateKeyFactory' not found
ERROR 2 -> Class 'BitWasp\Bitcoin\Key\PrivateKeyFactory' not found
Shouldn't that namespace be BitWasp\Bitcoin\Key\Factory\PrivateKeyFactory?
See here https://github.com/Bit-Wasp/bitcoin-php/blob/1.0/src/Key/Factory/PrivateKeyFactory.php#L5

neo4j graphaware php-client: class not found

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.

Fatal error: Uncaught Error: Class 'Imagick' not found in wordpress custom plugin

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.

PHP Fatal error: Class 'Sightengine\\SightengineClient' not found in

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

Fatal error: exactly/the/good/way/class not found

I got the Fatal Error:
Fatal error: Class 'app\Autoloader' not found in C:\wamp64\www\WE\index.php
In other words:
Fatal error: exactly/the/good/way/class not found
begin of my script index.php
<?php
use \app\Autoloader;
Autoloader::register();
Begin of my autoloader script:
namespace app;
class Autoloader{...}
Arborescence:
Racine local server
app
[...]
Autoloader.php
index.php
Why this fatal error ?? The way mentionned in the error php is right...
Thaks for help !
The use statement will need to have the class available first. Since you haven't added the autoloader, you'll have to require_once the PHP file containing the autoloader, then use the class to import it into your namespace.
After the autoloader is present, it will have the responsibility of finding and loading the classes as they're use'd.

Categories