Liaison
THIS VERSION IS ABANDONED (Sep 2, 2024)
This PROJECT is not abandoned. Just this version.
I envisioned this version as a major refactor of Liaison. I put several hours of work into it, and I wanted it to take Liaison from messy and bad to great and extremely well-coded.
I've recently been using v0.6 again & I've been really happy with it. I've been adding features to it piece-meal. Adding types, improving how errors are managed, and significantly improving the documentation.
I want to keep this around, and I may reference some of the code or notes at a later time.
But this strategy of a major redesign was just not a good approach IMO.
Instead I am bumping from v0.6 to v0.7 and I will be improving it one little piece at a time.
Liaison is a web-framework focused on building portable web-app libraries, and websites built from those libraries.
No integrations with other frameworks (like Laravel or Wordpress) are currently available, but I hope to add them eventually.
Install
composer require taeluf/liaison old-v1.0-attempt.x-dev
or in your composer.json
{"require":{ "taeluf/liaison": "old-v1.0-attempt.x-dev"}}
Documentation
Liaison (class Lia
) ties together Apps. Apps contain Addons. Addons integrate with Liaison, responding to certain events and callbacks to setup routes, bundle css files, apply a theme, and more.
Each App dir contains a config.json
where you your app can enable addons, such as lia:router
. During the Router's onEnabledByApp
callback, routes are added for every file in your app's public/
dir. The dirname, base url, and other router-related settings can be configured for each app.
Lia
manages events and facilitates sharing of Apps, Addons, and methods. Lia::deliver()
&& Lia::execute()
emit events, hooked into by apps and addons, that set everything up & output a response.
All other features are created by Apps, Addons, and simple scripted modifications.
All of the non-Liaison functionality is separated from Addons/Apps/Lia. For example, Lia\Http\Router
does not reference Lia\Addon\Router
or Liaison or any apps. It just handles routing. You can use these classes on their own.
Liaison can be used without deliver/execute, and without the built-in apps/addons.
TODO: Create all this documentation
- Getting Started - Create an example website & app to get an overview of Liaison's features & development experience.
- Develop Apps - Develop apps that are easily shared with other Liaison websites/apps.
- Build Websites - Build a website.
- Install Apps - Install apps on your website, or depend on them within your app.
- Features
- Routing - Delivering raw files, php script files, or callable routes
- Seo - Setting meta information for SEO engines
- Cache - Using the Liaison Cache
- Events/Hooks - Hook into app and server events
- Css & Js - Compiling and Delivering javascript & css resources
- Views - Reusable Templates
- Error Handling - Displaying & logging errors
- Redirecting - Redirecting to different pages
- Autoloading - You should just use composer, but I guess you can use Liaison's autoloader.
- Write Documentation - How to write & auto-generate your documentation
TODO: Create different documentation scaffold (they should mostly be Actions like 'Add Routes' or 'Create SEO Tags' ... idk ... maybe not...)
-
Initial Setup - Create a
Lia
instance, add apps to it, and deliver web pages. (* - Built-In App - ...
- ... the built-in app
Liaison App
A Liaison app can include routes, views, methods, hooks, and more. You can include as few or as many parts as you like.
Libraries typically do one of two things: create features for other libraries to use or implement features other libraries provide. Most features are created through Addons. Most features are implemented through directory structures & configurations.
App Directory Structure
You can include one, multiple, or all of these directories.
App/
- config.json <- Package settings
- public/ <- Public files to be routed to.
- index.php <- home page
- contact.php <- /contact/
- view/ <- Views
- theme.php <- site layout
- theme.css
- addon/ <- Addons (extend \Lia\Addon)
- MyAddon.php
- class/ <- Classes to autoload, PSR4 style, but you should use composer instead.
Liaison Web Server
A web server typically includes a self-made Liaison app (for themes, views, and routes), a configuration file, environment settings, and a deliver.php
script for setting up your Site's app and any other apps you're using.
Webserver Directory Structure
This is a sample structure, and you're welcome to use your own.
DOCUMENT_ROOT
- .env/ <- Your environment configs
- .htaccess <- Used by apache to route to your deliver.php
- composer.json
- deliver.php <- Every request is routed through this file
- site/ <- Your primary Liaison app, with your theme & core pages & features.
- public/index.php <- your home page
- apps/ <- Additional apps you develop, to organize different features of your website
- deliver/ <- Optional directory to organize different aspects of your setup
deliver.php
This script sets up your webserver & delivers a response.
<?php
$lia = new \Lia();
// Add the built-in App, which provides all the web-server features.
$server_app = new \Lia\Package\Server($lia, $fqn='lia:server', ?$dir, ?$base_url); // dir & base_url not required
// Add your app, providing home page & other core pages & features
$site_app = new \Lia\Package\Server($lia, 'myname:site', __DIR__.'/site/');
// delivers files in `site/public/*`
$lia->deliver();