Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create a site in php and have it generate a static version?

Tags:

For a particular project I have, no server side code is allowed. How can I create the web site in php (with includes, conditionals, etc) and then have that converted into a static html site that I can give to the client?

Update: Thanks to everyone who suggested wget. That's what I used. I should have specified that I was on a PC, so I grabbed the windows version from here: http://gnuwin32.sourceforge.net/packages/wget.htm.

like image 931
Nathan Peretic Avatar asked Sep 15 '08 20:09

Nathan Peretic


2 Answers

If you have a Linux system available to you use wget:

wget -k -K  -E -r -l 10 -p -N -F -nH http://website.com/

Options

  • -k : convert links to relative
  • -K : keep an original versions of files without the conversions made by wget
  • -E : rename html files to .html (if they don’t already have an htm(l) extension)
  • -r : recursive… of course we want to make a recursive copy
  • -l 10 : the maximum level of recursion. if you have a really big website you may need to put a higher number, but 10 levels should be enough.
  • -p : download all necessary files for each page (css, js, images)
  • -N : Turn on time-stamping.
  • -F : When input is read from a file, force it to be treated as an HTML file.
  • -nH : By default, wget put files in a directory named after the site’s hostname. This will disabled creating of those hostname directories and put everything in the current directory.

Source: Jean-Pascal Houde's weblog

like image 58
Jake McGraw Avatar answered Oct 21 '22 15:10

Jake McGraw


build your site, then use a mirroring tool like wget or lwp-mirror to grab a static copy

like image 21
Paul Dixon Avatar answered Oct 21 '22 16:10

Paul Dixon