|
1 | | -# PHP Copy/Paste Detector report |
2 | | -This document describing how you can generate report. |
| 1 | +# HTML Report Generation |
| 2 | +This document describes how to generate visual, interactive HTML reports from `phpcpd`'s XML output. These reports make it significantly easier to navigate, analyze, and share code duplication metrics with your team. |
3 | 3 |
|
4 | | -## Requirements for html report generation |
5 | | -* [Xalan](https://xalan.apache.org) tool |
6 | | -* created folder (f.e. `reports/phpcpd`) with write access where you want to save your report |
| 4 | +## Requirements |
| 5 | +To generate HTML reports, ensure you have the following: |
| 6 | +* The [Xalan](https://xalan.apache.org) XSLT processor installed locally or within your Docker container. |
| 7 | +* A dedicated output directory (e.g., `reports/phpcpd/`) with write permissions. |
7 | 8 |
|
8 | | -Note: You can find some already-made examples inside our solutions on our [GitHub page](https://github.com/systemsdk) |
| 9 | +Note: You can find fully configured examples within the open-source projects hosted on our [GitHub page](https://github.com/systemsdk). |
9 | 10 |
|
10 | | -## Steps for html report generation |
11 | | -You need to run the next commands for html report generation: |
| 11 | +## Generation Steps |
| 12 | +Follow these steps to analyze your code and compile the HTML report: |
12 | 13 |
|
13 | | -1. Run PHP Copy/Paste Detector |
| 14 | +1. Run PHPCPD to generate an XML report |
14 | 15 | ```bash |
15 | 16 | php ./vendor/bin/phpcpd --fuzzy --verbose --log-pmd=reports/phpcpd/phpcpd-report-v1.xml src |
16 | 17 | ``` |
17 | 18 |
|
18 | | -Note: `src` is a folder where your php source code for analyzing |
| 19 | +Note: In this example, `src` represents the directory containing the PHP source code you wish to analyze. |
19 | 20 |
|
20 | | -2. Run xalan tool for report generation |
| 21 | +2. Run Xalan to convert the XML into HTML |
21 | 22 | ```bash |
22 | 23 | xalan -in reports/phpcpd/phpcpd-report-v1.xml -xsl https://systemsdk.github.io/phpcpd/report/phpcpd-html-v1_0_0.xslt -out reports/phpcpd/phpcpd-report-v1.html |
23 | 24 | ``` |
24 | 25 |
|
25 | | -3. Now you can open the report using your web-browser |
| 26 | +3. View the Report |
| 27 | +Open the newly generated `reports/phpcpd/phpcpd-report-v1.html` file in any modern web browser. |
26 | 28 |
|
27 | | - |
| 29 | +You can view a live [Example Report here](https://systemsdk.github.io/phpcpd/report/report-example.html). |
28 | 30 |
|
29 | | -[Example](https://systemsdk.github.io/phpcpd/report/report-example.html) |
| 31 | + |
30 | 32 |
|
31 | | -Note: Please use menu items `Enable datatable`, `Disable datatabl` for enable/disable [DataTables](https://datatables.net/). |
| 33 | +Tip: Use the `Enable datatable` and `Disable datatable` menu items at the top of the HTML report to toggle the interactive [DataTables](https://datatables.net/) grid for advanced sorting and searching. |
32 | 34 |
|
33 | | -## Xml report format |
34 | | -This format uses `xml` to output the duplications in a more structured format. The `xml` format can then further be processed using `xslt` transformations. See section xslt below for examples. |
| 35 | +## XML Report Format |
| 36 | +Under the hood, `phpcpd` outputs the duplications in a structured `XML` format. This structured data can then be processed further using XSLT transformations. |
35 | 37 |
|
36 | | -Report file example: |
37 | | -``` |
| 38 | +Here is an example of the generated XML output: |
| 39 | +```xml |
38 | 40 | <?xml version="1.0" encoding="UTF-8"?> |
39 | | -<pmd-cpd xmlns="https://systemsdk.github.io/phpcpd/report" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" phpcpdVersion="8.2.4" timestamp="2025-11-07T21:42:17+00:00" version="1.0.0" xsi:schemaLocation="https://systemsdk.github.io/phpcpd/report https://systemsdk.github.io/phpcpd/report/phpcpd-report-v1_0_0.xsd"> |
40 | | - <duplication lines="59" tokens="136"> |
41 | | - <file line="116" endline="175" path="/var/www/html/tests/Fixture/Math.php"/> |
42 | | - <file line="217" endline="276" path="/var/www/html/tests/Fixture/Math.php"/> |
43 | | - <codefragment><![CDATA[ public function div($v1, $v2) |
| 41 | +<pmd-cpd xmlns="https://systemsdk.github.io/phpcpd/report" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" suppressedClones="11" suppressedLines="140" phpcpdVersion="9.1.0" timestamp="2026-09-02T13:11:49+00:00" version="1.0.0" xsi:schemaLocation="https://systemsdk.github.io/phpcpd/report https://systemsdk.github.io/phpcpd/report/phpcpd-report-v1_0_0.xsd"> |
| 42 | + <duplication lines="59" tokens="136" exact="false"> |
| 43 | + <file line="116" endline="175" path="/var/www/html/tests/Fixture/Math.php"/> |
| 44 | + <file line="217" endline="276" path="/var/www/html/tests/Fixture/Math.php"/> |
| 45 | + <codefragment><![CDATA[ public function div($v1, $v2) |
44 | 46 | { |
45 | 47 | $v3 = $v1 / ($v2 + $v1); |
46 | 48 | if ($v3 > 14) |
@@ -100,20 +102,20 @@ Report file example: |
100 | 102 |
|
101 | 103 | return $v8; |
102 | 104 | ]]></codefragment> |
103 | | - </duplication> |
| 105 | + </duplication> |
104 | 106 | </pmd-cpd> |
105 | 107 | ``` |
106 | 108 |
|
107 | | -## Xslt |
108 | | -This is not a direct report format. But you can use one of the following `xslt` stylesheets to convert the report into `html`. Or you can write your own stylesheet. |
| 109 | +## XSLT Stylesheets |
| 110 | +While XML is the direct report format, you can use XSLT stylesheets to convert the report into HTML. |
109 | 111 |
|
110 | | -`https://systemsdk.github.io/phpcpd/report/phpcpd-html-v1_0_0.xslt` |
| 112 | +We provide an official, ready-to-use XSLT stylesheet: `https://systemsdk.github.io/phpcpd/report/phpcpd-html-v1_0_0.xslt`. |
111 | 113 |
|
112 | | -This stylesheet is available and using for html report generation mentioned above. |
| 114 | +This stylesheet is utilized in the generation example above. It requires JavaScript to be enabled and uses [Bootstrap](https://getbootstrap.com/), [jQuery](https://jquery.com/), and [DataTables](https://datatables.net/) to provide a responsive user interface. |
113 | 115 |
|
114 | | -It requires javascript enabled and uses [Bootstrap](https://getbootstrap.com/), [jQuery](https://jquery.com/), and [DataTables](https://datatables.net/). |
| 116 | +Tip: Alternatively, you are free to write and apply your own custom XSLT stylesheet to match your internal corporate branding. |
115 | 117 |
|
116 | | -## Schema versions |
117 | | -PHP Copy/Paste detector tool is building xml report that has schema `https://systemsdk.github.io/phpcpd/report/phpcpd-report-v1_0_0.xsd`. |
| 118 | +## Schema Versions |
| 119 | +The PHP Copy/Paste Detector generates XML reports that strictly adhere to the following schema: `https://systemsdk.github.io/phpcpd/report/phpcpd-report-v1_0_0.xsd`. |
118 | 120 |
|
119 | | -You can find xsd versions history [here](schema.md). |
| 121 | +For details regarding schema version history and specifications, please refer to the [Schema Documentation](schema.md). |
0 commit comments