I am trying to install BingAds API and I keep getting the error
PHP Fatal error: Class 'Microsoft\BingAds\Auth\OAuthWebAuthCodeGrant' not found
I checked the composer file it looks OK.
{
"name": "microsoft/bingads",
"description": "This project provides a set of PHP client libraries that make it easy to access Bing Ads service APIs.",
"keywords": [ "php", "bingads", "bing ads", "sdk" ],
"license": "Apache-2.0",
"type": "library",
"homepage": "https://github.com/BingAds/BingAds-PHP-SDK",
"require": {
"php": ">=5.5.17",
"ext-curl": "*",
"ext-openssl": "*",
"ext-soap": "*"
},
"require-dev": {
"ext-curl": "*",
"ext-openssl": "*",
"ext-soap": "*"
},
"autoload": {
"psr-4": {
"Microsoft\\BingAds\\": "src/"
}
},
"authors": [
{
"name": "Microsoft",
"homepage": "https://github.com/BingAds/BingAds-PHP-SDK/graphs/contributors"
}
]
}
Also, the OAuth2Callback.php files look fine I am calling the namespace on the header as use Microsoft\BingAds\Auth\OAuthWebAuthCodeGrant; and later it calls the class OAuthWebAuthCodeGrant() on the line that gives the error.
The file structure is like:
- BingAds-PHP-SDK-master
- - OAuth2Callback.php
- - WebAuthHelper.php
- - composer.json
- - composer.lock
- - /samples
- - /src
- - /vendor
Does anybody have any clues? I am new with namespaces, not completely sure how it works. Thanks!
Can you share more details about OAuth2Callback.php? Have you tried this web app walkthrough? If you are running this locally in a console then I suggest starting with this console walkthrough.
Recently, I downloaded V13 source code from https://github.com/BingAds/BingAds-PHP-SDK, because the command "composer require microsoft/bingads" from the instruction only sending me the V12 not V13.
I got same error: PHP Fatal error: Class 'Microsoft\BingAds\Auth\OAuthWebAuthCodeGrant' not found.
Compared to the composer.json.
in V13:
"autoload": {
"psr-4": {
"Microsoft\BingAds\": "/src/"
}
},
and in v12:
"autoload": {
"psr-4": {
"Microsoft\BingAds\": "src/"
}
},
after updated the path from "/src/" to "src/", ran "composer update" and it works.
Related
we currently have a locally hosted Magento test site and some time ago it was working OK but after doing some changes it stopped working and constantly shows HTTP Error 500. I am new to Magento and to Linux (we use here a Gentoo Linux machine) and I tried to research as much as I can, testing different solutions, but the problem persists and I have the idea that is getting worse every time I try to resolve something.
The problem I am having now inside the Terminal is a PHP Warning and PHP Fatal Error related to the 'require' function. Every time I try to do something about Magento I have this error (for example, if I run 'php bin/magento --version' I have this error, and so on with every command related with Magento). As far as I understand, this problem occurs when you try to call for a file that doesn't exists or is not there. In my case trouble seems to be related with the Sage Pay extension. This is the warning I have inside Terminal:
PHP Warning: require(/var/www/localhost/htdocs/vendor/composer/../ebizmarts/sagepaysuite/registration.php): failed to open stream: No such file or directory in /var/www/localhost/htdocs/vendor/composer/autoload_real.php on line 73
PHP Fatal error: require(): Failed opening required '/var/www/localhost/htdocs/vendor/composer/../ebizmarts/sagepaysuite/registration.php' (include_path='/var/www/localhost/htdocs/vendor/magento/zendframework1/library:.:/usr/share/php7:/usr/share/php') in /var/www/localhost/htdocs/vendor/composer/autoload_real.php on line 73
Thinking that this could be related to the extension itself being missing for some reason, when I try to install the extension I have this error:
Installation failed, reverting ./composer.json to its original content.
[RuntimeException]
Failed to execute git clone --no-checkout -- 'https://MHuYqyU63hS4dojaex1J:
***#gitlab.ebizmarts.com/ebizmarts/magento2-sage-pay-suite.git' '/var/www/l
ocalhost/htdocs/vendor/ebizmarts/sagepaysuite' && cd '/var/www/localhost/ht
docs/vendor/ebizmarts/sagepaysuite' && git remote add composer -- 'https://
MHuYqyU63hS4dojaex1J:***#gitlab.ebizmarts.com/ebizmarts/magento2-sage-pay-s
uite.git' && git fetch composer && git remote set-url origin -- 'https://gi
tlab.ebizmarts.com/ebizmarts/magento2-sage-pay-suite.git' && git remote set
-url composer -- 'https://gitlab.ebizmarts.com/ebizmarts/magento2-sage-pay-
suite.git'
Cloning into '/var/www/localhost/htdocs/vendor/ebizmarts/sagepaysuite'...
remote: HTTP Basic: Access denied
fatal: Authentication failed for 'https://gitlab.ebizmarts.com/ebizmarts/ma
gento2-sage-pay-suite.git/'
Similarly, when I try to update Composer I have the same error related to Sage Pay and the update is aborted.
Our current composer.json file is as follows:
{
"name": "magento/project-community-edition",
"description": "eCommerce Platform for Growth (Community Edition)",
"type": "project",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"config": {
"preferred-install": "dist",
"sort-packages": true
},
"require": {
"absolute_design/absolute-slider": "^2.0.0",
"bitware/speedenginedeferjs": "^1.0",
"ebizmarts/sagepaysuite": "~1.3",
"magefan/module-wysiwyg-advanced": "^2.0",
"magento/data-migration-tool": "~2.3",
"magento/product-community-edition": "~2.3.7-p1",
"mageplaza/magento-2-english-united-kingdom-language-pack": "dev-master",
"mageplaza/magento-2-seo-extension": "^2.1",
"mageplaza/module-ajax-layered-navigation": "^1.0",
"mageplaza/module-delete-orders": "^1.2",
"mageplaza/module-gdpr": "^1.2",
"mageplaza/module-sitemap": "^1.0",
"olegkoval/magento2-regenerate-url-rewrites": "^1.5",
"trustpilot/module-reviews": "^2.6"
},
"require-dev": {
"allure-framework/allure-phpunit": "~1.2.0",
"friendsofphp/php-cs-fixer": "~2.14.0",
"lusitanian/oauth": "~0.8.10",
"magento/magento-coding-standard": "~3.0.0",
"magento/magento2-functional-testing-framework": "2.4.5",
"pdepend/pdepend": "2.5.2",
"phpmd/phpmd": "#stable",
"phpunit/phpunit": "~6.5.0",
"sebastian/phpcpd": "~3.0.0",
"squizlabs/php_codesniffer": "~3.4.0"
},
"conflict": {
"gene/bluefoot": "*"
},
"autoload": {
"psr-4": {
"Magento\\Framework\\": "lib/internal/Magento/Framework/",
"Magento\\Setup\\": "setup/src/Magento/Setup/",
"Magento\\": "app/code/Magento/",
"Zend\\Mvc\\Controller\\": "setup/src/Zend/Mvc/Controller/"
},
"psr-0": {
"": [
"app/code/",
"generated/code/"
]
},
"files": [
"app/etc/NonComposerComponentRegistration.php"
],
"exclude-from-classmap": [
"**/dev/**",
"**/update/**",
"**/Test/**"
]
},
"autoload-dev": {
"psr-4": {
"Magento\\Sniffs\\": "dev/tests/static/framework/Magento/Sniffs/",
"Magento\\Tools\\": "dev/tools/Magento/Tools/",
"Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/",
"Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/",
"Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/"
}
},
"version": "2.3.0",
"minimum-stability": "stable",
"repositories": {
"0": {
"type": "composer",
"url": "https://repo.magento.com/"
},
"magento": {
"type": "composer",
"url": "https://repo.magento.com"
},
"ebizmarts": {
"type": "composer",
"url": "https://packages.ebizmarts.com"
}
},
"extra": {
"magento-force": "override"
}
}
Any help would be appreciated, I am very lost and stuck right now not knowing how to resolve this.
Thanks in advance.
Maybe issue from extension ebizmarts/sagepaysuite
you can check file composer.json in this extension. In file composer.json you can see lable "require" php version for this extension.
=> you can delete this extension or upgrade you php version.
have a nice day !
I am trying to develop a package with will be required by some of our applications. However, I am unable to test the package when I require it using composer inside an application.
The package has the following composer.json:
{
"name": "armcanada/target-horaire",
"type": "library",
"license": "MIT",
"description": "",
"authors": [
{
"name": "Anthony Duhaime",
"email": "aduhaime#armcanada.ca"
}
],
"require": {},
"autoload": {
"psr-4": {
"Armcanada\\TargetHoraire\\": "src/"
}
},
"minimum-stability": "dev"
}
The package has the following directory structure and has the following testing class:
The package is require in another application in the composer.json:
"require": {
"armcanada/target-horaire": "dev-master"
}
"repositories": [
{
"type": "path",
"url": "../target-horaire"
}
]
Finally, I am importing the class and calling the test() method:
use Armcanada\TargetHoraire\Models\Timeline;
...
dd((new Timeline())->test());
It result with the following error:
"Class 'Armcanada\TargetHoraire\Models\Timeline' not found"
I have tried to composer dumpautoload in both the application and the package, still has no effect.
I also tried to delete the vendor folder and the package-lock.json then run composer install, I am now getting the error:
include(/app/vendor/composer/../armcanada/target-horaire/src/Models/Timeline.php): failed to open stream: No such file or directory. However, the file does exist:
What am I doing wrong?
I think you forgot
extends PHPUnit_Framework_TestCase
in `Timeline.php
and if using autoloading, try
phpunit --bootstrap src/autoload.php
I'm new in composer but I could get vendor, composer.lock and composer.json from cmd then I paste them to my project without Validation_Master folder.
My project Path: C:\wamp64\www\php Projects\project 1\(here there are test.php and vendor, composer.lock and composer.json)
Validation_Master folder path: C:\wamp64\www\php Projects\Validation_Master
My Code is:
<?php
require "vendor/autoload.php";
use Respect\Validation\Validator as v;
$number = 123;
v::numeric()->validate($number);
?>
But the above code gives me the following error :
Fatal error: Class 'Respect\Validation\Validator' not found in
C:\wamp64\www\php Projects\project 1\test.php
What did I do?!!?
copy Validation_Master folder to the path of test.php ==> (Failed )
copy Vendor folder to the path of Validation_Master folder and required from there ==> (Failed )
Manipulate namespace a lot and add namespace Respect\Validation to the code ==> (Failed )
What's The PROBLEM ????
How Can I use Respect Validation Library ????? Please answer me basically (I read docs before but didn't help)
vendor folder image
composer.json code:
{
"name": "respect/validation",
"description": "The most awesome validation engine ever created for PHP",
"keywords": ["respect", "validation", "validator"],
"type": "library",
"homepage": "http://respect.github.io/Validation/",
"license": "BSD Style",
"authors": [
{
"name": "Respect/Validation Contributors",
"homepage": "https://github.com/Respect/Validation/graphs/contributors"
}
],
"require": {
"php": ">=5.6"
},
"require-dev": {
"egulias/email-validator": "~1.2",
"malkusch/bav": "~1.0",
"mikey179/vfsStream": "^1.5",
"phpunit/phpunit": "~5.3",
"symfony/validator": "~2.6.9",
"zendframework/zend-validator": "~2.3"
},
"suggest": {
"ext-bcmath": "Arbitrary Precision Mathematics",
"ext-mbstring": "Multibyte String Functions",
"egulias/email-validator": "Strict (RFC compliant) email validation",
"malkusch/bav": "German bank account validation",
"symfony/validator": "Use Symfony validator through Respect\\Validation",
"zendframework/zend-validator": "Use Zend Framework validator through Respect\\Validation",
"fabpot/php-cs-fixer": "Fix PSR2 and other coding style issues"
},
"autoload": {
"psr-4": {
"Respect\\Validation\\": "library/"
}
},
"autoload-dev": {
"psr-4": {
"Respect\\Validation\\": "tests/library/"
}
},
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
},
"scripts": {
"test": "./vendor/bin/phpunit"
}
}
the autoload.php code :
<?php
require_once __DIR__ . '/composer' . '/autoload_real.php';
return ComposerAutoloaderInit46e0d859a60be6f2acf30ed92a2228ad::getLoader();
I appreciate and sorry that I've written a lot
UPDATE : My problem like this post : Why my autoload.php of composer doesn't work?, but it didn't help
I also run composer dump-autoload in cmd ==> (failed)
It looks to me like you copied the composer.json of the respect/validation library, and tried to use it as the composer.json for your project. This is a completely wrong approach.
Use this as your project composer.json:
{
"require": {
"respect/validation": "^1.0"
}
}
Then:
run composer install,
run your script again.
I'm trying to install this github repo to my project (running on codeigniter). The steps I'm doing is very simple:
{
"name": "project",
"description": "",
"license": "MIT",
"require": {
"php" : ">=5.3.0",
"blockchain/blockchain" : "1.*",
"ext-curl": "*"
},
"require-dev": {
}
} // composer.json
and run php composer.phar update. So the package installs but I can't use it in my project - I don't think its autoloaded. /vendor/autoload.php is required in my index.php. When I try it with different package for test purposes (kriswallsmith/buzz) - it works. So what I'm doing wrong?
Also I checked my vendor/composer/installed.json and I see this:
[
{
"name": "blockchain/blockchain",
"version": "v1.0",
"version_normalized": "1.0.0.0",
"source": {
"type": "git",
"url": "https://github.com/blockchain/api-v1-client-php.git",
"reference": "c219b9b00778cf6c025628bd34fd6543922fe81b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/blockchain/api-v1-client-php/zipball/c219b9b00778cf6c025628bd34fd6543$
"reference": "c219b9b00778cf6c025628bd34fd6543922fe81b",
"shasum": ""
},
"require": {
"ext-curl": "*",
"php": ">=5.3.0"
},
"time": "2015-02-03 18:34:11",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"Blockchain\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Blockchain API client library",
"homepage": "https://github.com/blockchain/api-v1-client-php",
"keywords": [
"bitcoin",
"blockchain"
]
}
]
and my function where I'm trying to use this lib:
private function __check_btc_balance()
{
error_reporting(E_ALL);
$Blockchain = new \Blockchain\Blockchain(PAYMENTS_BTC_API_CODE);
}
Have you followed the installation steps?
Basically there are some differences from common composer packages. Over here it says download the source code and run composer install from it's own folder
Then include the autoloader file from the folder of the downloaded files so you will have somewhere a folder Blockchain/vendor/autoload.php to include
Download the source or clone the repository. This php library works
with the Composer package manager. Navigate to the root of the
repository and run
$ composer install
This will create the /vendor folder in the repository root. In the php
source, simply:
// Include the autoload.php from its vendor directory require
'vendor/autoload.php'
// Create the base Blockchain class instance
I've seen ...
"autoload": {
"psr-4": {
"Blockchain\\": "src/"
}
},
I always keep all my code in src\Vendor\Project\Filename.php and composer autoloader works with this. Try to add this lines of code:
"autoload": {
"psr-0": {
"": "src/"
}
},
I'm using the excellent phpwkhtmltopdf library and want to update to latest version and for this I need to use composer.
File structure:
vendor
--mikehaertl
--php-shellcommand
--php-tmpfile
autoload.php
Composer.json file:
{
"name": "mikehaertl/phpwkhtmltopdf",
"description": "A slim PHP wrapper around wkhtmltopdf with an easy to use and clean OOP interface",
"keywords": ["pdf", "wkhtmltopdf", "wkhtmltoimage" ],
"homepage": "http://mikehaertl.github.com/phpwkhtmltopdf/",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Michael Haertl",
"email": "haertl.mike#gmail.com"
}
],
"require": {
"php": ">=5.0.0",
"mikehaertl/php-tmpfile": "1.0.*",
"mikehaertl/php-shellcommand": "1.0.*"
},
"autoload": {
"psr-4": {
"mikehaertl\\wkhtmlto\\": "src/"
}
},
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
}
}
I'm trying to use the library like this:
require '/home/bookmark/vendor/autoload.php';
use mikehaertl\wkhtmlto\Pdf;
...
$pdf = new Pdf('http://anysite.com'); <-- error points to this line
The problem is I get the error:
Fatal error: Class 'mikehaertl\wkhtmlto\Pdf' not found in /home/bookmark/public_html/ajax/action.php on line 132
This is my first time using composer, any idea what I'm doing wrong?
If you are using some package, you must not copy their composer.json file - that won't work.
The best thing would be to run composer init once to create an initial composer.json file for your project, and composer require mikehaertl/phpwkhtmltopdf:~2.0 to add this package you want to work with.
After that, it should work.