https://github.com/sirherobrine23/phargo
Parser Phar file in Golang
https://github.com/sirherobrine23/phargo
go golang phar php php-phar
Last synced: 8 months ago
JSON representation
Parser Phar file in Golang
- Host: GitHub
- URL: https://github.com/sirherobrine23/phargo
- Owner: Sirherobrine23
- License: mit
- Created: 2025-04-10T01:34:45.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-11T03:03:19.000Z (about 1 year ago)
- Last Synced: 2025-08-10T04:58:58.272Z (9 months ago)
- Topics: go, golang, phar, php, php-phar
- Language: Go
- Homepage:
- Size: 4.95 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Phargo
Reader Php Phar files in golang
## Info
Parser supports several signature algorithms:
* md5
* sha1
* sha256
* sha512
* OpenSSL
Also supports compression formats:
* None
* Gzip
* Bzip2
Can read manifest version, alias and metadata. For every file inside PHAR-archive can read it contents,
name, timestamp and metadata. Checks file CRC and signature of entire archive.
## Installation
1. Download and install:
```sh
go get -u github.com/Sirherobrine23/phargo
```
2. Import and use it:
```go
package main
import (
"encoding/json"
"flag"
"fmt"
"os"
"github.com/Sirherobrine23/phargo"
)
var pharFilePath = flag.String("file", "", "File path")
func main() {
flag.Parse()
// Open file
file, err := os.Open(*pharFilePath)
if err != nil {
fmt.Fprintf(os.Stderr, "Cannot open file: %s\n", err)
os.Exit(1)
return
}
// Get file size
stat, _ := file.Stat()
// Parse phar file
pharInfo, err := phargo.NewReader(file, stat.Size())
if err != nil {
fmt.Fprintf(os.Stderr, "Cannot parse file: %s\n", err)
os.Exit(1)
return
}
// Encode in json output
js := json.NewEncoder(os.Stdout)
js.SetIndent("", " ")
js.Encode(pharInfo)
}
```
## Running the tests
Just run the command:
```sh
go test
```
## License
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details