Lisensi Legal adalah utilitas untuk membantu menghasilkan satu file teks yang berisi semua informasi penting tentang ketergantungan proyek. Di beberapa organisasi, penggunaan Perangkat Lunak Sumber Terbuka (OSS) dikontrol dan diaudit secara ketat, dan mengharuskan setiap perpustakaan OSS didokumentasikan secara sederhana.
Utilitas ini akan menghasilkan file licenses.md
di root proyek Anda yang berisi daftar semua dependensi, versi yang diinstal saat ini, commit sha, deskripsinya, beranda, daftar lisensi, dan teks lisensi lengkap jika ada di kode sumber ketergantungan secara langsung. Ia menerima informasi ini dari file composer.lock
, jadi Anda harus menjalankan composer update
atau composer install
setidaknya sekali untuk menggunakan utilitas ini.
Jika Anda membutuhkan utilitas seperti ini untuk tempat usaha Anda, kemungkinan besar Anda akan membutuhkannya untuk lebih dari satu proyek. Oleh karena itu, cara termudah dan direkomendasikan untuk menginstal utilitas ini adalah sebagai paket komposer global:
composer global require comcast/php-legal-licenses
Jika Anda menginstal php-legal-licenses secara global melalui composer, Anda seharusnya dapat menjalankan skrip di proyek mana pun. Catatan, Anda harus menjalankan composer update
atau composer install
setidaknya sekali, untuk membuat file composer.lock
.
$ cd /path/to/my/project
$ which php-legal-licenses
> ~/.composer/vendor/bin/php-legal-licenses
$ php-legal-licenses generate
> Generating Licenses file...
> Done!
Anda juga dapat menyembunyikan versi ketergantungan dengan opsi --hide-version
:
$ php-legal-licenses generate --hide-version
Anda dapat menampilkan file csv dengan opsi --csv
:
$ php-legal-licenses generate --csv
Atau gunakan kedua opsi:
$ php-legal-licenses generate --hide-version --csv
Berikut cuplikan file lisensi yang akan dihasilkan untuk utilitas ini sendiri:
# 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
...