diff --git a/README.md b/README.md index 9fc10e5..911d5a9 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,10 @@ Create a .htaccess file with the following contents at the base of your project ``` RewriteEngine On RewriteCond %{REQUEST_URI} !(\.png|\.jpg|\.webp|\.gif|\.jpeg|\.zip|\.css|\.svg|\.js|\.pdf|\.ttf)$ -RewriteRule (.*) setup.php [QSA,L] +RewriteRule (.*) index.php [QSA,L] ``` -Obviously you must then add setup.php in the base of your project, to start, add the following contents: +Obviously you must then add index.php in the base of your project, to start, add the following contents: ```php determine($route); -//Phntm::Profile()::dump(); +// remove 'profile: true' to disable profiling +Phntm::init(profile: true); ``` This will set up the namespace router, and determine what to do with the current request. -Next, add the pages namespace to your composer.json pointing to the directory you wish to use, although I would recommend pages/ in the base of your project. - -To ensure composer loads all the contents of this directory call the following command to force this. -```bash -composer dumpautoload --optimize +Next, add the Pages namespace to your composer.json pointing to the directory you wish to use, although I would recommend pages/ in the base of your project. +```json +{ + "autoload": { + "psr-4": { + "Pages\\": "pages/" + } + } +} ``` -Any time you add a new page or file to your pages/ directory you will need to call this to resource the namespace - - I am currently looking into a way to do this automatically - Then start your local server and do as you wish ```bash php -S localhost:3000 @@ -68,27 +64,65 @@ class Page extends PageTemplate public function __construct() { parent::__construct(); + $this->setContent(<<home + HTML); + } +} +``` + +## Layouts + +Similar to NextJS, phntm uses layouts to wrap around the content of a page, this is useful for things like headers and footers, shared assets and more. +```php +registerAsset('/assets/layout.css'); + $this->registerAsset('/assets/layout.js'); + $this->setContent(<< +
+