I keep getting this error when I am trying to test Faker PHP from github on my server:
Fatal error: Class 'Faker\Provider\en_US\Address' not found in /home/andrew/public_html/JeffWork/src/Faker/Provider/en_US/Address.php on line 6
Link: http://aswanson.net/JeffWork/test/test.php
All of the package files have been installed and uploaded properly, and the code on line 5 & 6 looks like:
class Address extends \Faker\Provider\en_US\Address
{
Please make sure whether the file exists in the folder where your referring for "/home/andrew/public_html/JeffWork/src/Faker/Provider/en_US/Address.php".
Please take a new update with composer with the following
composer require fzaninotto/faker
Now with the updated version 1.6, you will be able to solve this kind of issue make sure to use autoload.php in file where your using.
The following shows the snippet of usage
<?php
require_once 'vendor/autoload.php';
$faker = Faker\Factory::create();
$person = new Faker\Provider\en_US\Person($faker);
$address = new Faker\Provider\en_US\Address($faker);
foreach(range(1,10) as $i){
echo $address->address(),'<br/>';
}
Cheers!
Related
I want to use namespaces class to manual one without using autoload.php to be included. Because I don't want to use all function the class.
I am using this project https://github.com/codenix-sv/coingecko-api to get it's function in my php function.
In the example of using is like this
use Codenixsv\CoinGeckoApi\CoinGeckoClient;
$client = new CoinGeckoClient();
$data = $client->ping();
But I want to change it to require_once. So I put all src folder in my php folder and create this to call the function
require_once 'libs/Api/CoinGeckoClient.php';
$client = new Codenixsv\CoinGeckoApi\CoinGeckoClient;
$data = $client->simple();
First I got this error when trying to access the page.
Fatal error: Uncaught Error: Class 'GuzzleHttp\Client' not found in
C:\xampp\htdocs\te.st\libs\Api\CoinGeckoClient.php:35
Then I try to remove the line "use GuzzleHttp\Client" in CoinGeckoClient.php file.
And got with this error
Fatal error: Uncaught Error: Class 'Codenixsv\CoinGeckoApi\Client' not
found in C:\xampp\htdocs\te.st\libs\Api\CoinGeckoClient.php:35
Is there any way to just use the "simple" function of coingecko only in my php file.
https://github.com/codenix-sv/coingecko-api/blob/master/src/Api/Simple.php
Here is the way I fix this.
load in composer.json like
{
"require": {
"codenix-sv/coingecko-api": "^1.0",
"guzzlehttp/guzzle": "~6.0"
}
}
then do composer update in command window.
In my php file. make sure
use Codenixsv\CoinGeckoApi\CoinGeckoClient;
is placed in top of file. Then do the rest.
Thanks all
That package is prepared to works with composer.
Composer delivered autoloader, to make you work simplier.
If you remove use GuzzleHttp\Client line from CoinGeckoClient.php, there will be no way to send request to the server.
The best option is include composer autoload in your project file, it means you should:
Create composer.json file for you project
Add required library dependency using command: composer require guzzlehttp/guzzle
Add require library dependency using command: composer require codenix-sv/coingecko-api
Inside your project file add folowing line:
require_once(dirname(__FILE__) . '/vendor/autoload.php');
use Codenixsv\CoinGeckoApi\CoinGeckoClient;
$client = new CoinGeckoClient();
$data = $client->ping();
In other way, that will be necessarily to import all files manually. And of course, you haven't to forget about imports for Guzzle client.
I'm trying to include .env file in Codeigniter 3 by following steps:
integrating.env files in CodeIgniter 3.0 using hooks
But, it returns the following error
A PHP Error was encountered Severity: 4096
Message: Argument 1 passed to Dotenv\Dotenv::__construct() must be an
instance of Dotenv\Loader, string given, called in
/application/config/hooks.php on line 5 and defined
Filename: src/Dotenv.php
Line Number: 31
My /application/config/hooks.php file is configured in the same way as indicated in the tutorial:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$hook['pre_system'] = function() {
$dotenv = new Dotenv\Dotenv(APPPATH);
$dotenv->load();
};
I had done a quick research and unable to find a perfect solution for the problem occurred, Can you guys please help me to find out a solution?
I was able to install phpdotenv in a different way from the instructions in the first tutorial.
In this tutorial installation is done without the use of Composer:
PHPDotenv for CodeIgniter (Installation without Composer)
If you try something like that :
$dotenv = Dotenv\Dotenv::create(__DIR__);
I assume the vendor folder is in project/vendor, not inside project/application/vendor folder. Then try this:
$hook['pre_system'] = function() {
$dotenv = Dotenv\Dotenv::create(FCPATH);
$dotenv->load();
};
I'm developping a package for Laravel 5.3+ ( My tests where developped in Laravel 5.3)
I have installed Laravel 5.4, downloaded laravel/browser-kit-testing, and follow upgrade guide.
Now, when I run my tests, I get :
PHP Fatal error: Trait 'Illuminate\Foundation\Testing\DatabaseTransactions' not found
I don't really understand why, because file exists.
In my BrowserKitTestCase.php, I have a reference to
$app = require __DIR__.'/../bootstrap/app.php';
But as I am in my package development folder, I don't think app.php exists, it might be the issue, but can't find out how to fix it...
I tried to change it to:
$app = require __DIR__.'/../../../../bootstrap/app.php';
where app can be found ( I am in /package/author/plugin/tests/ ) but it error remains the same...
Any idea what's happening???
Well I'm stumped. I've been trying to work this out for several hours, plenty of Googles later and nothing. /rant.
I'm new to Auth0 and figured I'd give it a go but I'm getting the error below. I'm using their PHP sample project which you can find here: https://github.com/auth0-samples/auth0-php-web-app/tree/master/00-Starter-Seed/basic-webapp
I've installed composer and installed the dependencies. I've renamed ensured that I have .env setup correctly. I'm running this in XAMPP.
Fatal error: Uncaught Error: Class 'Dotenv\Dotenv' not found in /Users/.../htdocs/oa/dotenv-loader.php:6
I've tried different varations of the dotenv-loader.php show below but with no luck. Does anyone have any advice?
try {
$dotenv = new Dotenv\Dotenv(__DIR__);
$dotenv->load();
} catch(InvalidArgumentException $ex) {
// Ignore if no dotenv
}
// Read .env
$dotenv = new Dotenv\Dotenv('.env');
if(file_exists(".env")) {
$dotenv->load();
}
$dotenv = new Dotenv\Dotenv(__DIR__);
//Check if file exists the same way as dotenv does it
//See classes DotEnv\DotEnv and DotEnv\Loader
//$filePath = $dotenv->getFilePath(__DIR__);
//This method is protected so extract code from method (see below)
$filePath = rtrim(__DIR__, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR . '.env';
if(is_file($filePath) && is_readable($filePath)) {
$dotenv->load();
}
Thanks a lot in advance.
Upon reading Google's login API, I realised you need to run 'composer install' where ever you composer.json is located, this seems to have fixed the issue. I'll update this should this not be the case.
I am trying to use NetDNA to purge cached URLS from MaxCDN and not able to create the NetDNA object - gives me the following error message:
Fatal error: Class 'NetDNA' not found in purgeCacheDev.php on line 8
Any ideas where to look to resolve this error ?
<?php
ini_set("display_errors",1);
error_reporting(E_ALL);
require_once '../vendor/autoload.php';
$api = new NetDNA("aaa","bbb","ccc");
// get account information
echo $api->get('/account.json');
exit;
?>
Try this:
php composer.phar update -o
within your project folder.
Also make sure your IP(s) are whitelisted: http://support.maxcdn.com/tutorials/how-to-whitelist-your-server-ip-to-use-the-api/