PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, May 20, 2022

[FIXED] How do I make a composer.json script accept flags

 May 20, 2022     composer-php     No comments   

Issue

I can't add a --filter argument to my composer.json script.

I've been reading up the docs but I can't seem to figure it out.

I have the following script in my composer.json

"scripts": {
    "test": [
        ".\\vendor\\bin\\phpunit"
    ]
},

But I can't send any --filters with it like:

$ composer test --filter pigeon_ringnumber_cant_be_more_then_9_chars_for_BE_NL_ESP

This outputs the following error:

[Symfony\Component\Console\Exception\RuntimeException]  
  The "--filter" option does not exist.

Any idea how I can make the script accept the --filter argument?

I want to be able to run it quicker then always typing

.\\vendor\\bin\\phpunit

Solution

The key here is reading carefully the docs. In docs there is:

Similar to the run-script command you can give additional arguments to scripts, e.g. composer test -- --filter will pass --filter along to the phpunit script.

So to pass --filter pigeon_ringnumber_cant_be_more_then_9_chars_for_BE_NL_ESP you should in fact run:

composer test -- --filter pigeon_ringnumber_cant_be_more_then_9_chars_for_BE_NL_ESP

so you should use here additional -- before specifying arguments that you want to pass.

Of course in this case the solution you search might be much simpler. You could just consider creating symbolic link to do this.



Answered By - Marcin NabiaƂek
Answer Checked By - David Goodson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing