Liaison
Liaison is a web-framework for building portable web-app libraries and fully-functioning websites.
Under Development! Some breaking changes are underway, but if it's documented, you should be able to count on it.
Install
composer require taeluf/liaison v0.7.x-dev
or in your composer.json
{"require":{ "taeluf/liaison": "v0.7.x-dev"}}
Documentation
Notice: A documentation rewrite/reorganization is in-progress. Some of these links are broken. Old documentation is below.
- Getting Started (below): Setup a Liaison-Powered Web Server
- CLI (below): Command line tool
- Packages: Contains your routes, views, theme, addons, hooks, and more.
- Addons: Organize features that you're adding to Liaison, whether for your own site, or for a library you're building.
-
Routes: Files in your
public/
dir are deliverable. Additional routing options available. - Views: Re-usable HTML/CSS/Javascript components.
- Theme: Your site's HTML page layout is just another view.
- Resources (CSS & Javascript): Add, remove, and manage css & javascript files on pages.
-
Hooks: Respond to events like
REQUEST_STARTED
andVIEW_LOADED
. -
SEO: Add
<head>
markup for search engines and social media sites. - Markdown Support: Markdown support can be added using Hooks.
- Http: Manages HTTP requests/responses, setting up hooks, processing routes, and loading themes.
- Errors & Debugging
- Cache: Cache key=>value pairs to save computation
- Tips: Various tips for website development that may (or may not) be related to Liaison.
-
Notes:
@NOTE
s throughout the library.
Getting Started
Liaison (class Lia
) ties together multiple different Packages (class Lia\Package
). Packages contain addons (class Lia\Addon
), views (php scripts), public files (php scripts), and anything else that is part of your package.
Liaison provides a built-in Server package with addons for routing, hooks, cache, SEO head tags, CSS & Javascript bundling, and views. An Http
addon processes requests and delivers responses.
I recommend using a main Site
package as the base of your site, then create additional packages for any complex features, or features you might want to use on another website later.
Create a Web Server
php -S localhost:3000 deliver.php
to run the below server.
/deliver.php
:
<?php
require_once(__DIR__.'/vendor/autoload.php');
$lia = new \Lia();
// Add the built-in Package, which provides all the web-server features.
$server_package = new \Lia\Package\Server($lia, $fqn='lia:server'); // dir & base_url not required
// Create your site's package, containing your routes, views, theme, addons, hooks, and more
$site_package = new \Lia\Package\Server($lia, 'vendor:namespace', __DIR__.'/Site/');
\Lia\Addon\Http::from($lia)->deliver();
Create the home page
Create the following file, then visit http://localhost:3000/
in your browser.
/Site/public/index.php
<h1>Hello Liaison</h1>
<p>This is my first Liaison-powered home page!</p>
What's Next?
Create a theme for your page layout, then start building out your site. See the Documentation links above to learn more about each feature. Start with public files, hooks, and views. Addons and Packages are a bit more advanced.
Planned Changes
These changes will take place piece-by-piece over time. I plan no major overhauls in a single update.
- Types: Types will be hardcoded in Liaison, instead of being dynamic/undefined.
CLI
vendor/bin/lia
runs the cli. It is self-documented, and will give you instructions on how to configure it when you run it for the first time.
For configuring, see bin/sample-config.json.
Available Commands:
help - show this help menu
error-page - Write an HTML error page to disk, with compiled css & js printed inline.
clear-cache - Delete the main cache and the resource files cache. Pass '--stale' to only delete expired files.
dump - Print information about your Lia instance, including routes, packages and addon lists, views, and more.