
A port of the var_dump function of PHP to Python.
This module allows you to “dump” trivial Python objects into PHP code.
Why? So you can use Python to write fast PHP websites when you need to run PHP websites.
Sometimes you need to run a PHP website.
Why on earth would you want this?!?!?
Imagine that you have to deploy something in PHP. You don’t have a choice. You HAVE to.
php_var_dump lets you do all your data processing and management in Python. You can then convert your native Python data structures into PHP code, which can then be saved as include fles for PHP.
Other Python modules that can accomplish the general idea:
phpserialize implements the PHP serialize/unserialize functions in Python allows you to serialize a Python data structure to PHP allows you to unserialize a php data structure to Python
simplejson there are json parsers in PHP, which can read code you save
The main benefit of using the var_dump method, is that there is no overhead in loading/unloading/parsing/etc.
This method allows you to build a PHP include file that simply runs fast, and that can use multiple includes within the filesystem as a “database” like system. This way you don’t have to set up any databases, libraries, or whatever - you can just deploy PHP code without coding much in PHP.
Usage
from php_var_dump import php_var_dump
data = "Hello World"
as_php = php_var_dump('var', data )
print(as_php)
That will generate valid PHP code:
$var = 'Hello World';
You’d probable then want to save it…
data_string = "<?php\n\n%s\n\n?>" % as_php
open('data.php', 'w').write(data_string.encode( "utf-8" ))
Then just include the data.php file in your PHP programs.
There’s also a php_as_block function, which does the trivial encapsulation as above.
- copyright:
2012 by Jonathan Vanasco
- license:
BSD
Changelog
v0.3.2 * packaging fixes
v0.3.1 * packaging fixes
v0.3 * upgraded black; 20.8b1 * integrated with pre-commit * tox, github actions * python3 support
v0.2 * flake8
v0.1 * initial
Metadata
Release files for php-var-dump 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| php_var_dump-0.3.2.tar.gz | 4.3 kB | Without provenance | Details |
Release files / php_var_dump-0.3.2.tar.gz
| Download URL | php_var_dump-0.3.2.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a5b2f0d918e8a0a477fbebd49958a00eef997f86417318ecf2e5235e28f8700c
|
|
BLAKE2b-256 checksum How to use checksums |
45855a1cf0485ccbcb4d11b50fffaa99302abdcfe3e7caf019682883338711af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
|
Security for php-var-dump 0.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.