Home > Backend Development > PHP Tutorial > About php packaging and unpacking Phar

About php packaging and unpacking Phar

藏色散人
Release: 2023-04-07 20:30:02
forward
3180 people have browsed it

Recently I used php to connect to hive and found php-thrift-sql (https://github.com/Automattic/php-thrift-sql). I found a sentence in the readme:
The first contact was with Boss Han. Create swooole packaging article

php -c php.ini build.php
Copy after login

Because phar.readonly in php.ini is on by default, and we need to unpack and package it here, so we need to configure it as follows

[Phar]
; http://php.net/phar.readonlyphar.readonly = Off
; http://php.net/phar.require-hash;phar.require_hash = On
;phar.cache_list =
Copy after login

We see that there is a ThriftSQL.phar in the code. If you want to know how to use it, you should look at the source code. So how to unpack it?

<?php$phar =new Phar("./ThriftSQL.phar");
$re=$phar->extractTo("Thrift-origin");
var_dump($re);
Copy after login

If the unpacking is correct, it will return true, so there will be one more Thrift-origin file in the path.

php returned.php 
bool(true)
root@tongbo:/home/tb/tmpdown# lsci_3.1.30  ci.zip  php-thrift-sql  returned.php  Thrift-origin  ThriftSQL.phar
root@tongbo:/home/tb/tmpdown#
Copy after login

Enter Thrift-origin and you can see the specific php code.

Recommended: "PHP Tutorial"

The above is the detailed content of About php packaging and unpacking Phar. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template