From 39a35fd25ab02e2815ac9696bb61643fa086b168 Mon Sep 17 00:00:00 2001 From: Friedhelm Betz Date: Fri, 13 Aug 2004 14:26:44 +0000 Subject: [PATCH] bcompiler docs: move from peardoc git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@166290 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/bcompiler/configure.xml | 99 +++++++++++++++++++ .../functions/bcompiler-load-exe.xml | 54 ++++++++++ .../bcompiler/functions/bcompiler-load.xml | 55 +++++++++++ .../functions/bcompiler-parse-class.xml | 58 +++++++++++ .../bcompiler/functions/bcompiler-read.xml | 55 +++++++++++ .../functions/bcompiler-write-class.xml | 67 +++++++++++++ .../functions/bcompiler-write-constant.xml | 64 ++++++++++++ .../functions/bcompiler-write-exe-footer.xml | 84 ++++++++++++++++ .../functions/bcompiler-write-footer.xml | 61 ++++++++++++ .../functions/bcompiler-write-function.xml | 65 ++++++++++++ .../bcompiler-write-functions-from-file.xml | 65 ++++++++++++ .../functions/bcompiler-write-header.xml | 60 +++++++++++ reference/bcompiler/reference.xml | 88 +++++++++++++++++ 13 files changed, 875 insertions(+) create mode 100644 reference/bcompiler/configure.xml create mode 100644 reference/bcompiler/functions/bcompiler-load-exe.xml create mode 100644 reference/bcompiler/functions/bcompiler-load.xml create mode 100644 reference/bcompiler/functions/bcompiler-parse-class.xml create mode 100644 reference/bcompiler/functions/bcompiler-read.xml create mode 100644 reference/bcompiler/functions/bcompiler-write-class.xml create mode 100644 reference/bcompiler/functions/bcompiler-write-constant.xml create mode 100644 reference/bcompiler/functions/bcompiler-write-exe-footer.xml create mode 100644 reference/bcompiler/functions/bcompiler-write-footer.xml create mode 100644 reference/bcompiler/functions/bcompiler-write-function.xml create mode 100644 reference/bcompiler/functions/bcompiler-write-functions-from-file.xml create mode 100644 reference/bcompiler/functions/bcompiler-write-header.xml create mode 100644 reference/bcompiler/reference.xml diff --git a/reference/bcompiler/configure.xml b/reference/bcompiler/configure.xml new file mode 100644 index 0000000000..00257d7a17 --- /dev/null +++ b/reference/bcompiler/configure.xml @@ -0,0 +1,99 @@ + + +
+ &reftitle.install; + + short installation note: + + + You need at least PHP 4.3. for the compression to work + + + + To install on PHP 4.3 and later at the unix command prompt type + pear install bcompiler + + + + + To install on Windows, until the binary package distribution + mechanism is finished please search the archives of the pear-general + mailing list for pre-built packages. (or send an email to it if you could + not find a reference) + + + + + To install on older versions you need to make some slight changes to the + build. + + + + + untar the bcompiler.tgz archive into + php4/ext.(Get it directly from + PECL &url.pecl.package.get;bcompiler) + + + + + If the new directory is now called something like bcompiler-0.x, then you + should rename it to bcompiler (except you only want to build it as + self-contained php-module). + + + + + If you are using versions before PHP 4.3, the you will need to copy the + Makefile.in.old to Makefile.in + and config.m4.old to config.m4. + + + + + run phpize in + ext/bcompiler + + + + + run ./buildconf in php4 + + + + + + run configure with (and your other options) + + + + + make; make install + + + that's it. + + +
+ + diff --git a/reference/bcompiler/functions/bcompiler-load-exe.xml b/reference/bcompiler/functions/bcompiler-load-exe.xml new file mode 100644 index 0000000000..4c253f1735 --- /dev/null +++ b/reference/bcompiler/functions/bcompiler-load-exe.xml @@ -0,0 +1,54 @@ + + + + + + bcompiler_load_exe + reads and creates classes from a bcompiler exe file + + + Description + + boolbcompiler_load_exe + stringfilename + + &warn.experimental.func; + + Reads data from a bcompiler exe file and creates classes from the bytecodes + + + <function>bcompiler_load</function> example + + +]]> + + + + + + diff --git a/reference/bcompiler/functions/bcompiler-load.xml b/reference/bcompiler/functions/bcompiler-load.xml new file mode 100644 index 0000000000..600822db26 --- /dev/null +++ b/reference/bcompiler/functions/bcompiler-load.xml @@ -0,0 +1,55 @@ + + + + + + bcompiler_load + reads and creates classes from a bz compressed file + + + Description + + boolbcompiler_load + stringfilename + + &warn.experimental.func; + + Reads data from a bzcompressed file and creates classes from the bytecodes + + + <function>bcompiler_load</function> example + + +]]> + + + + + + diff --git a/reference/bcompiler/functions/bcompiler-parse-class.xml b/reference/bcompiler/functions/bcompiler-parse-class.xml new file mode 100644 index 0000000000..a8662e90c8 --- /dev/null +++ b/reference/bcompiler/functions/bcompiler-parse-class.xml @@ -0,0 +1,58 @@ + + + + + + bcompiler_parse_class + reads the bytecodes of a class and calls back to a user function + + + Description + + boolbcompiler_parse_class + stringclass + stringcallback + + &warn.experimental.func; + + reads the bytecodes of a class and calls back to a user function + + + <function>bcompiler_parse_class</function> example + + +]]> + + + + + + diff --git a/reference/bcompiler/functions/bcompiler-read.xml b/reference/bcompiler/functions/bcompiler-read.xml new file mode 100644 index 0000000000..fb48b3d6e8 --- /dev/null +++ b/reference/bcompiler/functions/bcompiler-read.xml @@ -0,0 +1,55 @@ + + + + + + bcompiler_read + reads and creates classes from a filehandle + + + Description + + boolbcompiler_read + resourcefilehandle + + &warn.experimental.func; + + Reads data from a open file handle and creates classes from the bytecodes + + + <function>bcompiler_read</function> example + + +]]> + + + + + + diff --git a/reference/bcompiler/functions/bcompiler-write-class.xml b/reference/bcompiler/functions/bcompiler-write-class.xml new file mode 100644 index 0000000000..baff88a1f5 --- /dev/null +++ b/reference/bcompiler/functions/bcompiler-write-class.xml @@ -0,0 +1,67 @@ + + + + + + bcompiler_write_class + Writes an defined class as bytecodes + + + Description + + boolbcompiler_write_class + resourcefilehandle + stringclassName + + &warn.experimental.func; + + This reads the bytecodes from PHP for an existing class, and writes them + to the open file handle, It does not perform dependancy checking, so make + sure you write the classes in an order that will not result in an + 'undefined class' occuring when you load it. + + + <function>bcompiler_write_class</function> example + + +]]> + + + + See also bcompiler_write_header, + and bcompiler_write_footer. + + + + + diff --git a/reference/bcompiler/functions/bcompiler-write-constant.xml b/reference/bcompiler/functions/bcompiler-write-constant.xml new file mode 100644 index 0000000000..e5d3d278dc --- /dev/null +++ b/reference/bcompiler/functions/bcompiler-write-constant.xml @@ -0,0 +1,64 @@ + + + + + + bcompiler_write_constant + Writes a defined constant as bytecodes + + + Description + + boolbcompiler_write_constant + resourcefilehandle + stringconstantName + + &warn.experimental.func; + + This function reads the bytecodes from PHP for an existing constant, and + writes them to the open file handle. + + + <function>bcompiler_write_constant</function> example + + +]]> + + + + See also bcompiler_write_header, + and bcompiler_write_footer. + + + + + diff --git a/reference/bcompiler/functions/bcompiler-write-exe-footer.xml b/reference/bcompiler/functions/bcompiler-write-exe-footer.xml new file mode 100644 index 0000000000..eded03a2fd --- /dev/null +++ b/reference/bcompiler/functions/bcompiler-write-exe-footer.xml @@ -0,0 +1,84 @@ + + + + + + bcompiler_write_exe_footer + Writes the the start pos, and sig to the end of a exe type file + + + Description + + boolbcompiler_write_exe_footer + resourcefilehandle + intstartpos + + &warn.experimental.func; + + An EXE (or self executable) file consists of 3 parts, + + + + + The Executable code (eg. a compiled C program that can initiate call + the PHP bcompiler) + + The Bzip encoded Bytecodes + The bcompiler exe footer + + The startpos is the position of in the file at + which the Bzip encoded bytecodes start, and can be obtained using + ftell($fh). + + + <function>bcompiler_write_footer</function> example + + +]]> + + + + See also bcompiler_write_header, + bcompiler_write_class, and + bcompiler_write_footer. + + + + + diff --git a/reference/bcompiler/functions/bcompiler-write-footer.xml b/reference/bcompiler/functions/bcompiler-write-footer.xml new file mode 100644 index 0000000000..e7fba6f227 --- /dev/null +++ b/reference/bcompiler/functions/bcompiler-write-footer.xml @@ -0,0 +1,61 @@ + + + + + + bcompiler_write_footer + Writes the single character \x00 to indicate End of compiled data + + + Description + + boolbcompiler_write_footer + resourcefilehandle + + &warn.experimental.func; + + Writes the a single character \x00 to indicate End of compiled data + + + <function>bcompiler_write_footer</function> example + + +]]> + + + + See also bcompiler_write_header, and + bcompiler_write_header. + + + + + diff --git a/reference/bcompiler/functions/bcompiler-write-function.xml b/reference/bcompiler/functions/bcompiler-write-function.xml new file mode 100644 index 0000000000..f482d410d1 --- /dev/null +++ b/reference/bcompiler/functions/bcompiler-write-function.xml @@ -0,0 +1,65 @@ + + + + + + bcompiler_write_function + Writes an defined function as bytecodes + + + Description + + boolbcompiler_write_function + resourcefilehandle + stringfunctionName + + &warn.experimental.func; + + This reads the bytecodes from PHP for an existing function, and writes + them to the open file handle. Order is not important, (eg. if function b + uses function a, and you compile it like the example below, it will + work perfectly OK) + + + <function>bcompiler_write_function</function> example + + +]]> + + + + See also bcompiler_write_header, and + bcompiler_write_footer. + + + + + diff --git a/reference/bcompiler/functions/bcompiler-write-functions-from-file.xml b/reference/bcompiler/functions/bcompiler-write-functions-from-file.xml new file mode 100644 index 0000000000..e44461cffa --- /dev/null +++ b/reference/bcompiler/functions/bcompiler-write-functions-from-file.xml @@ -0,0 +1,65 @@ + + + + + + bcompiler_write_functions_from_file + Writes all functions defined in a file as bytecodes + + + Description + + boolbcompiler_write_functions_from_file + resourcefilehandle + stringfileName + + &warn.experimental.func; + + This function searches for all functions declared in the given file, and + writes their correspondent bytecodes to the open file handle. Always + remember to include/require the file you intend to compile. + + + <function>bcompiler_write_functions_from_file</function> example + + +]]> + + + + See also bcompiler_write_header, and + bcompiler_write_footer. + + + + + diff --git a/reference/bcompiler/functions/bcompiler-write-header.xml b/reference/bcompiler/functions/bcompiler-write-header.xml new file mode 100644 index 0000000000..2a41451b85 --- /dev/null +++ b/reference/bcompiler/functions/bcompiler-write-header.xml @@ -0,0 +1,60 @@ + + + + + + bcompiler_write_header + Writes the bcompiler header + + + Description + + boolbcompiler_write_header + resourcefilehandle + + &warn.experimental.func; + + Writes the header part of a bcompiler file. + + + <function>bcompiler_write_header</function> example + + +]]> + + + + See also bcompiler_write_class, and + bcompiler_write_footer. + + + + + diff --git a/reference/bcompiler/reference.xml b/reference/bcompiler/reference.xml new file mode 100644 index 0000000000..d0521c7d0e --- /dev/null +++ b/reference/bcompiler/reference.xml @@ -0,0 +1,88 @@ + + + + PHP bytecode Compiler + bcompiler + + +
+ &reftitle.intro; + &warn.experimental; + + Bcompiler was written for two reasons: + + To encode some classes in a proprietary PHP application + + To enable the production of php-gtk applications that could be used on + client desktops, without the need for a php.exe. + + To do the feasibility study for a PHP to C converter + + The first of these goals is achieved using the + bcompiler_write_header, + bcompiler_write_class, + bcompiler_write_footer, + bcompiler_read, + and bcompiler_load functions. The bytecode files can + be written as either uncompressed or plain. The + bcompiler_load reads a bzip compressed bytecode file, + which tends to be 1/3 of the size of the original file. + + + To create EXE type files, bcompiler has to be used with a modified sapi + file or a version of PHP which has been compiled as a shared library. In + this scenario, bcompiler reads the compressed bytecode from the end of the + exe file. + + + bcompiler is unlikely to improve performance very much, as it only + bypasses the compiler stage of the PHP running process and replaces it + with the import process in bcompiler. It also does not do any bytecode + optimization, this could be added in the future. + + + In terms of code protection, it is safe to say that it would be impossible + to recreate the exact source code that it was built from, and without the + accompanying source code comments. It would effectively be useless to use + the bcompiler bytecodes to recreate and modify a class. However it is + possible to retrieve data from a bcompiled bytecode file - so don't put + your private passwords or anything in it. + +
+ + &reference.bcompiler.configure; + +
+ Contact Information + + If you have comments, bugfixes, enhancements or want to help + developing this beast, you can drop me a mail at alan_k@php.net. Any help is very + welcome. + +
+ +
+ +&reference.bcompiler.functions; + +
+