如何使用通过作曲家安装的软件包



我已经通过作曲家安装了FactoryMuffin。安装后,我跑了作曲家转储 - 只是为了确保我正在使用最新的东西。

现在,当我尝试在代码中使用我无法安装的软件包中的东西时,我不能。例如:

use LeagueFactoryMuffinFacade;
class APITest extends Sw_Test_PHPUnit_LibraryTestCase
{
    public function setUp()
    {
        $a = new FactoryMuffin();
        parent::setUp();
    }
}

当我徘徊在新的FactoryMuffin对象实例化上时,它说找不到声明。

如果我徘徊在:

use LeagueFactoryMuffinFacade;

它说

未定义的班级立面

徘徊时:

use LeagueFactoryMuffin

它说

多个实现

我正在遵循FactoryMuffin文档中列出的所有步骤,我缺少什么?

这是我的作曲家文件:

{
    "name": "project/project",
    "description": "Main Project Library",
    "homepage": "http://www.testproject.com/",
    "require": {
        "php": ">=5.4",
        "zendframework/zendframework": "2.3.9",
        "guzzle/guzzle": "~3.7",
        "justinrainbow/json-schema": "~1.3",
        "mikey179/vfsStream": "v1.2.0",
        "mtdowling/cron-expression": "1.0.*",
        "minfraud/http": ">=1.60,<2.0",
        "davegardnerisme/nsqphp": "dev-master",
        "myclabs/deep-copy": "1.3.0",
        "maennchen/zipstream-php": "0.3.*",
        "corneltek/getoptionkit": "~2",
        "firebase/php-jwt": "~3.0",
        "symfony/property-access": "~3.0",
        "punic/punic": "2.1.*",
        "guzzlehttp/guzzle": "^6.3",
        "easypost/easypost-php": "^3.4",
        "textalk/websocket": "^1.2",
        "robmorgan/phinx": "^0.10.6",
        "fzaninotto/faker": "^1.8",
        "league/factory-muffin": "^3.0",
        "league/factory-muffin-faker": "^2.1"
    },
    "require-dev": {
        "phpunit/phpunit": "5.6.*",
        "mockery/mockery": "dev-master"
    },
    "repositories": [],
    "autoload": {
        "psr-0": {
            "DeepCopy": "vendor/myclabs/deep-copy/src"
        }
    }
}

https://factory-muffin.thephpleague.com/usage/examples/

尝试使用AS

use LeagueFactoryMuffinFacade as FactoryMuffin;
FactoryMuffin::define('Message', array(
    'user_id'      => 'factory|User',
    'subject'      => 'sentence',
    'message'      => 'text',
    'phone_number' => 'randomNumber|8',
    'created'      => 'date|Ymd h:s',
    'slug'         => 'call|makeSlug|word',
), function ($object, $saved) {
    // we're taking advantage of the callback functionality here
    $object->message .= '!';
});

相关内容

  • 没有找到相关文章

最新更新