Skip to content

About

Clean URLs for simple PHP sites. Write ordinary PHP and HTML, with automatic file-based routing and a ready-to-use website starter.

Resources

Contributing

Stars

7 stars

Watchers

4 watching

Forks

Repository files navigation

PHP Cornerstone

Clean URLs for simple PHP sites

Download · Documentation · Examples

Write your pages in PHP and HTML. Cornerstone gives them clean URLs automatically. For when you know PHP and just want to make a website.

Add a file. It has a URL.

Your file Its URL
pages/index.php /
pages/about.php /about
pages/docs/index.php /docs

Use ordinary PHP includes for headers and footers. Organize the rest your way. Cornerstone handles file-based routing, simple redirects, and custom 404 pages. There’s no template language to learn or route list to maintain.

Get started

PHP 8.3 or newer. No database, Composer install, or frontend build step required. You can add a database, PHP packages, or frontend tools whenever you need them.

Download and unzip the starter, then run:

cd phpcornerstone
php -S localhost:3000 -t public tools/server.php

Open http://localhost:3000. Edit pages/index.php to change the homepage. The starter includes the website, documentation, and all the examples. The local server is for development; see hosting when you’re ready to go live.

Prefer Composer?

Start a new site:

composer create-project madlab/phpcornerstone my-site
cd my-site
composer start

Or add the router to an existing project:

composer require madlab/phpcornerstone

Create your own pages/index.php. In your public/index.php:

<?php
require dirname(__DIR__) . '/vendor/autoload.php';
Cornerstone\Site::run(dirname(__DIR__));

Point your web server at public/ and send page requests to its index file. Use the starter’s public/.htaccess for Apache or the Nginx configuration. Installing the package does not overwrite your existing site files.

To add other Composer packages to the starter, use composer require normally. The starter loads Composer’s autoloader when present.

Find your way around

Location What belongs there
pages/ Your PHP pages and folders
partials/ Shared headers, footers, and helpers
public/assets/ CSS, images, and other public files
errors/404.php Your missing-page screen
redirects.php Old addresses and their new destinations
config.php Optional base path and debug setting
src/ The small routing engine

Only public/ should be exposed by your web server. Keep private code and configuration outside it. Use Cornerstone\escape() when inserting text into HTML, and $site->url() for links that need to work under a subdirectory.

A new purpose for an old project

Cornerstone began as an MVC framework that we used to build our own sites. As we moved to newer frameworks, it fell out of regular use.

Version 1.0 gives it a simpler purpose: a small foundation for PHP websites, with clean URLs and ordinary PHP pages. The router and starter now live together in this repository.

Coming from version 0.x?

Version 1.0 is a breaking rewrite. Convert Smarty views and controllers to PHP pages and includes. Move helpers, credentials, and data outside public/ and pages/. Preserve old addresses with explicit redirects before switching traffic.

The old model, session, migration, database, and dependency-container APIs have been removed. Previous releases remain available in the repository’s tags and history.


Made by MadLab · MIT license · Contributing

About

Clean URLs for simple PHP sites. Write ordinary PHP and HTML, with automatic file-based routing and a ready-to-use website starter.

Resources

Contributing

Stars

7 stars

Watchers

4 watching

Forks

Releases

Packages

Contributors

Languages