I use this code:
require_once __DIR__."/vendor/autoload.php";
use League\OAuth2\Server\AuthorizationServer;
use League\OAuth2\Server\Exception\OAuthServerException;
use League\OAuth2\Server\Grant\PasswordGrant;
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
$clientRepository = new ClientRepository();
But I get error :
Fatal error: Uncaught Error: Class 'ClientRepository' not found in
/home/a/public_html/app/oauth2.php:23 Stack trace: #0 {main} thrown in
/home/a/public_html/app/oauth2.php on line 23
Maybe, you forgot namespace:
require_once __DIR__."/vendor/autoload.php";
use League\OAuth2\Server\AuthorizationServer;
use League\OAuth2\Server\Exception\OAuthServerException;
use League\OAuth2\Server\Grant\PasswordGrant;
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
use NamespaceClass\ClientRepository; <-- edit
$clientRepository = new ClientRepository();
Related
My webpage gives the "methods with the same name as their class will not be constructors in a future version of php" error with the below code.
When I change the "function settings()" to "function __construct()", the web page gives a fatal error.
Fatal error: Uncaught Error: Call to undefined method validator::settings() in /home/mertcek1563/public_html/rmd2015/sdwf/validator.php:11
Stack trace:
#0 /home/mertcek1563/public_html/rmd2015/z_common.php(103): validator->__construct()
#1 /home/mertcek1563/public_html/rmd2015/z_core.php(22): include('/home/mertcek15...')
#2 /home/mertcek1563/public_html/rmd2015/index.php(2): include('/home/mertcek15...')
#3 {main}
thrown in /home/mertcek1563/public_html/rmd2015/sdwf/validator.php on line 11
How I can fix this code?
class settings
{
var $settings = array();
function settings(){
$this->settings["price"]=array();
$this->settings["price"]["dot"]=".";
$this->settings["price"]["decimals"]=6;
$this->settings["date"]=array();
$this->settings["date"]["delimiter"]="/";
$this->settings["date"]["format"]="dd/mm/yyyy";
$this->settings["number"]=array();
$this->settings["number"]["dot"]=".";
$this->settings["number"]["decimals"]=6;
}
}
Then I end up with fatal error:
Fatal error: Uncaught Error: Call to undefined method
validator::settings() in
/home/mertcek1563/public_html/rmd2015/sdwf/validator.php:11
<?
include_once("settings.php");
class validator extends settings
{
var $errors = array();
var $required = array();
function __construct(){
$this->settings();
}
I am using
php 7.4.3
composer v4.1.4
I have this error
Fatal error: Uncaught Error: Call to undefined method Dotenv\Dotenv::createImmutable() in C:\xampp\htdocs\ecommerce\app\config\_env.php:9
Stack trace:
#0 C:\xampp\htdocs\ecommerce\bootstrap\init.php(8): require_once()
#1 C:\xampp\htdocs\ecommerce\public\index.php(3): require_once('C:\\xampp\\htdocs...')
#2 {main} thrown in C:\xampp\htdocs\ecommerce\app\config\_env.php on line 9
Define base path
_env.php ------------> any other method of defining realpath?
<?php
define('BASE_PATH', realpath(__DIR__.'/../../'));
require_once __DIR__.'/../../vendor/autoload.php';
$dotEnv = Dotenv\Dotenv::createImmutable(BASE_PATH);
$dotEnv->load();
index.php
<?php
require_once __DIR__ . '/../bootstrap/init.php';
$app_name = getenv('APP_NAME');
echo $app_name;
I am trying autoload function in php. The files are all in the same directory.
I have a file called aviation.php with the following code:
class Avaitor{
public function __construct(){
echo "Fly high<br>";
}
}
Then in my autoloader file I am trying to do this:
function __autoload($fileName){
if(file_exists($fileName . ".php"))
require_once $fileName . ".php";
}
//require_once "aviatior.php";
$pilot = new Avaitor();
But I am getting this error:
Fatal error: Uncaught Error: Class 'Avaitor' not found in
/Applications/MAMP/htdocs/php_oop/autoload.php:22 Stack trace: #0
{main} thrown in /Applications/MAMP/htdocs/php_oop/autoload.php on
line 22
Just to test that require_once does find my aviator.php I tried it out and then commented it out.
What am I doing wrong here?
$param['websiteConfigID'] = 729872;
$param['numberOfRecords'] = 10;
$param['numberOfRecords'] = 10;
$client = new SoapClient(WSDL);
$result = $client->__soapCall('GetTicketsStringInputs', array('parameters' => $param));
$result holding this error message....
Fatal error: Uncaught SoapFault exception:
[Client] Function ("GetTicketsStringInputs") is not a valid method for this service in /home/fmticket/public_html/inc/genericLib.php:279
Stack trace:
#0 /home/fmticket/public_html/inc/genericLib.php(279): SoapClient->__soapCall('GetTicketsStrin...', Array)
#1 /home/fmticket/public_html/resultsTicket.php(12): getTickets(Array)
#2 {main} thrown in /home/fmticket/public_html/inc/genericLib.php on line 279
how to resolve it?? plz help.
Your code is calling the remote GetTicketsStringInputs function :
$client->__soapCall('GetTicketsStringInputs', ...
The Fatal error you get indicates :
Function ("GetTicketsStringInputs") is not a valid method for this service
It seems pretty clear : the method you're trying to call doesn't exist, it is not provided by the remote web-service.
So, to fix that Fatal Error, you have to stop calling that function ;-)
You should check the WSDL of your webservice : does it really export such a method ?
This code:
<?php
namespace designblob;
function autoloader($class){
include "wrappers/databaseWrapper.php";
}
spl_autoload_register('autoloader');
?>
throws this error:
Fatal error: Uncaught exception 'LogicException' with message 'Function 'autoloader' not found (function 'autoloader' not found or invalid function name)' in /var/www/xxx/library/autoloader.php:8 Stack trace: #0 /var/www/xxx/library/autoloader.php(8): spl_autoload_register('autoloader') #1 /var/www/xxx/library/debug.php(19): require_once('/var/www/xxx...') #2 {main} thrown in /var/www/xxxm/library/autoloader.php on line 8
Why doesn't it work?
spl_autoload_register('designblob\autoloader');