Documentation
A website, one file at a time.
If you know a little PHP, you know enough to get started. You can understand the whole idea right here.
Put a PHP file in pages/.
Cornerstone makes a URL from its name. pages/about.php becomes /about. A folder’s index.php becomes the folder’s address.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>PHP Cornerstone - Hello, world</title>
</head>
<body>
<h1>Hello, world.</h1>
<p>This is a whole page. Make a file, and it has a URL.</p>
</body>
</html>
Open the page this code makes. That is a real page running on this site, with no controller or template setup.
Want to try it yourself?
- Download and unzip this site.
Get the starter. It includes the core, these docs, and the examples. You need PHP 8.3 or newer; Composer and Node aren’t required.
- Start PHP in the unzipped folder.
php -S localhost:3000 -t public tools/server.phpOpen
http://localhost:3000in your browser. This built-in server is for local development only. - Make it yours.
Edit
pages/index.php, or createpages/about.phpand visit/about. Refresh to see your change. There’s nothing to compile.
What’s in the folder?
pages/ Your PHP pages
partials/ Shared pieces, like a header and footer
public/ The web root; images and CSS go in assets/
errors/ Your 404 page
src/ The small Cornerstone router
config.php A couple of settings
redirects.php Optional old-to-new addresses
Only public/ belongs on the public side of your web server. Cornerstone renders pages from outside it. See the hosting instructions.
As much organization as you need.
Keep a small page in one file. Share markup with PHP includes. Move data or logic into separate files when that helps. Cornerstone doesn’t require models, controllers, or a new template language.