Giter Club home page Giter Club logo

php-legal-licenses's Introduction

StyleCI Status Total Downloads Latest Stable Version License

PHP Legal Licenses

Legal Licenses is a utility to help generate a single text file containing all of the important information about a project's dependencies. In some organizations, the use of Open Source Software (OSS) is strictly controlled and audited, and requires having every OSS library simply documented.

This utility will generate a licenses.md file in the root of your project that contains a list of all dependencies, the currently installed version, commit sha, its description, homepage, list of licenses, and full license text if it is present in the dependency source code directly. It receives this information from the composer.lock file, so you must have run a composer update or composer install at least once in order to use this utility.

Installation

If you need a utility such as this for your place of business, chances are, you will need it for more than a single project. Therefore, the easiest and reccommeded way to install this utility is as a global composer package:

composer global require comcast/php-legal-licenses

Usage

If you installed php-legal-licenses globally via composer, you should be able to run the script in any of your projects. Note, you must have run either composer update or composer install at least once, to create a composer.lock file.

$ cd /path/to/my/project
$ which php-legal-licenses
> ~/.composer/vendor/bin/php-legal-licenses
$ php-legal-licenses generate
> Generating Licenses file...
> Done!

You can also hide dependency version with --hide-version option:

$ php-legal-licenses generate --hide-version

You can output csv file with --csv option:

$ php-legal-licenses generate --csv

Or use both option:

$ php-legal-licenses generate --hide-version --csv

Example Output

Here is a snippet of the licenses file that would be generated for this utility itself:

# Project Licenses
This file was generated by the Legal Licenses utility. It contains the name, version and commit sha, description, homepage, and license information for every dependency in this project.

## Dependencies

### psr/log (Version 1.0.2 | 4ebe3a8)
Common interface for logging libraries
Homepage: https://github.com/php-fig/log
Licenses Used: MIT
Copyright (c) 2012 PHP Framework Interoperability Group

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.


### symfony/console (Version v3.3.6 | b087823)
Symfony Console Component
Homepage: https://symfony.com
Licenses Used: MIT

...

php-legal-licenses's People

Contributors

akondas avatar dschniepp avatar gpupo avatar johnriv avatar matijaboban avatar orediggerco avatar shooding avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-legal-licenses's Issues

Make compatible with latest PHPUnit 8 / phpDocumentor

Hi!

When I try to require this package together with PHPUnit 8 and phpDocumentor (v3) I get the following error:

matzeeable@MSI:/d/Programme/VSCode Workspace/wp-reactjs-starter/plugins/wp-reactjs-starter$ composer require --dev phpdocumentor/phpdocumentor 3.0.x-dev
    1/2:        http://packagist.org/p/provider-2020-01$49a31ca2d5e78eaf012aa1abd411dd1caea8d5854d4f775675df3fd035be6ed9.json
    2/2:        http://packagist.org/p/provider-latest$e4ee51c940c6b6adb8201ada4774af9a6af9e097518aae92d756e85e8439a40d.json
    Finished: success: 2, skipped: 0, failure: 0, total: 2
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - don't install phpdocumentor/phpdocumentor 3.0.x-dev|install phpdocumentor/phpdocumentor dev-master
    - Installation request for phpdocumentor/phpdocumentor 3.0.x-dev -> satisfiable by phpdocumentor/phpdocumentor[3.0.x-dev].
    - Conclusion: remove symfony/console v4.4.2
    - Conclusion: don't install symfony/console v4.4.2
    - phpdocumentor/phpdocumentor dev-master requires symfony/console ^5.0 -> satisfiable by symfony/console[5.0.x-dev, 5.1.x-dev, v5.0.0, v5.0.0-BETA1, v5.0.0-BETA2, v5.0.0-RC1, v5.0.1, v5.0.2].
    - Can only install one of: symfony/console[5.0.x-dev, v4.4.2].
    - Can only install one of: symfony/console[5.1.x-dev, v4.4.2].
    - Can only install one of: symfony/console[v5.0.0, v4.4.2].
    - Can only install one of: symfony/console[v5.0.0-BETA1, v4.4.2].
    - Can only install one of: symfony/console[v5.0.0-BETA2, v4.4.2].
    - Can only install one of: symfony/console[v5.0.0-RC1, v4.4.2].
    - Can only install one of: symfony/console[v5.0.1, v4.4.2].
    - Can only install one of: symfony/console[v5.0.2, v4.4.2].
    - Installation request for symfony/console (locked at v4.4.2) -> satisfiable by symfony/console[v4.4.2].


Installation failed, reverting ./composer.json to its original content.

Do you think this package can be used with https://github.com/symfony/console v5?

Best regards,
Matthew 🙂

Comcast\PhpLegalLicenses\Console\string, string given

The following error
Error Output: PHP Catchable fatal error: Argument 1 passed to Comcast\PhpLegalLicenses\Console\GenerateCommand::generateDependencyText() must be an instance of Comcast\PhpLegalLicenses\Console\string, string given

Is given when running, this is due to the type hint 'string' in the function definitions of these two functions, PHP doesn't require hints for primative types.

This is using PHP 5.6, prior to 7 only hinting for objects and arrays is used.

Distribute as PHAR

Is your feature request related to a problem? Please describe.
It's not as easy to keep and shuffle around composer global tools as it is PHAR tools.

Describe the solution you'd like
It would be great if you folks could distribute this as a PHAR app.

Additional context
I've used box-project/box a great deal and it's an easy way to get started.

Issue with execute() expecting an integer return in symfony 5

HI @orediggerco,
it seems that the update to symfony/console and symfony/process update to ~5.0 in v1.1.3 (#12 ) introduced an issue related to expected execute() output, as it is expected as integer now.

This is causing the following issue when running the command:

Return value of "Comcast\PhpLegalLicenses\Console\GenerateCommand::execute()" must be of the type int, NULL returned. 

I've taken a quick look at the documentation at Symfony console docs and opened a simple PR (#13 ) to solve this.

Please note that as the project doesn't seem to have exposed unit tests, I haven't included any in the PR.

[BUG] Requirements prevent installation with Symfony 6.0 dependencies present

Describe the bug
This package is not installable when using Symfony 6 due to package.json version constraints.

To Reproduce
Steps to reproduce the behavior:

  1. composer require symfony/console=6.0
  2. composer require Comcast/php-legal-licenses
  3. See error:
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - comcast/php-legal-licenses[v1.1.0, ..., v1.1.2] require php ^5.6 || ^7.0 || ^7.1 -> your php version (8.0.12) does not satisfy that requirement.
    - comcast/php-legal-licenses[v1.1.3, ..., v1.1.4] require php ^5.6 || ^7.1 || ^7.2 || ^7.3 || ^7.4 -> your php version (8.0.12) does not satisfy that requirement.
    - comcast/php-legal-licenses[v1.1.5, ..., v1.1.6] require symfony/console ~2.3|~3.0|~4.0|~5.0 -> found symfony/console[v2.3.0, ..., v2.8.52, v3.0.0, ..., v3.4.47, v4.0.0, ..., v4.4.37, v5.0.0, ..., v5.4.3] but it conflicts with your root composer.json require (6.0).
    - Root composer.json requires comcast/php-legal-licenses ^1.1 -> satisfiable by comcast/php-legal-licenses[v1.1.0, ..., v1.1.6].

Expected behavior
Installation success.

Run Environment (please complete the following information):
OS, PHP version, composer version etc are not applicable

Additional context
Tried to create a PR, the the only response is
image

Symlinked packages not working

Hi!

I just noticed that symlinked packages does not work as expected. I have the following settings in my composer.json:

{
    "repositories": [
        {
            "type": "path",
            "url": "../../packages/*",
            "options": {
                "symlink": true
            }
        }
    ]
}

And my composer.lock results in the following (for a symlinked package):

{
    "packages": [
        {
            "name": "wp-reactjs-multi-starter/utils",
            "version": "dev-feat/multipackage",
            "dist": {
                "type": "path",
                "url": "../../packages/utils",
                "reference": "bb1d92ba33ae3925685c4cc5701938b71e37627b",
                "shasum": null
            },
            "archive": {
                "exclude": [
                    "lib"
                ]
            },
            "type": "library",
            "autoload": {
                "psr-4": {
                    "MatthiasWeb\\Utils\\": "src/"
                }
            },
            "license": [
                "MIT"
            ],
            "authors": [
                {
                    "name": "Matthias Günter",
                    "email": "hidden"
                }
            ],
            "description": "Utility functionality for all your WordPress plugins",
            "transport-options": {
                "symlink": true
            }
        }
    ],
}

That results to the following error:

PHP Notice:  Undefined index: source in /d/Programme/VSCode Workspace/wp-reactjs-starter/plugins/wp-reactjs-starter/vendor/comcast/php-legal-licenses/src/Comcast/PhpLegalLicenses/Command/GenerateCommand.php on line 89
PHP Stack trace:
PHP   1. {main}() /d/Programme/VSCode Workspace/wp-reactjs-starter/plugins/wp-reactjs-starter/vendor/comcast/php-legal-licenses/bin/php-legal-licenses:0
PHP   2. Symfony\Component\Console\Application->run() /d/Programme/VSCode Workspace/wp-reactjs-starter/plugins/wp-reactjs-starter/vendor/comcast/php-legal-licenses/bin/php-legal-licenses:15
PHP   3. Symfony\Component\Console\Application->doRun() /d/Programme/VSCode Workspace/wp-reactjs-starter/plugins/wp-reactjs-starter/vendor/symfony/console/Application.php:117
PHP   4. Symfony\Component\Console\Application->doRunCommand() /d/Programme/VSCode Workspace/wp-reactjs-starter/plugins/wp-reactjs-starter/vendor/symfony/console/Application.php:185
PHP   5. Comcast\PhpLegalLicenses\Console\GenerateCommand->run() /d/Programme/VSCode Workspace/wp-reactjs-starter/plugins/wp-reactjs-starter/vendor/symfony/console/Application.php:835
PHP   6. Comcast\PhpLegalLicenses\Console\GenerateCommand->execute() /d/Programme/VSCode Workspace/wp-reactjs-starter/plugins/wp-reactjs-starter/vendor/symfony/console/Command/Command.php:245
PHP   7. Comcast\PhpLegalLicenses\Console\GenerateCommand->generateLicensesText() /d/Programme/VSCode Workspace/wp-reactjs-starter/plugins/wp-reactjs-starter/vendor/comcast/php-legal-licenses/src/Comcast/PhpLegalLicenses/Command/GenerateCommand.php:41
PHP   8. Comcast\PhpLegalLicenses\Console\GenerateCommand->getTextForDependency() /d/Programme/VSCode Workspace/wp-reactjs-starter/plugins/wp-reactjs-starter/vendor/comcast/php-legal-licenses/src/Comcast/PhpLegalLicenses/Command/GenerateCommand.php:57

The issue comes from this line:

$sha = str_split($dependency['source']['reference'], 7)[0];

Due to the fact I am using a symlinked package the lockfile never generates a source section for the package. Changing the affected line to the below solves the issue:

$sha = isset($dependency['source']) ? str_split($dependency['source']['reference'], 7)[0] : 'no sha';

What do you think?

Thanks for your answer! :-)

[BUG] Requirements prevent installation with Symfony 7.0 dependencies present

Describe the bug
Same as this previous issue but for version 7.0.

To Reproduce
Steps to reproduce the behavior:

  1. composer require symfony/console=7.0
  2. composer require Comcast/php-legal-licenses
  3. See error:
Problem 1
    - Root composer.json requires comcast/php-legal-licenses ^1.2 -> satisfiable by comcast/php-legal-licenses[v1.2.0].
    - comcast/php-legal-licenses v1.2.0 requires symfony/console ~2.3|~3.0|~4.0|~5.0|~6.0 -> found symfony/console[v2.3.0, ..., v2.8.52, v3.0.0, ..., v3.4.47, v4.0.0, ..., v4.4.49, v5.0.0, ..., v5.4.36, v6.0.0, ..., v6.4.4] but it conflicts with your root composer.json require (7.0).

Expected behavior
The install is successful.

Run Environment (please complete the following information):
N/a

Pull Request
PR Request Added

PHP Fatal error: Uncaught Error: Call to undefined function Symfony\Polyfill\Mbstring\iconv() in /cygdrive/d/projects/agfin/vendor/symfony/polyfill-mbstring/Mbstring.php:114

Hello, I am getting this error. I installed this package as a local dev package in the project. May that be the problem?

PHP Fatal error: Uncaught Error: Call to undefined function Symfony\Polyfill\Mbstring\iconv() in /cygdrive/d/projects/agfin/vendor/symfony/polyfill-mbstring/Mbstring.php:114

Stack trace:
#0 /cygdrive/d/projects/agfin/vendor/symfony/polyfill-mbstring/bootstrap.php(19): Symfony\Polyfill\Mbstring\Mbstring::mb_convert_encoding('Composer Lock f...', 'UTF-8', 'ASCII')
#1 /cygdrive/d/projects/agfin/vendor/symfony/console/Application.php(1125): mb_convert_encoding('Composer Lock f...', 'utf8', 'ASCII')
#2 /cygdrive/d/projects/agfin/vendor/symfony/console/Application.php(780): Symfony\Component\Console\Application->splitStringByWidth('Composer Lock f...', 199)
#3 /cygdrive/d/projects/agfin/vendor/symfony/console/Application.php(750): Symfony\Component\Console\Application->doRenderException(Object(RuntimeException), Object(Symfony\Component\Console\Output\StreamOutput))
#4 /cygdrive/d/projects/agfin/vendor/symfony/console/Application.php(128): Symfony\Component\Console\Application->renderException(Object(RuntimeException), Object(Symfo in /cygdrive/d/projects/agfin/vendor/symfony/polyfill-mbstring/Mbstring.php on line 114

Support PHP 8.0.0

Is your feature request related to a problem? Please describe.
I am unable to use your software with PHP 8

Describe the solution you'd like
Update composer.json to allow ^8.0

$ composer update
Loading composer repositories with package information
Updating dependencies                                 
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - comcast/php-legal-licenses[v1.1.0, ..., v1.1.2] require php ^5.6 || ^7.0 || ^7.1 -> your php version (8.0.0) does not satisfy that requirement.
    - comcast/php-legal-licenses[v1.1.3, ..., v1.1.4] require php ^5.6 || ^7.1 || ^7.2 || ^7.3 || ^7.4 -> your php version (8.0.0) does not satisfy that requirement.
    - Root composer.json requires comcast/php-legal-licenses ^1.1 -> satisfiable by comcast/php-legal-licenses[v1.1.0, ..., v1.1.4].

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.