"Convert" 要在 Symfony 中加载的包
"Convert" package to load in Symfony
我有 THIS 包(支付网关),我想在 Symfony 3.0.1 中使用它
不幸的是我得到这个错误:
ClassNotFoundException in AppKernel.php line 21: Attempted to load class "SofortBundle" from namespace "Sofort\SofortLib".
Did you forget a "use" statement for another namespace?
在 sofort\sofortlib-php
文件夹中,我创建了包含此内容的文件 SofortBundle.php
<?php
namespace Sofort\SofortLib;
use Symfony\Component\HttpKernel\Bundle\Bundle as BaseBundle;
class SofortBundle extends BaseBundle
{
}
我在 AppKernel.php
中加载了 Bundle:
new Sofort\SofortLib\SofortBundle(),
但这只会导致上述异常。
我错过了什么?
不要将包复制到您的自定义文件夹。按照说明安装包:
在composer.json
中添加:
"require": {
"sofort/sofortlib-php": "3.*"
}
运行 composer update sofort/sofortlib-php
在您的代码中,您可以像这样使用库:
use \Sofort\SofortLib\Billcode;
class MyClass
{
function doSomething($configkey) {
$SofortLibBillcode = new Billcode($configkey);
...
}
}
我有 THIS 包(支付网关),我想在 Symfony 3.0.1 中使用它 不幸的是我得到这个错误:
ClassNotFoundException in AppKernel.php line 21: Attempted to load class "SofortBundle" from namespace "Sofort\SofortLib". Did you forget a "use" statement for another namespace?
在 sofort\sofortlib-php
文件夹中,我创建了包含此内容的文件 SofortBundle.php
<?php
namespace Sofort\SofortLib;
use Symfony\Component\HttpKernel\Bundle\Bundle as BaseBundle;
class SofortBundle extends BaseBundle
{
}
我在 AppKernel.php
中加载了 Bundle:
new Sofort\SofortLib\SofortBundle(),
但这只会导致上述异常。
我错过了什么?
不要将包复制到您的自定义文件夹。按照说明安装包:
在composer.json
中添加:
"require": {
"sofort/sofortlib-php": "3.*"
}
运行 composer update sofort/sofortlib-php
在您的代码中,您可以像这样使用库:
use \Sofort\SofortLib\Billcode;
class MyClass
{
function doSomething($configkey) {
$SofortLibBillcode = new Billcode($configkey);
...
}
}