I'm trying to generate a custom report from Authorize.net using their API but cannot get the SDK to load without errors.
I created a post on the developer board HERE as well as sending an email request to their support team. The issue was supposed to have been fixed with a temporary patch HERE. But the errors persist.
Does anyone have any ideas as to how to work around this issue?
My Code:
<?php
error_reporting(-1); ini_set('display_errors', 'On');
date_default_timezone_set('UTC');
/* autoload through composer */
//require 'vendor/autoload.php';
/* autoload through git clone */
//require 'git/sdk-php/autoload.php';
/* autoload through .zip download */
require 'download/sdk-php-master/autoload.php';
use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController;
function getSettledBatchList($startDate, $endDate) {
$api_id = "MY_API_ID";
$account_key = "MY_ACCOUNT_KEY";
$start_dt = new DateTime($startDate);
$end_dt = new DateTime($endDate);
$merchAuth = new AnetAPI\MerchantAuthenticationType();
$merchAuth->setName($api_id);
$merchAuth->setTransactionKey($account_key);
$request = new AnetAPI\GetSettledBatchListRequest();
$request->setMerchantAuthentication($merchAuth);
$request->setIncludeStatistics(true);
$request->setFirstSettlementDate($start_dt);
$request->setLastSettlementDate($end_dt);
$controller = new AnetController\GetSettledBatchListController($request);
$response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
if(($response != null) && ($response->getMessages()->getResultCode() == "Ok")){
/* Do Nothing For Now */
}else{
$errorMessages = $response->getMessages()->getMessage();
echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n";
}
return $response;
}
$api_response = getSettledBatchList('2016-05-01T00:00:00Z', '2016-05-10T00:00:00Z');
var_dump($api_response);
?>
The Errors:
/* Loaded with git clone https://github.com/AuthorizeNet/sdk-php.git */
Warning: include(sdk-php/vendor/jms/serializer/src/JMS/Serializer/Annotation/Type.php): failed to open stream: No such file or directory in sdk-php/autoload.php on line 16
Warning: include(): Failed opening '/sdk-php/vendor/jms/serializer/src/JMS/Serializer/Annotation/Type.php' for inclusion (include_path='.:') in sdk-php/autoload.php on line 16
Fatal error: Class 'JMS\Serializer\Annotation\Type' not found in /sdk-php/lib/net/authorize/util/SensitiveDataConfigType.php on line 6
/* Loaded by downloading .zip from github page */
Warning: include(/sdk-php-master/vendor/jms/serializer/src/JMS/Serializer/Annotation/Type.php): failed to open stream: No such file or directory in /sdk-php-master/autoload.php on line 16
Warning: include(): Failed opening '/sdk-php-master/vendor/jms/serializer/src/JMS/Serializer/Annotation/Type.php' for inclusion (include_path='.:') in /sdk-php-master/autoload.php on line 16
Fatal error: Class 'JMS\Serializer\Annotation\Type' not found in /sdk-php-master/lib/net/authorize/util/SensitiveDataConfigType.php on line 6
/* Loaded with Composer using recommended composer.json */
Fatal error: Class 'Goetas\Xsd\XsdToPhp\Jms\Handler\BaseTypesHandler' not found in /vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/base/ApiOperationBase.php on line 82
I'm open to all ideas at this point. Thanks!
Simple mistake. The patch was to the composer.json file that updated the required-dev version of Goetas. Did not realize I needed to update my composer.json before running composer update.
Updated composer.json Language
I just had the same issue, and I realized that the problem is that I was using require on the wrong autoload.php and I think you're doing that too.
You probably have figured it by now but in case someone else has this problem the solution is this:
You have to load/require the autoload.php that's inside the vendor folder, not the one inside the sdk (root) folder.
Related
I'm in the process of trying to upgrade a PHP application from Symfony 2.x to 3.x. I've managed to resolve dependency issues for the various packages we're using and all the packages download and install. However when the composer install triggers a cache clear it errors out with the following:
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command:
Warning: Uncaught Symfony\Component\Debug\Exception\ContextErrorException: Warning: require_once(/home/vagrant/code/symfony/vendor/jms/security-extr
a-bundle/Tests/Functional/../../vendor/autoload.php): failed to open stream: No such file or directory in /home/vagrant/code/symfony/vendor/jms/secu
rity-extra-bundle/Tests/Functional/AppKernel.php:5
Stack trace:
#0 /home/vagrant/code/symfony/vendor/jms/security-extra-bundle/Tests/Functional/AppKernel.php(5): require_once()
#1 /home/vagrant/code/symfony/vendor/symfony/symfony/src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php(191): require_
once('/home/vagrant/c...')
#2 /home/vagrant/code/symfony/vendor/symfony/symfony/src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php(145): Symfony\
Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler->convertFileToClass('/home/vagrant/c...', '/home/vagrant/c...', 'JMS\\SecurityExt..
.')
#3 /home/vagrant/code/symfony/vendor/symfony/symfony/src/Symfony/Component/Debug/Fata in /home/vagrant/code/symfony/vendor/jms/security-extra-bundle
/Tests/Functional/AppKernel.php on line 5
Fatal error: Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler::main(): Failed opening required '/home/vagrant/code/symfony/v
endor/jms/security-extra-bundle/Tests/Functional/../../vendor/autoload.php' (include_path='.:/usr/share/php') in /home/vagrant/code/symfony/vendor/j
ms/security-extra-bundle/Tests/Functional/AppKernel.php on line 5
The file it's referring to has these lines at the top:
<?php
namespace JMS\SecurityExtraBundle\Tests\Functional;
require_once __DIR__.'/../../vendor/autoload.php';
There is no autoload.php at that path. I suspect that this file is being autoloaded when it shouldn't be but I'm not sure how to resolve this.
I have compared the contents of the /vendor/jms/security-extra-bundle/Tests/Functional/AppKernel.php file to another Symfony 3 project that we have and it's exactly the same so this leads me to think it's even more likely that this file is being autoloaded when it shouldn't be.
What can I do to resolve this and get past the cache:clear --no-warmup command?
I have now resolved this. I had originally copied bin/console from another Symfony 3 project. It seems however that the correct approach was to move the existing app/console to the bin/console path and update the include paths to correctly reference the bootstrap.php.cache file in ../var/ and the autoload.php and AppKernel.php in ../app. The whole bin/console file now looks like this:
#!/usr/bin/env php
<?php
// if you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
//umask(0000);
set_time_limit(0);
require_once __DIR__.'/../var/bootstrap.php.cache';
require_once __DIR__.'/../app/autoload.php';
require_once __DIR__.'/../app/AppKernel.php';
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;
$input = new ArgvInput();
$env = $input->getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'dev');
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod';
if ($debug) {
Debug::enable();
}
$kernel = new AppKernel($env, $debug);
$application = new Application($kernel);
$application->run($input);
I came accross this Cloudflare library and want to implement in codigniter.
How to use the this cloudflare library into the source.
This is the halfway code:
require_once(APPPATH.'libraries/Cloudflare/API/');
$key = new Cloudflare\API\Auth\APIKey(CLOUDFLARE_API_USER, CLOUDFLARE_API_USER);
$adapter = new Cloudflare\API\Adapter\Guzzle($key);
$user = new Cloudflare\API\Endpoints\User($adapter);
The error message is:
Message: require_once(...\application\libraries\Cloudflare\API):
failed to open stream: Permission denied
I have installed composer and add require_once('vendor/autoload.php'); like the example in here and have this error message now:
Message: require_once(vendor/autoload.php): failed to open stream: No
such file or directory
Please help. Thanks
require_once(APPPATH.'libraries/Cloudflare/API/'); is a directory.
You need to use composer:
Install it:
composer require cloudflare/sdk
Then use composer's autoloader:
<?php
require 'vendor/autoload.php';
$key = new Cloudflare\API\Auth\APIKey('user#example.com', 'apiKey');
$adapter = new Cloudflare\API\Adapter\Guzzle($key);
$user = new Cloudflare\API\Endpoints\User($adapter);
echo $user->getUserID();
I know, that's stupid, but I can't solve the problem with my project.
I wrote project on WAMP firstly and all works.
After, I try to migrate on live server, and find a problem - server don't require my files.
Project structure is:
application
core
Controller.php
Model.php
View.php
Route.php
models
views
controllers
included
config.php
app.php
index.php
when I try to run it, server return error:
Warning: require_once(core/model.php): failed to open stream: No such
file or directory in /home/u224052355/public_html/application/app.php
on line 4
This is the app.php code:
session_start();
require_once 'config.php';
require_once 'core/model.php';
require_once 'core/view.php';
require_once 'core/controller.php';
require_once 'core/route.php';
spl_autoload_register(function($class_name){
include 'included/' . $class_name . '.php';
});
Route::start();
When I try solve this by adding __DIR__ to require_once I gave this message:
Warning:
require_once(/home/u224052355/public_html/application/core/model.php):
failed to open stream: No such file or directory in
/home/u224052355/public_html/application/app.php on line 4
Fatal error: require_once(): Failed opening required
'/home/u224052355/public_html/application/core/model.php'
(include_path='.:/opt/php-5.5/pear') in
/home/u224052355/public_html/application/app.php on line 4
Using the $_SERVER['DOCUMENT_ROOT'] and etc. - same result.
How can I solve this problem?
Problems with require_once 'Zend/Library/Autoloader.php'
PHP Warning: require_once(Zend/Loader/Autoloader.php): failed to open stream: No such file or directory in /var/www/DenisApp/scripts/load.sqlite.php on line 13
PHP Fatal error: require_once(): Failed opening required 'Zend/Loader/Autoloader.php' (include_path='/var/www/DenisApp/application/../library:.:/usr/share/php:/usr/share/pear') in /var/www/DenisApp/scripts/load.sqlite.php on line 13
I have no idea what to do ! Please help ...
Download the correct Zend-version that your load.sqlite.php expects (can't find much about it, but it looks like the 1.x-range): http://framework.zend.com
Place the Zend-folder (located in the folder library in the Zend-download) in /var/www/DenisApp/application/../library
Hit F5
Download the latest framework (actually 'Zend Framework 2.3.1 Full'):
http://framework.zend.com/downloads/latest
Extract it to a folder near your application. Ie: /home/app/public_html/
Then prepare the Path in your php code:
set_include_path('/home/app/public_html/ZendFramework-2.3.1/library');
So you can use the Autoload class to initialize the framework:
$loader = new Zend\Loader\StandardAutoloader(array('autoregister_zf' => true));
$loader->register();
So you can call the classes you need. Example:
$mail = new Zend\Mail\Storage\Maildir(array('dirname' => "/path/to/maildir"));
i'm trying to use phpunit with zendframework and i'm follwing the tutorial in
https://media.readthedocs.org/pdf/zf2/latest/zf2.pdfhere is my
bootstrap.php
<?php
chdir(dirname(__DIR__));
include __DIR__ . '/../init_autoloader.php';
here is my IndexControllerTest.php
<?php
namespace ApplicationTest\Controller;
use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;
class IndexControllerTest extends AbstractHttpControllerTestCase
{
public function setUp()
{
$this->setApplicationConfig(
include '/C:/wamp/www/zf2/config/application.config.php'
);
parent::setUp();
}
public function testIndexActionCanBeAccessed()
{
$this->dispatch('/'); // this is line 20
$this->assertResponseStatusCode(200);
$this->assertModule('application');
$this->assertControllerName('application_index');
$this->assertControllerClass('IndexController');
$this->assertMatchedRouteName('home');
}
}
and i'm getting the follwing errors
Warning: include(C:\wamp\www\zf2\module\Application\test/../init_autoloader.php)
: failed to open stream: No such file or directory in C:\wamp\www\zf2\module\App
lication\test\Bootstrap.php on line 4
Fatal error: Class 'Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase'
not found in C:\wamp\www\zf2\module\Application\test\ApplicationTest\Controller
\IndexControllerTest.php on line 8
i think that's a path probleme (auloading)but i don't know how to fix
any one can help me please ?
Warning: include(C:\wamp\www\zf2\module\Application\test/../init_autoloader.php)
: failed to open stream: No such file or directory in C:\wamp\www\zf2\module\App
lication\test\Bootstrap.php on line 4
This warning is telling you that it can't find the location of your init_autoloader.php file. Assuming that file is located in the root of your ZF2 project (so C:\wamp\www\zf2) as is convention, you need to change:
include __DIR__ . '/../init_autoloader.php';
to
include __DIR__ . '/../../../init_autoloader.php';
EDIT Continued...
PHP Fatal error: Uncaught exception 'RuntimeException' with message 'Unable to
load ZF2. Run php composer.phar install or define a ZF2_PATH environment
variable.' in C:\wamp\www\zf2\init_autoloader.php:48
Your init_autloader.php file is having trouble finding your ZF2 library autoloader. As you're using composer. Add
"zendframework/zendframework": "2.1.*",
to your "require" section in composer.json if its not already there. Run composer and update your vendor libraries with
php composer.phar update
Try run the application again and see if it works. It may do depending what is included in your init_autoload.php file. If you're still having problems add the following to init_autoloader.php
if(file_exists('vendor/autoload.php'))
{
$loader = require 'vendor/autoload.php';
}
Here's the Fix for the fatal error.
You must be missing the 'zend-test' package in your application.
$ composer require zendframework/zend-test