PHP

13 Oct 2004

libgda on windows

I mentioned a while back that my new php extension (dbdo) used libgda, and that i ran into a roadblock, that libgda was not available on windows. Well, after quite a bit of work, that is finally solved.

For those not interested in the how - it's available here
libgda for windows

IMPORTANT: you must be unzip the files to C:\libgda (so the providers are in C:\libgda\providers\*.dll)

Note you need the dll's from the following files
(use http://www.gimp.org/~tml/gimp/win32/downloads.html if any of these are out of date.)

http://www.gimp.org/~tml/gimp/win32/glib-2.4.5-20040903.zip
http://www.gimp.org/~tml/gimp/win32/libiconv-1.9.1.bin.woe32.zip http://www.gimp.org/~tml/gimp/win32/gettext-runtime-0.13.1.zip

from ftp://ftp.zlatkovic.com/pub/libxml/
ftp://ftp.zlatkovic.com/pub/libxml/libxml2-2.6.14.win32.zip
ftp://ftp.zlatkovic.com/pub/libxml/libxslt-1.1.11.win32.zip
ftp://ftp.zlatkovic.com/pub/libxml/zlib-1.2.1.win32.zip

for mysql
http://mysql.mirrors.pair.com/Downloads/MySQL-4.0/mysql-4.0.21-win-noinstall.zip

for postgres
http://www.hagander.net/pgsql/win32snap/postgres_win32_7.5_devel.zip


While I doubt I'll ever personally use the thing, It has been quite interesting building it. After trying out a few compilers (including MSVC, dev-cpp, cygwin) I settled on using mingw and cross compiling on linux. (yes the whole thing is built on linux!), and tested under win4lin.

I did experiment using make/configure, but concluded it was far easier to script the build process in PHP (build.php), there is also a enviroment creator (mkenv.php) which downloads all the necessary components (may need tweaking)

Other than this, there is a little fun involved in getting the mysql backend to build. Based on the instructions on creating a mingW mysql client, you have to follow the windows bit at the bottom, pretty much word for word..
  1. download the mysql libs above
  2. copy the libmySQL.dll to a windows machine, and run the pexports (part of the mingw distro for windows) to get the def file.
  3. copy the defs file to the build same folder as the original .dll
  4. run the dll tool eg.
    /usr/src/win32mingw/mysql-4.0.21-win/bin/#
    /usr/src/win32mingw/cross-tools/bin/i386-mingw32msvc-dlltool --input-def libmySQL.def --dllname libmySQL.dll --output-lib libmySQL.a -k
  5. Try running the builder - you get lots of errors like
    unknown symbol mysql_init@4 ..... mysql_real_connect@16 etc.
  6. edit the defs file manually (change mysql_init to mysql_init@4 - matching the prefixes to the missing symbols
  7. repeat step 4.
  8. if you got all the right @ signs it will build very hapilly.
The other big trick that I spotted from mysql++ was that you need to add -DSYMBOL=int to the gcc lines!! - that's not mentioned anywhere!! :)

Next step is finding if anyone can add dbdo to the build scripts for snaps.php.net

Posted by in PHP | Add / View Comments()

14 Sep 2004

When windows throws a spanner in the works

I really hate it when I overlook something. This week it was libgda, which is the current backend for DBDO. It was after a few commits by the pecl team to the config.w32 file in cvs. The question came to me.... Could DBDO actually be built on windows?

Unfortunatly after some reseach, the answer was a definate maybe. libgda was designed to be buildable on windows, but no-one has really taken up the gauntlet and run with it. Browsing through the archives, it looks like a few people have tried, but no-one had actually decided to make it their baby. So no dll's or lib's exist for libgda.

This does leave DBDO in a bit of a state of flux.
  • Should I continue on, as on Unix, libgda provides an excellent backend, and builds really easily and quickly. (on the offchance that someone gets passionate about win32 support and spend a few nights figuring out how to build libgda)
  • Should I look at the alternative backends:
    • libdbi - which lacks
      • has no global connection/config cache
      • a schema retreival API
      • a column type to abstract column type API
    • pdo - which lacks
      • has no global connection/config cache
      • a schema retreival API
      • a column type to abstract column type API
    • copy & pasting chunks of libgda (impossible due to the LGPL...), let alone a pain to implement..
To implement the same thing using PDO, would require
  • copying the driver header file (and keeping up with any changes)
  • copying the driver loader code.
  • implementing a config cache.
  • implementing a connection cache.
  • adding schema query and fetchers for all the backends.
  • adding schema type to enum type mappers.
  • enriching the type enum? maybe
It may be worth attempting this by emulating the gda calls, and relaying them through the pdo backends??

On a side note, It became clear earlier that the joinAdd design in DataObjects is probably far better done on the client side, - most of it relates to building the join part based on the links configuration. As far as I can see, this is hardly touches on the special advantages of coding it up in C.


Posted by in PHP | Add / View Comments()

26 Aug 2004

Sorting out my old HTML mess - XUL+Midas is nice.

My old website www.akbkhome.com has been suffering from serious neglect. I scraped enough together time a few months ago to extract the old content out of midgard, into a subversion with a wiki like file structure, and overlay a simple rendering layer.

For some strange reason, even though I'm dieing to get on with pintcompiler and dbdo, the fact that most of the links on the old site where broken really annoyed me. So I spent a bit of time this week writing a editing interface for it.

These days I try and avoid any type of dynamic interface work in HTML - XUL is the only way to do forms, and user-interfaces. So I started with the midas demo code and plugged it into a XUL interface.

Along with this I added a links editor [press on the view as links] (as that was the major thing to sort out on the site), a insert link from navigation bar (as my menu is a simple html list, parsed with XML_Tree). Added a few fun features like a image browser, tag viewer, webdav publishing (thanks to a link from chegru) and hey it's a pretty damn cool simple site manager.
Have fun playing with it.. (mozilla/firefox only)
http://www.akbkhome.com/wiki.php/Edit/phpmole_IDE/index

the only bit that bugs me at the moment is how to get the selection code to recognize that you pressed on an image (I suspect I may have to add onclick handlers to the images or something..)


Posted by in PHP | Add / View Comments()

21 Aug 2004

Latest in Vapourware, PintCompiler & dbdo

Most days I work on paid projects (or try to), while they sometimes offer an intellectual challenge (like hacking up xul trees in javascript [it's amazing how javascript is actually usable on Mozilla, rather than the absolute nightmare it is on IE]), or some pleasant company (doing maintenance at a yacht club). It tends to be more the exception than the rule. Most of the day is spent going through lists of changes that have been discussed and modifying databases, interfaces, and ocassionally fixing up someone else's code.

So to prevent insanity creeping in, I try and find something interesting to attack in the evening. In the last few weeks I've had 2 projects ticking away, both of them have big question marks about whether they get finished (like phpmole,DB_DataObjects), or get abandoned in the wastland of muse's (like PHP#, BinaryPHP). Anyway only time will tell.

PintCompiler

Sterling, Thies and a few others, have been busy investigating PHP for Parrot, I had a chance to browse the code a couple of weeks ago. Last time I saw it was at the PHP conference last November, which was a bit chaotic, so although I did start trying to hack up a compiler in PHP to do the same thing, the phpSharp code base I was using wasnt quite ready..

Fast forward 9 months later, having hacked in a Abstract Syntax tree into BinaryPHP, I now had a Tree that parsed PHP code, which could theoretically be refactored quickly to write a generator for any type of bytecode. It took exactly 3 evenings to modify the BinaryPHP tree builder/generator to get the first hello world's working, along with some basic maths etc.

Pint originally had about 6 test PHP files, the most complex a mandelprot calculation however proved to be difficult to implement. Mainly based on a poor assumption I made in designing the code generator. I had assumed it would be a good idea to keep the number of temporary vars down to a minimum, and reuse them where possible. This was a BIG! mistake. Due to the way variables are objects, and need cloning explicity, if you try and reuse a variable and forget to clone, you tend to end up changing the first variable value by accident. Luckly to get it working properly is probably just a matter of reducing the redundant extra clone'ing opcodes, and removing the temporary variable stack code..
http://devel.akbkhome.com/svn/index.php/PintCompiler/

DBDO - DB_DataObjects as a PHP extension.

http://devel.akbkhome.com/svn/index.php/dbdo/
I had been toying with this idea for a while, DataObjects, while being a godsend for development, has a ended up with little issues that are totally unfixable, while it remains in PHP. some of the biggest being, how to reduce the print_r() size, and how to determine which variables have changed, when building the update/insert requests.

So after spending a week or so looking at potential backends (libgda, libdbi and pdo), My major preference out of all these was libgda, for a number of reasons. Interesting Design, alot of Backends, Great Documentation and it uses the glib/gobject stuff that I've used a couple of times over the years. Although the mailing list is quiet, compared to most of the php ones, the developer's list seemed to be getting things done. It was a close call, there where alot of other deciding factors, libgda's type library was pretty convincing, and introspection features made it pretty compelling.

While no where near completed (and leaking memory like a seive) After 3 late nights, I have alot of what I thought would be the more complex stuff working: - >>>> read the extended entry to find out more (as this intro is long enough).. >>>
Posted by in PHP | Add / View Comments()

30 Jul 2004

Oh how they fear the GOTO

It's kind of fun watching the reactions to the GOTO proposal for PHP, most negative reactions appear to be comming from people who have not actually read the code, kind of like a knee jerk reaction to flamebait.

Sara's Patch introduces localized GOTO's, eg. only within the current function / method scope. (although theoretically you can jump around within the global scope, you cant jump to it from inside a function/method.)

So if you read and understand the historical reasoning against GOTO's you quickly realize that GOTO's only really cause spagetti code when used wildy in really large blocks of code.

The reality is that as most programmers know, large methods and functions often are either an indication that the codes not that good anyway (eg. it should have been broken up into smaller components), so the addition of GOTO's is not going to make a pile of shit smell much worse..

While I dont think the original joke about adding it and not documenting it will fly, I do hope that it is modified to prevent usage in the global scope.



Posted by in PHP | Add / View Comments()

22 May 2004

Hello World.. First step to world domination... Compiling PHP again.

It seems like 4 months since I got a chance to 'expand my mind', rather than manically try and complete some paid work. But last week, the workload cooled off enough for me to spend some time with my favourite pastime, trying to make binaries out of PHP.

As I've pointed out a few times in the blog, making .exe's/binaries from PHP, for me is more about solving the desktop (and maybe the daemon issue), rather than solving the web problem. As PHP in it's current form solves that perfectly well. (unless you happen to be desperatly insecure in your job, in which case Perl can work quite well.)

I had seen The BinaryPHP project quite a while back, and thought it was an interesting idea. Using c++ to represent the rather painfull little item called a variable in PHP, made alot of sense. - It also had managed to build a small library of some of the functions (the other real pain for PHP). And not only that, it could actually compile Hello world, and a few others.

However, it did have one major design flaw, it tried to just use PHP's tokenizer to do the conversion. Having already got some way (although not much further than Hello world) with PHPSharp, my look at a .NET compiler. I had realized pretty early that a Parser (phpJay) was required to understand the language structure, and a tree builder and many, many nodes (treecc) where needed to represent the language prior to generation (What is now BinaryPHP_Generator_Function).

At present, it builds a parse tree, then runs emilCpp on each of the function blocks (main being the global scope one). and adds code ($function->addCode()) to the function, registers variables
($function->registerVar($name), $function->registerTmpVar() ) and generates some pretty funky code.

The current state should be pretty visable as it compiles helloworld2.php into helloworld2.php.cpp. The nodes are generated by the Parser.jay, and emited by Nodes.emitCpp.tc.
Then compiled by BinaryPHP_Compiler (and it's factory provider for g++)


Posted by in PHP | Add / View Comments()

01 Apr 2004

Changes to case sensitivity in PHP

After rather heated discussions on IRC over the last week, concerning StudlyCaps naming and php core. The core php developers (from what I saw) appear to be close to agreeing on some changes for PHP5.1
  • Finally we will get Case sensitive functions / methods
  • the _ underscore naming convention for PHP functions will be gradually replaced with StudlyCaps for all objects,  methods and functions.

Alot of the discussion centered around the impact this may have on old code, In general it was the concensus that it would only break really bad code hosted on sourceforge, which wouldnt be a complete disaster..

I have to admit it was pretty rare to see such agreement in such an argumentative group, but they considered consitency to be the ultimate goal, and it would make the life fo developers considerably easier.

Some of the core deadlines in the strategy are
  • Changing the manual to add the extra 500+ functions, and make the old ones redirect to new ones, (eg. going to www.php.net/array_count would redirect automatically to www.php.net/arrayCount) this is expected to be complete by July
  • For adding the aliases in, Lukas Smith was unanomously nominated to undertake the code changes, normally a core PEAR developer this will be his first major expedition into the C source code. it is expected that this will be completed by November.

In the meantime, they do recommend that if you are using any of the existing under_scored methods, that you write short wrappers to ensure that when they are removed in PHP5.1, that your applications work:
eg.
if (!function_exists('array_count')) {
function array_count($a) { return arrayCount($a); }
}


Posted by in PHP | Add / View Comments()

13 Mar 2004

back from the php|cruise - Books and APC

Finally recovering from my long flight back from the php|cruise, I hope everyone enjoyed my talks there. Unlike the php conference in germany, i (and the other real developers) got to meet alot more of the attendees, which was really nice.

I even managed to win George's Advanced PHP book in a raffle, A very nice book, as everyone has been saying. I really liked the section on how to write PHP extensions (the amount of times that would have come in handy, rather than greping PECL and ext/*). My only nitpick was that he did a whole chapter on DataAccess Modeling, where he basically implemented a really simplistic DataObject, and failed to mention DB_DataObjects.

I had a really good evening after the cruise with James Cox and Stuart Herbert, who like all people involved in PHP seem to have wonderfully forcefull opinions about a variety of subjects, which rarely match.. :). James, now an editor at Apress, also took us round a few bookshops in Orlando. And I finally got to see the only Book which has my name in the intro section.

Yes, I was one of the technical reviewers on PHP MySQL Website Programming: Problem - Design - Solution and also wrote the last chapter (that you can download from that site). The book has proved to be pretty popular, which is quite nice.

On a slightly related note, I tried out georges APC extension on my little framework, on average I had page load times of 0.29s, was wasnt to bad, considering its a good ole php4 object MVC system, (although designed to be sensibly light weight). so I was very happy to see 0.06 seconds after installing APC. - nice work there.


Posted by in PHP | Add / View Comments()

22 Feb 2004

.NET, parrot and compiling

Sterlings got another nice little blog up about parrot & .NET, he touches a bit on my concerns (less directly), in that with a fixed specification, like .NET, making allowances for the oddities of Scripting languages is going to be a little more complex...

All this talk has been making me ponder the real reason for my interest in them. At the heart I guess is the desire to do desktop programming again, and seeing the results of PHP-GTK. While proving to be a great development enviroment, and lighting fast on linux, it proved to be less than desirable on Win32 desktops.. Really slow on old machines (basically everything is slow on them.. including Java, and .Net wont even install on alot of those win95/98 boxes...), let alone the amount of work I got into with writing bytecode compilers and installers.. - It's a long way from point and click build... deliver..

So I did rack my brain about the whole idea of bytecode languages, and started to ponder... why not compile the thing down to assember and make .exe's and forget about the interpreter/jvm crap....

gcc is an interesting project in that respect - It was designed to have pluginable frontends .. gjc, g++ are just 2 examples, mercury which has backends that compile to .NET, java, and native using gcc shows the potential.. However... most of the documentation for compiler backends indicates the best, first step is to build gcc... - which proved to be impossible .. I just kept ending up with this.. and no great response from google for ideas..
/usr/src/gcc-3.3/gcc/tree.h:351:24: tree-check.h: No such file or directory
print-rtl1.c: In function `print_mem_expr':
print-rtl1.c:93: warning: implicit declaration of function `IDENTIFIER_NODE_CHECK'
print-rtl1.c:93: error: invalid type argument of `->'
print-rtl1.c:102: warning: function `IDENTIFIER_NODE_CHECK' was previously declared within a block
print-rtl1.c:102: error: invalid type argument of `->


oh well, so much for the idea of playing with the toy compiler..., writing php bindings for gcc, then targeting a gcc tree as a target for my parser....


Posted by in PHP | Add / View Comments()

09 Nov 2003

Pint - PHP in Parrot

It was nice to meet up with Sterling and Thies at Franfurt, after seeing a few mentions in their blog about PHP in Parrot, I finally go to see the work.

Having got so far with my PHPSharp, toy, It was interesting to see how similar the two project codebases where, (apart from PINT is written C, and PHPSharp is in PHP). But I guess the biggest supprise was IMC, the kind of bytecode for dummies that they where generating. (If I'd seen this earlier I perhaps would  not have bothered so much with a .NET target).

IMC is kind of hard to dig up on parrotcode.org, but it's a richer IL language, that can be compiled down into parrot opcodes, so you dont have to bother understanding about register based stuff, (as it's alot simpler to work with stack based bytecodes)

I download parrot, and tryed to get the examples imc code to work, but found it segfaulted all the time, however code from PINT didnt segfault until after it had run. so Obviously the examples may not have been updated.


For the last day at the hotel (as I got stuck in Frankfurt for one extra day after the conference finished), I started changing the code in PHPSharp to parse PHP, using the PHP_Parser code I'd done before, on the premise that I could add a file Nodes.imcEmit.tc which would implement emiting IMC bytecodes from the tree that it builds..

Well I got quite a way on changing the parser to create Nodes for PHP, but didnt quite finish it.. (and I really need to change the parser to use a more classic $tokenizer->advance() approach.

But perhaps with a few more hours I might be able to get Pint's mandleprot compiled as well. :).. Although that still leaves the doors open to the two fundimental problems of both projects

a) It takes alot of time to do this compiler stuff..

b) There are lots of funky issues to sort out, like type guessing, how to implement all the existing 'PHP' functions.... and on and on..


Posted by in PHP | Add / View Comments()
« prev page    (Page 6 of 7, totalling 63 entries)    next page »

Follow us on