PHPackages                             livecms/transports - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. livecms/transports

ActiveLibrary

livecms/transports
==================

Live CMS Transports

v0.0.2(7y ago)11501MITPHP

Since Jul 18Pushed 7y ago1 watchersCompare

[ Source](https://github.com/livecms/transports)[ Packagist](https://packagist.org/packages/livecms/transports)[ Docs](https://github.com/livecms/transports)[ RSS](/packages/livecms-transports/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (3)Used By (1)

Welcome to Transport
--------------------

[](#welcome-to-transport)

The idea is how to transport your code (HTML and Javascript) from your business logic (Model - Controller) into View.

Like a global variable, when can set and access it from anywhere in our code.

Currently we provide HTMLTransport and JavascriptTransport. For HTML Transport, you can give it the name each time you set (inserting) the code into it, just like a variable. For Javascript, you can not insert identical script, just to make sure you don't duplicate your javascript code.

How to use
----------

[](#how-to-use)

Install via composer :

```
    composer require livecms/transports
```

HTML :

```
require vendor/autoload.php;

$htmlTransport = new LiveCMS\Transport\HtmlTransport;

// Set new transport with name 'form'
$html = '';
$htmlTransport->set($html, 'form');

// Set new transport with name 'message'
$html = 'Hello, Admin';
$htmlTransport->set($html, 'message');

// Append code to 'form'
$html = '';
$htmlTransport->append($html, 'form');

// Show content of 'form'
echo $htmlTransport->get('form');

/**
Result :

*/

// Delete content of 'form'
$htmlTransport->flush('form');
echo $htmlTransport->get('form');

/**
Result :
*/

// Use method pull() to get content and delete it.
echo $htmlTransport->pull('form');

// Delete all content
$htmlTransport->flushAll();
echo $htmlTransport->get('message');

/**
Result :
*/
```

Javascript :

```
require vendor/autoload.php;

$jsTransport = new LiveCMS\Transport\JavascriptTransport;

// Set new javascript code
$js =
