Giter VIP home page Giter VIP logo

tooly-composer-script's Introduction

tooly-composer-script

Latest Stable Version Total Downloads Build Status Code Climate Test Coverage License

With the tooly composer-script aka hook you can manage needed phar files, such as phpunit, in your composer.json. Every phar file will be saved in the composer binary directory.

Why

Because of dependency-encapsulation! An example. You have a symfony application with a lot of commands and want to use the php7cc as an composer dev requirement.

Add this to your composer.json file and you are perhaps in a dependency hell. Because your symfony app needs the symfony console component in version x and php7cc in version y.

That is the situation you should use phar's for developing.

Example

For an quick example look at the composer.json here.

Install

To use the script just do the following single command:

Note: There are no further dependencies in this library. Only PHP.

composer require tm/tooly-composer-script

Then add the script in the composer.json under "scripts" with the event names you want to trigger. For example:

...
"scripts": {
    "post-install-cmd": "Tooly\\ScriptHandler::installPharTools",
    "post-update-cmd": "Tooly\\ScriptHandler::installPharTools"
  },
...

Look here for more informations about composer events.

Usage

The composer.json scheme has a part "extra" which is used for the script. Its described here.

In this part you can add your needed phar tools under the key "tools".

...
"extra": {
    ...
    "tools": {
      "phpunit": {
        "url": "https://phar.phpunit.de/phpunit-4.8.9.phar",
        "only-dev": true
      },
      "phpcpd": {
        "url": "https://phar.phpunit.de/phpcpd-2.0.4.phar",
        "only-dev": true
      }
    }
    ...
  }
...

After you add the name of the tool as key, you need only one further parameter. The "url". The url can be a link to a specific version, such as x.y.z, or a link to the latest version for this phar.

Every time you update or install with composer the phar tools are checked. You are asked if you want to overwrite the existing phar if the remote and local phar has not the same checksum.

The "only-dev" parameter is optional. Its default true and means that this phar is only needed in developing mode. So the command composer [install|update] --no-dev ignores this phar tool.

A note to PhpStorm or other IDE users

To furthermore have auto-suggestion you should set the "include_path" option in the project. PhpStorm setting

Contributing

Please refer to CONTRIBUTING.md for information on how to contribute.

tooly-composer-script's People

Contributors

hollodotme avatar tommy-muehle 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.