1
votes

I'm currently working on a package of Laravel that will launch behats tests directly from our browser. this is a personal project.

I use the Process Component Symfony to execute various commands. However, it can not execute the command Behat and returns me this error:

vendor / bin / Behat "failed. Exit Code: 255 (Unknown error) Working directory: / Applications / MAMP / htdocs / Package / public Output: ================ Parse error: parse error, expecting '&' 'or "variable (T_VARIABLE)' 'in / Applications / MAMP / htdocs / Package / vendor /laravel/framework/src/Illuminate/Foundation/helpers.php on line 475 Error Output: ================

In short, he refused to execute all commands Behat. Here the use of the command in the controller of my package.

<? Php

namespace Nkweb\BehatWeb\Http\Controllers;

use App\Http\Controllers\Controller;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;

class BehatWebController extends Controller
{
    
    public function launchBehat()
    {
        
        $command = base_path('vendor/bin/Behat');

        $process = new Process($command);
        try {
            $process->mustRun();
            $outputs = explode("\n", $process->getOutput());
        } Catch (ProcessFailedException $e) {
            return $e->getMessage();
        }

        return view('behatweb::content.init', ['outputs' => $outputs]);
    }
}

I searched google and returned in every way but I could not find anything about it. I really need your help :(

1
Have you tried Behat with B lowercase?lauda
Hello, yes but i get the same errornkweb

1 Answers

0
votes

I'm not a Laravel user but I'll give it a shot. I'll walk through my process so hopefully it will help you debug similar issues in the future. I'm assuming you're using the latest Laravel but would be helpful if you could state which version you're running.

Looking at the error, we have a nice place to start. Line 475 in laravel/framework/src/Illuminate/Foundation/helpers.php. Which is the first line below:

function event(...$args)
{
    return app('events')->fire(...$args);
}

And we are expecting a variable or & (pass by reference) according to the error, so we can assume it is talking about the parameter in the event function. Now we can see the parameter is preceded by ... this is a hard one to Google but you might get better results searching for the "splat" operator (note, different languages may have alternative names).

This was introduced in PHP 5.6, which leads me to believe you are running an earlier version which is not supported. I'd suggest upgrading to PHP 5.6 or above and seeing if that fixes your issue. If it doesn't, please post the version of PHP you're using.