Coder Social home page Coder Social logo

composer-unused's Introduction

composer-unused logo

composer-unused

A Composer tool to show unused Composer dependencies by scanning your code.

Created by Andreas FrΓΆmer and contributors, logo by Caneco.

πŸ”₯πŸ”₯ Now available as Github Action on the Marketplace πŸ”₯πŸ”₯

Motivation

When working in a big repository, you sometimes lose track of your required Composer packages. There may be so many packages you can't be sure if they are actually used or not.

Unfortunately, the composer why command only gives you the information about why a package is installed in dependency to another package.

How do we check whether the provided symbols of a package are used in our code?

composer unused to the rescue!

example

Installation

PHAR (PHP Archive) (recommended)

Install via phive or grab the latest composer-unused.phar from the latest release:

$ phive install composer-unused

$ curl -JOL https://github.com/icanhazstring/composer-unused/releases/latest/download/composer-unused.phar

Global

If you have a lot of projects and don't want to install this package per project, simply install it as a global dependency (e.g. on your CI):

$ composer global require icanhazstring/composer-unused

Local

You can also install composer-unused as a local development dependency:

$ composer require --dev icanhazstring/composer-unused

❗ Beware: Local (or global) requirement might lead to issues related to outdated or replaced dependencies and composer-unused might not work as intended!

Usage

Depending on the art of your installation the command might differ.

PHAR

The phar archive can be run directly in you project:

$ php composer-unused.phar

Local/Global

Having composer-unused as a local or global dependency you can run it as an composer-plugin:

$ composer unused

Exclude folders and packages

Sometimes you don't want to scan a certain directory or ignore a Composer package while scanning. In these cases, you can provide the --excludeDir or the --excludePackage option. These options accept multiple values as shown next:

$ php composer-unused.phar --excludeDir=config --excludePackage=symfony/console
$ php composer-unused.phar \
    --excludeDir=bin \
    --excludeDir=config \
    --excludePackage=symfony/assets \
    --excludePackage=symfony/console

Make sure the package is named exactly as in your composer.json

Ignore by configuration

You are also able to exclude packages by configuration. For this, you need to provide the extra directive in your composer.json file.

{
    "extra": {
        "unused": [
            "package/a",
            "package/b"
        ]
    }
}

Suppress progress bar

If you run composer-unused in CI the console progressbar often messes up your logs files. To suppress them use:

`$ php composer-unused.phar --no-progress`

Troubleshooting

If you encounter some errors, try running:

$ php composer-unused.phar -vvv

This command will enable the debug mode and create an error report beside your composer.json.

composer-unused-dump-YmdHis

Changelog

Please have a look at CHANGELOG.md.

Contributing

Please have a look at CONTRIBUTING.md.

Code of Conduct

Please have a look at CODE_OF_CONDUCT.md.

License

This package is licensed under the MIT License.

composer-unused's People

Contributors

bcremer avatar binarious avatar caneco avatar finagin avatar icanhazstring avatar machour avatar marcelthole avatar maxhelias avatar moltam avatar raphaelstolt avatar seriquynh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.