简体   繁体   中英

RoboFile composer autoload trait not found

I'm trying to use a Parameter file writer package in my RoboFile, loading it via composer.

RoboClass:

<?php
use Symfony\Component\Finder\Finder;
use Robo\Result;
use Robo\Collection\CollectionBuilder;
use Nordcode\RoboParameters\loadTasks;

  class RoboFile extends \Robo\Tasks
  {
    use loadTasks;

    public function sometask()
    {
       //something
    }

when trying to call sometask() I get the following error:

PHP Fatal error: Trait 'Nordcode\RoboParameters\loadTasks' not found in /projects/Robo/RoboFile.php on line 9

while I can find it in composers autoload_classmap.php

'NordCode\\RoboParameters\\loadTasks' => $vendorDir . '/nordcode/robo-parameters/src/loadTasks.php',

Am I missing something?

Edit 12.02.16: Fixed "\\" in at the beginning of the namespace, doesn't seem to make a difference

Also fixed lower case trait name :)

The contents of what appears to be the bootstrap.php

<?php

if (strpos(basename(__FILE__), 'phar')) {
    require_once 'phar://robo.phar/vendor/autoload.php';
} else {
    if (file_exists(__DIR__.'/vendor/autoload.php')) {
        require_once __DIR__.'/vendor/autoload.php';
    } elseif (file_exists(__DIR__.'/../../autoload.php')) {
        require_once __DIR__ . '/../../autoload.php';
    } else {
        require_once 'phar://robo.phar/vendor/autoload.php';
    }
}
$runner = new \Robo\Runner();
$statusCode = $runner->execute($_SERVER['argv']);
exit($statusCode);

contents of LoadTasks

<?php

namespace NordCode\RoboParameters;

use NordCode\RoboParameters\Task\Parameters;
use NordCode\RoboParameters\Task\SymfonyParameters;

trait LoadTasks
{
   //functions
}

I am working with Tobias and it worked for me now... I did not exactly change anything. Just re-setup it on my machine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM