I remember someone mentioned using PHP as their static site generator and I was intrigued because PHP is an old and established way of doing "page templates" that it would be Cool to re-use instead of downloading a bespoke site generator tool

the problem is of course that php doesn't have any sort of "make static" command. but what it DOES have is a built-in server so that you can test out your php files.

so.

I wrote a makefile that serves a php file over localhost and then downloads from localhost to static html.

might polish this later but here's my work if you want to copy it:

https://github.com/nycki93/xp-php-wget

edit: i knew i'd seen this somewhere!
@alterae does this on its site, but with a different makefile strategy: https://git.sr.ht/~alterae/alterae.online/tree/main/item/Makefile

#programming #website #php #makefile
GitHub - nycki93/xp-php-wget: make a static website using php

make a static website using php. Contribute to nycki93/xp-php-wget development by creating an account on GitHub.

GitHub

@nycki i am only now learning that PHP apparently has a built-in webserver.

You probably don’t actually need to use it here though, if you just run a php file with php script.php it’ll output the generated page on stdout. do a shell output redirection (php script.php > output.html) to save that to a file. it might be a different environment than webserver for the php script in many subtle ways but it should work.

@[email protected] this is true! not sure if it makes the build script any simpler though; may have to try it both ways.

@kimapr @nycki Running php as an interpreter for scripts with no server has been a solid case for years. The differences mostly boil down to what global vars you have available (argv and argc instead of a request) and different configuration loaded (like php modules, memory limit) and if i recall correctly - no execution time limit by default.

The last time i checked, even Composer, a package manager for php, was written in php :T