[Date Index][Thread Index]
[Date Prev][Date Next][Thread Prev][Thread Next]

Re: [PHP] Please review our coding standards




On Wed, 2 May 2001, Steven Haryanto wrote:

> At 5/2/2001 12:46 PM, Anuradha Ratnaweera wrote:
> 
> >We use WML (website meta language - www.engelschall.com/sw/wml/) with make
> >to produce single php files and do _not_ use the include feature of php.
> >
> >Also, we have written scripts that creates diff files between releases.
> 
> Interesting. How do you find WML so far? I evaluated WML once in the
> past, but it seemed too complex to me then...

This is a discussion on the PHP mailing list, but since most of this mail
applies to WML, I am sending a CC to WML list too.

I will outline the method we use, and most, if not all, of this is not
specific to PHP. Also sorry for being off topic ...

1. WML supports creating templates, so we have to create only the
   "content" of the document. All of them include the templace

   #include "template.wml"

   Also library files are also included using WML include mechanism and
   not PHP include(). This needs taking care of dependencies.

2. Php code have to be escaped from WML optimization/stripping process, so
   we write php inside

   <protect><? ?></protect>

   However, simple <?=$var?> doesn't need this.

   All the source files have extension wml and not php.

3. The makefile first has a list of all the php files to be generated

   HTMLFILES= index.php about.php dir1/file1.php

   etc. Notice the extension php.

4. We create *.d files to hold dependencies, so we need a list of them in
   the makefile

   DEPFILES= $(patsubst %,%.d,$(basename $(HTMLFILES)))

   This declaration gets the base name (without extention php) from
   HTMLFILES and adds extention d to all of them.

   Similarly files in the web site (at $(WWWROOT)) are also declared

   WEBFILES= $(patsubst %,$(WWWROOT)/%,$(HTMLFILES))

5. The default target is to build all the files

   all: $(HTMLFILES)

   and there is an install target to build actual files on the web site

   install: $(WEBFILES)

6. All the dependency files are included to the makefile, but since we
   don't have them at the start, errors are ignored with a hyphen -

   -include $(DEPFILES)

   This is included _after_ the target all: because DEPFILES also contain
   targets.

7. There is also a target which copies the created wml files to the real
   site located at $(WWWDIR)

   $(WWWDIR)/%.php:%.php
   	cp -f $< $@

   This target should come _before_ the %.php: target.

8. *.php files are generated with *.wml with the following rule

   %.php: %.wml
   	wml --depend=D -o $@ $<
   	wml -o $@ $<

9. The clean: target clears *.php files and distclean clears *.d files.

   Notice that if we rename a library file which is included, make stops
   with an error, and in that case, either we have to edit the .d file by
   hand, or run "make distclean".

10. Now comes the fun part of the "releasing" the web site.

   We do development on a seperate machine with an ideal configuration to
   the real thing. The real machine also has a WML source tree. The
   problem is to transfer the changes in the development system to the 
   real system.

   We keep all the releases in a seperate system and use an 'ls | tail -1'
   to find out the latest release. This is untared, wml files in the
   development tree are copied to another, do necessary settings
   for production version (for example we have two include files with
   error_reporting(0) and error_reporting(E_ALL), respectively) and
   a diff is done to create a pacth, which is applied to the copy of
   the source tree in the real system.

   Notice that we wound have done a 'make distclean' and done the diff
   against the working tree itself, but rebuilding is very time consuming
   for a big server, so we copy them to a different directory first.

11. We maintain the source tree on a CVS for obvious reasons.

This is a very rough outline of the process. There are many other details
I didn't go into. Feedback is welcome.

Regards,

Anuradha


______________________________________________________________________
Website META Language (WML)                www.engelschall.com/sw/wml/
Official Support Mailing List                   sw-wml@engelschall.com
Automated List Manager                       majordomo@engelschall.com