Nauka programowania php
Prosty kurs dla amatorów
VIII. PHP bytecode Compiler
Wstęp
| Ostrzeżenie |
Ten moduł jest w stadium EKSPERYMENTALNYM. Oznacza to, że zachowanie tych funkcji, ich nazwy, w zasadzie wszystko udokumentowane tutaj może zostać zmienione w przyszłych wersjach PHP bez wcześniejszego uprzedzenia. Używaj tego modułu na własne ryzyko. |
Bcompiler was written for several reasons:
| To encode entire script in a proprietary PHP application |
| To encode some classes and/or functions 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 second 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 can improve performance by about 30% when used with uncompressed bytecodes only. But keep in mind that uncompressed bytecode can be up to 5 times larger than the original source code. Using bytecode compression can save your space, but decompression requires much more time than parsing a source. bcompiler 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.
Instalacja
short installation note:
You need at least PHP 4.3.0 for the compression to work
To install on PHP 4.3.0 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 http://pecl.php.net/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.0, 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
--enable-bcompiler(and your other options)make; make install
that's it.
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.
- Spis treści
- bcompiler_load_exe -- Reads and creates classes from a bcompiler exe file
- bcompiler_load -- Reads and creates classes from a bz compressed file
- bcompiler_parse_class -- Reads the bytecodes of a class and calls back to a user function
- bcompiler_read -- Reads and creates classes from a filehandle
- bcompiler_write_class -- Writes an defined class as bytecodes
- bcompiler_write_constant -- Writes a defined constant as bytecodes
- bcompiler_write_exe_footer -- Writes the start pos, and sig to the end of a exe type file
- bcompiler_write_file -- Writes a php source file as bytecodes
- bcompiler_write_footer -- Writes the single character \x00 to indicate End of compiled data
- bcompiler_write_function -- Writes an defined function as bytecodes
- bcompiler_write_functions_from_file -- Writes all functions defined in a file as bytecodes
- bcompiler_write_header -- Writes the bcompiler header
- bcompiler_write_included_filename -- Writes an included file as bytecodes
| Poprzedni | Spis treści | Następny |
| bcsub | Początek rozdziału | bcompiler_load_exe |
Newsy:
Nowości z listy dyskusyjnej
Mam taki test i co prawa ju¿ go pisa³em ale nie wiem jakie s± dobre odpowiedzi moze kto¶ mi pomo¿e??
http://www.kolejland.rail.pl/iz/Forum%20-%...wania/jipp2.jpg
Moje odpowiedzi to:
1. a
2. abc
3. bc
4. d
5. ad
Plisss bardzo potrzebny nam jest taki program!!!
Witam,
Jak w temacie zlecê napisanie od nowa lub zmodyfikowanie istniej±cej ju¿ wersji programu do obliczania sum md5. Zainteresowanych proszê o kontakt.
Autor strony Polishwords rozwa¿a przej¶cie na model Open Source. Aby u³atwiæ sobie decyzjê umie¶ci³ ankietê, w której mo¿na zag³osowaæ za albo przeciwko przej¶ciu na Open Source. Pomó¿my autorowi!
Strona Polishwords jest przeznaczona dla programistów i ogó³ informatyków. Zawiera filmy instrukta¿owe z programowania i zarz±dzania baz± danych. Autor rozwa¿a obecnie przej¶cie na model Open Source i opublikowanie kodu strony. Chcia³by przez to osi±gn±æ szybszy rozwój strony i zaanga¿owanie wiêkszej liczby programistów PHP.
W umieszczonej ankiecie mo¿na zag³osowaæ czy autor powinien przej¶æ na model Open Source. Pomó¿ podj±æ dobr± decyzjê autorowi.
Wiêcej na: http://polishwords.com.pl/blog/2008/polishwords-open-source/
Witam pisze program klient-serwer. Próba nr.1:
Skorzysta³em z najprostszech komponentów tego rodzaju czyli ClientSocket i ServerSocket. Posutawialem porty oraz ip w kliencie.
Je¿eli wpsize ip localhosta (127.0.0.1) to klient polaczy sie z serwerem. Jezeli wpisze IP wewnetrzne tez sie polaczy. Ale jezeli wpisze juz ip zewnetrzne to wyskauje blad asynohrous socket error 10061.
Podejscie nr.2
Zmieni³em komponenty na Indy. Wszystko zosta³o odpowiednio skofigurowane. Wiec sytuacja jest identyczna jak powyzej wszystko dziala na ip wewnetrznym i na localhoscie a na zewnetrznym juz. Prosze o pomoc w tej sprawie.
Mo¿e jeszcze dodam, ¿e jest w sieci typu WLan.
Pozdro
Prosze o jak najszybsza odpowiedz
Jak nie znasz jezyka C++ i wskaznikow i programowania obiektowego
Kurs
Kurs powstał w celu nauki podstawowych zagadnień z dziedziny php.
Losowe tagi:
apcdba
filter
pdo
image