ใบอนุญาตทางกฎหมายเป็นโปรแกรมอรรถประโยชน์ที่ช่วยสร้างไฟล์ข้อความเดียวที่มีข้อมูลสำคัญทั้งหมดเกี่ยวกับการขึ้นต่อกันของโครงการ ในบางองค์กร การใช้ซอฟต์แวร์โอเพ่นซอร์ส (OSS) ได้รับการควบคุมและตรวจสอบอย่างเข้มงวด และกำหนดให้มีไลบรารี OSS ทุกแห่งที่จัดทำเป็นเอกสารอย่างเรียบง่าย
ยูทิลิตี้นี้จะสร้างไฟล์ licenses.md
ในรูทของโปรเจ็กต์ของคุณซึ่งประกอบด้วยรายการการขึ้นต่อกันทั้งหมด เวอร์ชันที่ติดตั้งในปัจจุบัน คอมมิต sha คำอธิบาย หน้าแรก รายการสิทธิ์การใช้งาน และข้อความสิทธิ์การใช้งานแบบเต็ม หากมีอยู่ใน ซอร์สโค้ดการพึ่งพาโดยตรง ได้รับข้อมูลนี้จากไฟล์ composer.lock
ดังนั้นคุณต้องรัน composer update
หรือ composer install
อย่างน้อยหนึ่งครั้งจึงจะสามารถใช้ยูทิลิตีนี้ได้
หากคุณต้องการสาธารณูปโภคเช่นนี้สำหรับสถานประกอบการของคุณ มีโอกาสที่คุณจะต้องใช้สำหรับโครงการมากกว่าหนึ่งโครงการ ดังนั้น วิธีที่ง่ายที่สุดและแนะนำในการติดตั้งยูทิลิตีนี้คือเป็นแพ็คเกจผู้แต่งสากล:
composer global require comcast/php-legal-licenses
หากคุณติดตั้ง php-legal-licenses ทั่วโลกผ่านทางผู้แต่ง คุณจะสามารถเรียกใช้สคริปต์ในโปรเจ็กต์ของคุณได้ หมายเหตุ คุณต้องเรียกใช้ composer update
หรือ composer install
อย่างน้อยหนึ่งครั้งเพื่อสร้างไฟล์ 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!
คุณยังสามารถซ่อนเวอร์ชันการพึ่งพาด้วยตัวเลือก --hide-version
:
$ php-legal-licenses generate --hide-version
คุณสามารถส่งออกไฟล์ csv ด้วยตัวเลือก --csv
:
$ php-legal-licenses generate --csv
หรือใช้ทั้งสองตัวเลือก:
$ php-legal-licenses generate --hide-version --csv
นี่คือตัวอย่างไฟล์ใบอนุญาตที่จะสร้างขึ้นสำหรับยูทิลิตี้นี้:
# 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
...