How do I solve fusionauth php client error 'FusionAuthClient' not found? - fusionauth

when I follow https://github.com/FusionAuth/fusionauth-php-client
I can see error:
PHP Fatal error: Uncaught Error: Class 'FusionAuthClient' not found ... on line 6
My application looks like this:
First application
<?php
require_once 'FusionAuthClient.php';
$apiKey = "7W-yBfeXfniDhu8PR_h0dGkSsPDJlpUYuP9rP2xXd_4";
$client = new FusionAuthClient($apiKey, "http://localhost:9011");
line 6 is last.
composer says all is right
$ composer require fusionauth/fusionauth-client
Using version ^1.6 for fusionauth/fusionauth-client
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing fusionauth/fusionauth-client (1.6.1)
Downloading: 100%
Writing lock file
Generating autoload files
FusionAuthClient.php, ClientResponse.php and RESTClient.php are in the same directory as my test script.
Can you point me into the right direction what is cause of this problem?

Have you looked at the first line of the FusionAuthClient.php file? apparently not.
namespace FusionAuth;
Therefore, the class is not in the global namespace, therefore you need to tell php which namespace it's in:
$client = new FusionAuth\FusionAuthClient($apiKey, "http://localhost:9011");
You're welcome.

That looks the require_once function path is invalid
Do have you same bug when using "require" and not "require_once"?

Related

PHP Fatal error: Class 'jsonserializable' not found in Unknown on line 0

Ubuntu 16.04
PHP 7.0.4
Phalcon 2.1.x
Zephir
$~: php -v
PHP Fatal error: Class 'jsonserializable' not found in Unknown on line 0
When add phalcon.so in php.ini
Somehow I found the answer on and old bug report here:
Segmentation fault after update to 2.1.x
The problem is that the phalcon extension is being loaded before the json extension, so I guess that you, as myself, added the extension=phalcon.so line in the main php.ini
What you have to do is add a file in /etc/php/7.0/mods-available called phalcon.ini with the line in it: extension=phalcon.so
Then you just go and make a softlink that points from /etc/php/7.0/cli/conf.d/50-phalcon.ini to that phalcon.ini file, (important to put a number higher than 20 so it gets loaded after the json extension) and that's it!
Repeat the process to any other configuration that you have for php (apache, nginx, etc).

Fatal error: Class 'PHPUnit_Extensions_Selenium2TestCase' not found in *.php

I am completely new to Seleniu, and am trying to set up PHPUnit with Selenium 2, following this tutorial https://www.youtube.com/watch?v=zva_GETXimI
So far this is what I've done:
Installed PHPUnit using PHAR as instructed here https://phpunit.de/manual/current/en/installation.html
Installed Selenium Server
Upgraded to PHP5.6 (but my Apache is still 2.22 instead of 2.4)
Installed PHPUnit_selenium package using Composer
Created a testLogin.php file:
<?php
class testLogin extends PHPUnit_Extensions_Selenium2TestCase{
public function setUp()
{
$this->setHost('localhost');
$this->setPort(4444);
$this->setBrowser('firefox');
$this->setBrowserUrl('http://localhost/Achievers');
}
}
When I run testLogin.php using 'phpunit testLogin.php' I get an error:
Class 'PHPUnit_Extensions_Selenium2TestCase' not found in /home/osadmin/projects/Sel/testLogin.php on line 5
Since I am just starting out, I have no idea how to fix this. On googling the error, it shows to add this line to my php file:
require_once('PHPUnit/Extensions/Selenium2TestCase.php');
But I'm not sure how I can use this since there is no PHPUnit folder, just a file linked to the PHAR.
Could someone please shed some light on how to fix this issue?
Thanks.
EDIT:
As per Ushakov's suggestion, I tried /path/to/phpunit.phar testLogin.php
But it gives the same error.
If I add this line to the testLogin.php: require_once('/usr/local/bin/phpunit');
and run /path/to/phpunit.phar testLogin.php
I get this:
#!/usr/bin/env php
PHP Notice: Constant __PHPUNIT_PHAR__ already defined in /usr/local/bin/phpunit on line 18
PHP Notice: Constant __PHPUNIT_PHAR_ROOT__ already defined in /usr/local/bin/phpunit on line 19
PHP Fatal error: Cannot redeclare class DeepCopy\DeepCopy in phar:///usr/local/bin/phpunit/myclabs-deep-copy/DeepCopy/DeepCopy.php on line 15
Solved it by adding this line to the PHP file:
require_once 'vendor/autoload.php';
No tutorial I have seen mentions this, but it can be found in github projects
For anyone else coming late to the party - this worked for me:
class testLogin extends \PHPUnit\Extensions\Selenium2TestCase
(Using PHP 7.0.3 and installing Selenium package with Composer ).

Yii 2.0 showing Warning: Module 'mysql' already loaded in Unknown on line 0

I am new to yii 2.0. I installed my first Yii2.o application on my server and configred URL to use user friendly urls. However, I am getting
Warning: Module 'mysql' already loaded in Unknown on line 0
message when I go to the web/about/ URL. I tried to remove the base rout using "defaultRoute" in web.php but that is also not possible.
Please help me to figure out this issue.
That has nothing to do with Yii 2.0. It's a PHP misconfiguration.
Probably, you've enabled mysql extension twice. Search in your php.ini and extensions ini files:
extension=mysql.so
or
extension=mysql.dll
I had the same problem and i fix it by deleting this line in my php.ini:
extension=mysql.so
located in: /etc/php5/apache2/ and restarting apache2 service:
sudo service apache2 restart

How to deploy fuelphp website to server

I'm new to fuelPHP, I developed a simple application and when I uploaded the files to my web server I got those errors :
Notice: Use of undefined constant __DIR__ - assumed '__DIR__' in /home1/tdfdf/public_html/site/site/public/index.php on line 22
Fatal error: require() [function.require]: Failed opening required '/bootstrap.php' (include_path='.:/usr/lib64/php:/usr/lib/php:/usr/share/pear') in /home1/tdfdf/public_html/site/site/public/index.php on line 44
I probably miss some configurations here. I also want to remove this "/public" from the url
Can any one help ?
I found the solution. The DIR is not defined for older versions of PHP . I changed my server settings to run on PHP 5.3 and it worked like magic.
Thanks.

Why my YII need have installed Oracle's Instant Client libraries?

I am playing with Yii framework and now I am investigating Yii Shell. But if I use this command:
yiic shell
I always get this error message:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/oci8.so' - libclntsh.so.11.1: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/pdo_oci.so' - libclntsh.so.11.1: cannot open shared object file: No such file or directory in Unknown on line 0
libdc1394 error: Failed to initialize libdc1394
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/oci8.so' - libclntsh.so.11.1: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/pdo_oci.so' - libclntsh.so.11.1: cannot open shared object file: No such file or directory in Unknown on line 0
Error: index.php does not exist or is not an entry script file.
It is strange for me, because I am gonna to use only mySQL drivers, so why Oracle now? Any idea?
Many thanks for your replies!
Jakub
Please install Oracle client and Open your php.ini, search for oci8.so and php_oci.so, in extensions section you should have something like extension=oci8.so and extension=pdo_oci.so, just comment it with ;. If You have extension=oci8_11g.so comment it as well"
Open your php.ini, search for oci8.so and php_oci.so, in extensions section you should have something like extension=oci8.so and extension=pdo_oci.so, just comment it with ;. If You have extension=oci8_11g.so comment this as well