JorgeNeira's avatar

[L5.1] Artisan Not working in Command Line Tool - PhpStorm

Hi

I'm trying to integrate Artisan in the command line tool in PHPStorm, so I can use aliases in my windows enviroment following these instructions:

https://confluence.jetbrains.com/display/PhpStorm/Laravel+Development+using+PhpStorm#LaravelDevelopmentusingPhpStorm-CommandLineToolSupportforArtisanandComposer

It was working with Laravel 5, but I can't make it work with L5.1 It seems phpstorm is calling artisan with the --xml param, instead of --format. Does anybody know how to solve this issue from phpstorm side?

Thanks

Problem Failed to parse output as xml: Error on line 4: Content is not allowed in prolog.. Command D:\Programas\xampp\php\php.exe D:\Programas\xampp\htdocs\backendDev\admin\artisan list --xml

Output

[ErrorException]
The --xml option was deprecated in version 2.7 and will be removed in versi
on 3.0. Use the --format option instead.

0 likes
8 replies
gildniy's avatar
gildniy
Best Answer
Level 27

Sorry for answering a bit late, but you can place this code:

//Start - Code to allow PhpStorm CLI
if (isset($argv[1], $argv[2]) &&
    $argv[1] === 'list' &&
    $argv[2] === '--xml'
) {
    $argv[2] = '--format=xml';
    $_SERVER['argv'] = $argv;
}
//End - Code to allow PhpStorm CLI

before this line

require __DIR__ . '/bootstrap/autoload.php';

in artisan file (in your root directory) Tested in LARAVEL 5.27 and PHPSTORM 10.0.7

2 likes
MehmetNuri's avatar

if (isset($argv[1], $argv[2]) &&
    $argv[1] === 'list' &&
    $argv[2] === '--xml'
) {
    $argv[2] = '--format=xml';
    $_SERVER['argv'] = $argv;
}

require __DIR__.'/bootstrap/autoload.php';

$app = require_once __DIR__.'/bootstrap/app.php';

Php Storm 10.0.3 and Laravel 5.2.12 not work

1 like
aliassiri's avatar

your code not working with Php Storm 10.0.3 and Laravel 5.2.12 not work

MehmetNuri's avatar
  1. copy artisan to artisan-shim

  2. add the following lines to artisan-shim just after the opening <?php tag

 if(count($argv) == 2 && $argv[1] == "-V"){
        echo "Symfony version 3.0.0";
} else {
    if($argv[1] == "list" && $argv[2] == "--xml"){
        $argv[2] = '--format=xml';
        $_SERVER['argv'] = $argv;
    }
}

Then

  1. Open /vendor/laravel/framework/src/Illuminate/Console/Application.php
  2. In __construct() replace
parent::__construct('Laravel Framework', $version);
parent::__construct('Symfony', '3.0.1');

and finish. Php Storm and Laravel 5.2 ready :)

gildniy's avatar

Hi, here is a working solution: (in artisan.php) Before

require __DIR__ . '/bootstrap/autoload.php';

add these

//STARTS - Code to allow PhpStorm CLI in PhpStorm 10.0.x and Laravel 5.2.x
if (isset($argv[1], $argv[2]) &&
    $argv[1] === 'list' &&
    $argv[2] === '--xml'
    ) {
    $argv[2]  = '--format=xml';
    $_SERVER['argv'] = $argv;
}
if (isset($argv[1]) && $argv[1] === '-V') {
    die('Symfony version 3.0.0');
}
//ENDS - Code to allow PhpStorm CLI
1 like

Please or to participate in this conversation.