Liaison: WebApp framework
Create agnostic web-apps that can be used across many frameworks like Wordpress, Laravel, Joomla, Drupal, and others. You can make a full website with it too.
There is still much work to do. I've been working on it for over a year & there's a lot of good, a lot of pain points, and some things that are just outright trash. I'm dedicated to it, I use it for almost all my projects, for all my websites, and uhh... I hope it's awesome enough for the general public sometime soon.
WOAH WOAH
Under Development: This branch is broken and under develompent. You shouldn't use the old version_1 branch either (documented below) because a lot of stuff is changing.
all of this is going to change
Installing
composer require taeluf/liaison dev-version_1
or
{
"require": {
"taeluf/liaison": "dev-version_1"
}
}
Liaison
Liaison ties everything together. Packages & their components, view lookups, config values, routing, events, and more??
Basic Usage
$lia = new \Liaison();
$lia->addPackage(
['dir'=>__DIR__.'/my-package/',
'name'=>'MyPackage'
]
);
$lia->deliver();
This will load files from your package and route appropriately.
$lia, Methods to know
- deliver($url=null)
- uses the requested url by default, but you can pass in a url, which may include a get string like
?cats=cute
- uses the requested url by default, but you can pass in a url, which may include a get string like
- addPackage($options): $options is an array
- dir: The root directory of your package
- name: The name to be used for retrieving your package.
-Each package must have a unique name
- package($name): retrieve a package by name
- packages(): A list of packages
- compo($name): For each package, get any components named
$name.- 0 components found, return null, 1 component found, return the component, 2+ components found, throw an exception
- set($key, $value) & get($key,$valueIfNotFound): Store & retrieve values across the $lia instance
- view($name, $passthru): Get a view (from any package) by $name, passing $passthru to the view.
- See Views for more information
- register($eventName, $object, $method=null): Register the event to be executed
- send($eventName,$arg1, $arg2, $arg3, ....): Execute the given event, passing the list of args along.
- See Events
Views
Each package can set up it's own view system. Currently, we support the built-in \Lia\View and the Fresh Package lib I created. \Lia\View is... basic, but it works. Fresh Package is cool, but needs a lot of work.
Retrieve a view
Call $lia->view($name,$data) or $lia->compo('ViewHandler')->view(...)
- Get a view (from any package) by $name, passing $data to the view.
- 0 views found, return null. 1 view found, return it. 2+ views found, throw an exception
- Uses the
ViewHandlercomponent of the liaison base package to retrieve view objects
Route Types
New route types can be added, but these are built in.
PHP
Key not found for @import(Route.phpFile)
Markdown
Key not found for @import(Route.mdFile)
Everything else
Routed files not otherwise handled will be sent, with the correct headers, including browser caching headers.
Example: For file public/funny/kitty.png, url /funny/kitty.png will deliver the image file, as you would expect.
Mimetypes (for headers) are derived from a PHP file internal to Liaison. It's not particularly efficient.
Autoloading
Files in your Package's class dir will be auto-loaded. The class dir varies by package, but the built-in package uses yourpackagedir/class
It's uhh. It's dumb. It's 1 to 1 relationship of namespace to directory. This will be improved, but we're not sure how. Thus \My\Glass must be at class/My/Glass.php
The autoloader is setup during the Package_Added event
See Audoloader docs for more information.
Events
Events are the primary way that different packages and different parts of a package communicate with one another.
Any component (using the base package) may declare onNamespace_EventName($event,$arg1,$arg2,....) to automatically have the event registered when the package is added.
Namespaces aren't entirely required, but it's better that way.
Each Event callable will receive an $event object. This object is always the same \Lia\Event component object. This needs to be improved.
See Event docs for more information.
Resources files (js, css)
See Extra Docs to learn how to add javascript & css code, files, and urls to a request.