Ako spravne nacitat funkcie mimo triedy
- MKI-Miro
- Člen | 279
Ahojte
Dostavam takuto chybu
Call to undefined function GuzzleHttp\choose_handler()
File: .../guzzlehttp/guzzle/src/HandlerStack.php:40
V booting.php
->addDirectory(__DIR__ . '/../vendor/guzzlehttp')
funkcia choose_handler() sa nachadza v namespace GuzzleHttp mimo triedy
v controllery mam use GuzzleHttp;
v com moze byt problem?
dakujem
Editoval MKI-Miro (13. 10. 2019 17:25)
- MKI-Miro
- Člen | 279
pozeral som teraz ako to spravit cez composer.json a teda ten composer ma byt v tom istom adresari ako su app, vendor…
ako ale nette vie ze ma composer.json citat z toho adresara?
inac problem som vyrisiel takto
require('../vendor/guzzlehttp/guzzle/src/functions.php');
require('../vendor/guzzlehttp/psr7/src/functions.php');
require('../vendor/guzzlehttp/promises/src/functions.php');
Editoval MKI-Miro (13. 10. 2019 20:56)
- Marek Bartoš
- Nette Blogger | 1280
Nette s tím nemá nic společného, composer.json a vendor/autoload.php jsou záležitosti čistě jen composeru. Nic z vendoru přes nette/robot-loader nenačítej, ten je jen pro aplikaci
- chemix
- Nette Core | 1310
Mrkni treba na https://www.kutac.cz/…alicku-v-php nebo na YouTube je plno ukazek co to composer je a jak se pouziva. Jde o to, ze prestanes stahovat zip soubory s knihovnama ale zacnes pouzivat prikazovou radku s prikazy pro instalaci potrebnych knihoven.
A je tam udelany tzv autoloading pro ty knihovny, takze muzes zapomenout ze neco jako require je a jen v udelat v php require composeru podle navodu a pak uz mas pristupne vsechny nainstalovane knihovny s jejich tridama a pripadne funkcema
- MKI-Miro
- Člen | 279
takze vymazal som reuqired volania a vymazal som veci z bootingu a pridal som teda composer ktory mi nacital potrebne kniznice. Too vidim v tracy:
gopay/payments-sdk-php v1.4.1
guzzlehttp/guzzle 6.3.3
guzzlehttp/promises v1.3.1
guzzlehttp/psr7 1.6.1
V presentery tedy mám
use GoPay;
use GoPay\Api;
use GoPay\Definition;
use GoPay\Definition\Language;
use GoPay\Definition\Payment;
use GoPay\Definition\Payment\BankSwiftCode;
use GoPay\Definition\Payment\Currency;
use GoPay\Definition\Payment\PaymentInstrument;
use GoPay\Definition\Payment\PaymentItemType;
use GoPay\Definition\Payment\VatRate;
dostavam ale chybu
Class 'GoPay\Definition\Payment\PaymentItemType' not found
robim nieco zle? alebo ako to debugnut hlbsie?
dakujem
- Marek Bartoš
- Nette Blogger | 1280
Tenhle řádek tam máš? https://github.com/…ww/index.php#L5
Instaloval jsi knihovny přes composer require?
Autoloader nedokáže najít třídu nebo není ani zaregistrovaný.
- Marek Bartoš
- Nette Blogger | 1280
Třída opravdu existuje?
Jestli ti to na localhostu funguje, tak se ujisti, že se ti vendor nahrává na
ftp celý
- MKI-Miro
- Člen | 279
takze dal som aj dumpautoload ale nic sa nezmenilo
v autoload_files vidim potrebne veci
'59af96974553a1fc6407327354b6f47e' => $vendorDir . '/nette/di/src/compatibility.php',
'19a7e2c3b1d506dcdc1b60aab8e102e4' => $vendorDir . '/tracy/tracy/src/Tracy/shortcuts.php',
'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
'e7a6fd2e7a869bb207158e9416bdd9b0' => $vendorDir . '/nette/application/src/compatibility.php',
'afdda9f94b76f77a7518e02eee753cc9' => $vendorDir . '/nette/mail/src/compatibility.php',
'a9b805bf529b5a997093b3cddca2af6f' => $vendorDir . '/gopay/payments-sdk-php/factory.php',
);
v autoload_classmap ale namem ziaden GoPay...
composer.json:
{
"name": "nette/web-project",
"description": "Nette: Standard Web Project",
"keywords": ["nette"],
"type": "project",
"license": ["MIT", "BSD-3-Clause", "GPL-2.0", "GPL-3.0"],
"require": {
"php": ">= 7.1",
"nette/application": "^3.0",
"nette/bootstrap": "^3.0",
"nette/caching": "^3.0",
"nette/database": "^3.0",
"nette/di": "^3.0",
"nette/finder": "^2.5",
"nette/forms": "^3.0",
"nette/http": "^3.0",
"nette/mail": "^3.0",
"nette/robot-loader": "^3.0",
"nette/security": "^3.0",
"nette/utils": "^3.0",
"latte/latte": "^2.5",
"tracy/tracy": "^2.6",
"gopay/payments-sdk-php": "^1.4"
},
"require-dev": {
"nette/tester": "^2.0"
},
"autoload": {
"classmap": ["app/Booting.php"]
},
"minimum-stability": "stable",
"config": {
"platform": {
"php": "7.3"
}
}
}
composer.lock
"packages": [
{
"name": "gopay/payments-sdk-php",
"version": "v1.4.1",
"source": {
"type": "git",
"url": "https://github.com/gopaycommunity/gopay-php-api.git",
"reference": "ee9285c5a560046c4d59eec34295198d2b832e98"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/gopaycommunity/gopay-php-api/zipball/ee9285c5a560046c4d59eec34295198d2b832e98",
"reference": "ee9285c5a560046c4d59eec34295198d2b832e98",
"shasum": ""
},
"require": {
"guzzlehttp/guzzle": "^5.3.1|^6.2.1",
"php": ">=5.4.0"
},
"require-dev": {
"hamcrest/hamcrest-php": "*",
"phpunit/phpunit": "<6.0"
},
"type": "library",
"autoload": {
"psr-4": {
"GoPay\\": "src/"
},
"files": [
"factory.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "GoPay",
"homepage": "https://github.com/gopaycommunity/gopay-php-api/contributors"
}
],
"description": "GoPay's PHP SDK for Payments REST API",
"keywords": [
"api",
"gopay",
"payments",
"rest",
"sdk"
],
"time": "2019-07-11T12:34:04+00:00"
},
Editoval MKI-Miro (17. 10. 2019 7:47)
- David Matějka
- Moderator | 6445
@teekey99 nemas pravdu, nastaveni autoloadu ma spravne. odpovida i web-projectu
- teekey99
- Člen | 45
David Matějka napsal(a):
@teekey99 nemas pravdu, nastaveni autoloadu ma spravne. odpovida i web-projectu
V tom případě se omlouvám a beru zpět. Unáhlil jsem se, jsem zvyklej používat PSR-4, tohle mě trochu zarazilo. @MKI-Miro Omlouvám se za zavádějící informaci, moje chyba.