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();
Related
I'm trying to develop Laravel project on hosting server, but I have a problem with public_html/index.php
Structure of files is:
/laravel/(all laravel files except /public)
/public_html/(all files from laravel /public folder)
File /public_html/index.php (without comments):
<?php
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;
define('LARAVEL_START', microtime(true));
if (file_exists(__DIR__.'/../laravel/storage/framework/maintenance.php')) {
require __DIR__.'/../laravel/storage/framework/maintenance.php';
}
require __DIR__.'/../laravel/vendor/autoload.php';
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';
$kernel = $app->make(Kernel::class);
$response = tap($kernel->handle(
$request = Request::capture()
))->send();
$kernel->terminate($request, $response);
And I'm receiving following problem:
Warning: PHP Startup: failed to open stream: No such file or directory in /index.php on line 34
Fatal error: PHP Startup: Failed opening required '//../laravel/vendor/autoload.php' (include_path='.:/:/usr/local/php74/lib/pear') in /index.php on line 34
I'm accessing website by https://my_domain.com.
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've uploaded my webapp (made with Laravel 5.8). I run composer install via SSH so vendor is created, but when opening website I get:
Warning: PHP Startup: failed to open stream: No such file or directory in /index.php on line 24
Fatal error: PHP Startup: Failed opening required '//../vendor/autoload.php' (include_path='.:/:/usr/local/php72/lib/pear') in /index.php on line 24
When I change server's PHP default version, for example to 7.1, in second line path changes to: usr/local/php71/lib/pear .
On localhost, and on different with the very same vendor everything works fine.
So I assume something is wrong with php's path?
I've already run composer update or dumb-autoload with no success.
E1:
define('LARAVEL_START', microtime(true));
require __DIR__.'/../vendor/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
try to run following command in your application
sudo chmod -R 777 bootstrap/cache storage
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.
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"));