PHPackages                             jbzoo/crosscms - 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. jbzoo/crosscms

AbandonedLibrary

jbzoo/crosscms
==============

Abstract library for Joomla and Wordpress CMS

1.1.12(9y ago)151.1k[1 issues](https://github.com/JBZoo/CrossCMS/issues)MITPHPPHP &gt;=5.4

Since Feb 21Pushed 9y ago5 watchersCompare

[ Source](https://github.com/JBZoo/CrossCMS)[ Packagist](https://packagist.org/packages/jbzoo/crosscms)[ RSS](/packages/jbzoo-crosscms/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (12)Versions (16)Used By (0)

JBZoo CrossCMS [![Build Status](https://camo.githubusercontent.com/8cf1510a6856a3db79494c4d6fc4285ea548be7ee7cee4a61a18281e225dcac8/68747470733a2f2f7472617669732d63692e6f72672f4a425a6f6f2f43726f7373434d532e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/JBZoo/CrossCMS) [![Coverage Status](https://camo.githubusercontent.com/93a6c8e075936ea0cc5de1d0972fd7eb37536fb287c506138a20f8ef731c0d36/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f4a425a6f6f2f43726f7373434d532f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/JBZoo/CrossCMS?branch=master)
=============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#jbzoo-crosscms--------)

#### One extention, one code — different CMS!

[](#one-extention-one-code--different-cms)

[![License](https://camo.githubusercontent.com/1cc2db290deda3019310ab4236833bc90deb27ea4335cf2fc24febfc969c8092/68747470733a2f2f706f7365722e707567782e6f72672f4a425a6f6f2f43726f7373434d532f6c6963656e7365)](https://packagist.org/packages/JBZoo/CrossCMS)[![Latest Stable Version](https://camo.githubusercontent.com/3a6ef4633615de77a26a90b585fa1f96bc6c423909f79746700077cb96a62f86/68747470733a2f2f706f7365722e707567782e6f72672f4a425a6f6f2f43726f7373434d532f762f737461626c65)](https://packagist.org/packages/JBZoo/CrossCMS) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/e88ae8ca5e27c63f338164d8712486e82a139fb7ddb4e465ad37f3baff61a938/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4a425a6f6f2f43726f7373434d532f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/JBZoo/CrossCMS/?branch=master)

[RUSSIAN README !](https://github.com/JBZoo/CrossCMS/blob/master/README_RUS.md)

### Description

[](#description)

CrossCMS it's collection of simple helpers, which helps you to create one cross platform extension for Joomla and WordPress. So developer writes code once and runs the same tests for two different CMS.

This library is result of combining different API systems to general appearance concealing the difference within yourself. It is necessary to consider it as a global renaming of the main functions of CMS (though it is a bit more complicated). Moreover, the library does not carry any specific implementations of functions. So, there is little overhead and memory performance for your extension.

CrossCMS was created for [JBZoo CCK](http://jbzoo.com/) (Content Constructor Kit) and it works fine. You can find project in the repository [JBZoo/JBZoo](https://github.com/JBZoo/JBZoo).

### Testing

[](#testing)

For testing we are running same set of unit tests in PHP from v5.4 to v7.0 **without any mocks or stubs!**. Only real CMS last versions, only hardcore!

```
make
make server
make test-all
```

### Support of CMS

[](#support-of-cms)

- Joomla CMS: 3.4.x ... 3.6.x
- Wordpress: 4.2.x ... 4.5.x

Documentation
-------------

[](#documentation)

#### Install

[](#install)

Just use the composer

```
composer require jbzoo/crosscms
```

#### Main container

[](#main-container)

[Pimple DI](http://pimple.sensiolabs.org/) contains all helpers.

Starting to use CrossCMS.

```
use JBZoo\CrossCMS\Cms;

require_once './vendor/autoload.php';
$cms = Cms::getInstance(); // Create or Get DI-singleton with helpers. It's ready to use!
```

#### Autocomplete

[](#autocomplete)

We are using [PhpStorm IDE](https://www.jetbrains.com/phpstorm/), so we recommend you to install [plugin for Silex](https://plugins.jetbrains.com/plugin/7809) and copy file `pimple.json` to the root of your project. The file is result of [JBZoo/PimpleDumper](https://github.com/JBZoo/PimpleDumper).

#### Work with cache

[](#work-with-cache)

CrossCMS uses only CMS drivers and API for caching anything.

```
$cms = Cms::getInstance();

// Check is cache enabled
$cms['cache']->isEnabled();

// Store variable to cache
$cms['cache']->set($key, $data, $group, $isForce, $ttl);

// Get variable from cache
$cms['cache']->get($key, $group);

// Store output buffer, See http://php.net/manual/ru/ref.outcontrol.php
$cms['cache']->start($key, $data, $group, $isForce, $ttl);

// Get output buffer from cache
$cms['cache']->end($key, $group);
```

Example

```
$cms = Cms::getInstance();

$myVar = $cms['cache']->get('some-var');
if (!$myVar) {
    $myVar = someHardcoreFunction(); // Too slow code
    $cms['cache']->set('some-var', $myVar);
}

echo $myVar; // Use it!
```

#### General site properties

[](#general-site-properties)

```
$cms = Cms::getInstance();

$cms['config']->isDebug();
$cms['config']->sitename();
$cms['config']->sitedesc();
$cms['config']->email();
$cms['config']->dbHost();
$cms['config']->dbName();
$cms['config']->dbUser();
$cms['config']->dbPass();
$cms['config']->dbPrefix();
$cms['config']->dbType();
$cms['config']->timezone();
```

#### Database

[](#database)

We recommend you to use [SqlBuilder](https://github.com/JBZoo/SqlBuilder) with the database helper. This is a simple and secure SQL-queries builder compatible with CrossCMS, Joomla and Wordperss. It's not required. Only if you wish. If an error occurs, CMS will throw an exception (Joomla), or cause Die (Wordpress).

```
$cms = Cms::getInstance();

$select = 'SELECT PI() AS pi';

$cms['db']->fetchAll($select);          // [['pi' => '3.141593']]
$cms['db']->fetchRow($select);          // ['pi' => '3.141593']
$cms['db']->fetchArray($select);        // ['3.141593']
$cms['db']->query($select);             // Result: (int)1 - expected rows
$cms['db']->escape(' abc123-+\'"` ');   // ' abc123-+\\\'\"` ' - Т.е получим безопасную строку для SQL средствами CMS
$cms['db']->insertId();                 // Get last Primary ID after INSERT
$cms['db']->getTableColumns('#__table') // Table columns
```

#### Dates

[](#dates)

Helper allows you to get time in different formats (check timezone and localisation). It support pre defined date formats. We are using helper [JBZoo/Utils](https://github.com/JBZoo/Utils/blob/master/src/Dates.php) for parse string to date.

```
$cms = Cms::getInstance();
$time = '2011-12-13 01:02:03';              // Date in some popular format
$time = '1323738123';                       // or in seconds (timestamp)

$cms['date']->format($time);                // '2011-12-13 01:02:03' (Sql is default)
$cms['date']->format($time, 'timestamp');   // (int)1323738123
$cms['date']->format($time, 'detail');      // 'Tuesday, Dec 13 2011 01:02'
$cms['date']->format($time, 'full');        // 'Tuesday, Dec 13 2011'
$cms['date']->format($time, 'long')         // '13 December, 2011'
$cms['date']->format($time, 'medium')       // 'Dec 13, 2011'
$cms['date']->format($time, 'short');       // '12/13/11'
$cms['date']->format($time, 'time')         // '01:02'
```

#### Environment

[](#environment)

```
$cms = Cms::getInstance();

$cms['env']->getVersion();  // CMS Version
$cms['env']->isAdmin();     // Is control panel (back-end)?
$cms['env']->isSite();      // Is front-end
$cms['env']->isCli();       // Is command line (cron...) ?
$cms['env']->getRootUrl();  // Get frontpage URL
```

#### Events

[](#events)

CrossCMS uses simple and power event manager [JBZoo/Event](https://github.com/JBZoo/Event). This is [Only one file](https://github.com/JBZoo/Event/blob/master/src/EventManager.php).

Примеры

```
use JBZoo\CrossCMS\AbstractEvents;

$cms = Cms::getInstance();

$noopCallback = function(){ /* some action */};

$cms->on(AbstractEvents::EVENT_INIT, $noopCallback);    // CMS inited
$cms->on(AbstractEvents::EVENT_CONTENT, $noopCallback); // on parse content
$cms->on(AbstractEvents::EVENT_HEADER, $noopCallback);  // before head-tag rendering
$cms->on(AbstractEvents::EVENT_SHUTDOWN, $noopCallback);// before CMS shutdown
```

You can subsribe to back-end of front-end pages.

```
$cms->on(AbstractEvents::EVENT_INIT.'.admin', $noopCallback);   // Init only for admin-panel
$cms->on(AbstractEvents::EVENT_INIT.'.site', $noopCallback);    // Init only for front-end
```

Examples for install (see comments)

- [For Joomla](https://github.com/JBZoo/CrossCMS/blob/master/src/Joomla/Events.php)
- [For Wordpress](https://github.com/JBZoo/CrossCMS/blob/master/src/Wordpress/Events.php)

#### Assets

[](#assets)

```
$cms = Cms::getInstance();

$cms['header']->setTitle($title);               // Set page title
$cms['header']->setDesc($description);          // Set page description
$cms['header']->setKeywords($keywords);         // Set meta keywords
$cms['header']->addMeta($meta, $value = null);  // Add some meta content (Open Graph, etc)
$cms['header']->noindex();                      // Noindex for Google
$cms['header']->jsFile($file);                  // Include JS-file (url)
$cms['header']->jsCode($code);                  // Some custom JS-code in the head-tag of website. (jQuery-widgets, etc).
$cms['header']->cssFile($file);                 // Include CSS-file (url)
$cms['header']->cssCode($code);                 // Some custom CSS-styles in the head-tag of website. (Dynamic background from PHP-code, etc).
```

#### HTTP-client

[](#http-client)

```
$cms = Cms::getInstance();

$response = $cms['http']->request('http://site.com/path');  // Only first argument is required

$response = $cms['http']->request(
    'http://site.com/path',                                 // Url of service
    [                                                       // GET/POST variables
        'var-1' => 'value-1',
        'var-2' => 'value-2',
    ],
    [                                                       // Options
        'timeout'    => 5,                                  // Max wait or connection timeout
        'method'     => 'GET',                              // HTTP-method (GET|POST|HEAD|PUT|DELETE|OPTIONS|PATCH)
        'headers'    => [                                   // Custom headers
            'x-custom-header' => '42',
        ],
        'response'   => 'full',                             // Format of response (full|body|headers|code)
        'cache'      => 0,                                  // Enable cache (see $cms['cache'])
        'cache_ttl'  => 60,                                 // Cache TTL in minutes
        'user_agent' => 'CrossCMS HTTP Client',             // Custom USER_AGENT
        'ssl_verify' => 1,                                  // Verify SSL cert
        'debug'      => 0,                                  // Debug mode on errors (additional debug messages from CMS)
    ]
);

// Вариант ответа для ['response' => 'full']
$response->code;     // HTTPcode, (int)200
$response->headers;  // Array of headers, 'key' => 'value'
$response->body;     // Body, some string
```

#### Localisations

[](#localisations)

```
$cms = Cms::getInstance();

echo $cms['lang']->translate('january');                        // "January" | "Январь"
echo $cms['lang']->translate('%s and %s', 'qwerty', 123456));   // "qwerty and 123456" | 'qwerty и 123456'

// Short alias
function _text($message) {
    $cms = Cms::getInstance();
    return call_user_func_array(array($cms['lang'], 'translate'), func_get_args());
}

echo _text('january');                      // "January" | "Январь"
echo _text('%s and %s', 'qwerty', 123456)); // "qwerty and 123456" | 'qwerty и 123456'
```

#### Internal libs

[](#internal-libs)

Usually all popular CMS contains popuplar JS-libraries. It makes no sense to include your jQuery file, while there is built-in one. So we avoid the classic conflicts with other CMS extensions.

```
$cms = Cms::getInstance();

$cms['libs']->jQuery();             // Include built-in jQuery file
$cms['libs']->jQueryUI();
$cms['libs']->jQueryAutocomplete();
$cms['libs']->jQueryDatePicker();
$cms['libs']->colorPicker();
```

#### Mailer

[](#mailer)

```
$cms = Cms::getInstance();
$mail = $cms['mailer'];

$mail->clean(); // Cleanup before new message

$mail->setTo('admin@example.com');
$mail->setSubject('Test message subject');
$mail->setBody('Simple test');
$mail->isHtml(false);
$mail->setFrom('no-replay@example.com', 'Website name');

$mail->setHeader('Cc', 'John Smith ');
$mail->setHeaders([
    'Cc'  => 'John Smith ',
    'Bcc' => 'Mike Smith '
]);

$mail->addAttachment('/full/file/path.zip', 'Some custom name');

$mail->send(); // return true|false
```

Short alias

```
$mail->complex('admin@example.com', 'Test message subject', 'Test complex method'); // (return true|false)
```

#### Filesystem

[](#filesystem)

```
$cms = Cms::getInstance();

$cms['path']->get('root:');     // Root of website
$cms['path']->get('upload:');   // Uploaded images and other files
$cms['path']->get('tmpl:');     // Templates
$cms['path']->get('cache:');    // FS caches
$cms['path']->get('logs:');     // Logs
$cms['path']->get('tmp:');      // For any temporary data

// Get path to file in tmp directory
$path = $cms['path']->get('tmp:my-file.txt');
$path = $cms['path']->get('tmp:folder/my-file.txt');
```

#### Request

[](#request)

```
$cms = Cms::getInstance();

$cms['request']->getMethod();                   // Current http-method
$cms['request']->isGet();                       // Is GET method?
$cms['request']->isPost();                      // Is POST method?
$cms['request']->isAjax();                      // Is AJAX request?
$cms['request']->getUri();                      // URL od current page
$cms['request']->checkToken();                  // Check tocken (XSS)
$cms['request']->getHeader('x-custom-header');  // Get HTTP-header from request

$cms['request']->set($name, $value);            // Set new value

$cms['request']->get('foo', '42');                       // Get var
$cms['request']->get('foo', null, 'trim');               // Get variable and trim it (See JBZoo/Utils/Filter)
$cms['request']->get('foo', null, 'trim, alias, float'); // Several filters JBZoo/Utils/Filter
$cms['request']->get('foo', null, function ($value) {    // Custom filter (handler)
    $value = str_replace('124', '789', $value);
    return $value;
}));
```

#### Response

[](#response)

```
$cms = Cms::getInstance();

$cms['response']->set404($message);            // Show page 404
$cms['response']->set500($message);            // Show fatal error
$cms['response']->redirect($url, 301);         // Redirect use to new location
$cms['response']->json(array $data = array()); // Send JSON
$cms['response']->text();                      // Send header "Content-Type: plain/text"
$cms['response']->noCache();                   // Send no cache headers
$cms['response']->setHeader($name, $value);    // Send response http-header
```

#### Session

[](#session)

```
$cms = Cms::getInstance();

$cms['session']->has($key);
$cms['session']->get($key, $default, $group);
$cms['session']->set($key, $value, $group);
$cms['session']->getGroup($group, $default);
$cms['session']->setGroup($group, array $data, $isFullReplace);
$cms['session']->clear($key, $group);
$cms['session']->clearGroup($group);
$cms['session']->getToken();
```

#### Users

[](#users)

```
$cms = Cms::getInstance();
$user = $cms['user']->getCurrent();

$user->isGuest();
$user->isAdmin();
$user->getEmail();
$user->getLogin();
$user->getName();
$user->getId();
$user->getAvatar(128);
```

#### Examples

[](#examples)

Plugins for Wordpress

- [JBZoo 3.x-dev](https://github.com/JBZoo/JBZoo/tree/master/src/wordpress/jbzoo)
- [JBZoo 3.x-dev for unit-tests](https://github.com/JBZoo/JBZoo/tree/master/tests/extentions/wp_jbzoophpunit)
- [CrossCMS for unit-tests](https://github.com/JBZoo/CrossCMS/tree/master/tests/extentions/wp-plugin)

Extensions for Joomla!CMS

- [JBZoo 3.x-dev](https://github.com/JBZoo/JBZoo/tree/master/src/joomla/plg_sys_jbzoocck)
- [JBZoo 3.x-dev for unit-tests](https://github.com/JBZoo/JBZoo/tree/master/tests/extentions/j_jbzoophpunit)
- [CrossCMS for unit-tests](https://github.com/JBZoo/CrossCMS/tree/master/tests/extentions/joomla-plugin)

License
-------

[](#license)

MIT

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~11 days

Total

14

Last Release

3585d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/75e6de2785f6d099699f430ff58404af4fc0e83060d2953028c9664a54704a5f?d=identicon)[smetdenis](/maintainers/smetdenis)

---

Top Contributors

[![SmetDenis](https://avatars.githubusercontent.com/u/1118678?v=4)](https://github.com/SmetDenis "SmetDenis (160 commits)")

---

Tags

wordpresscmsdriverextensionjoomla

### Embed Badge

![Health badge](/badges/jbzoo-crosscms/health.svg)

```
[![Health](https://phpackages.com/badges/jbzoo-crosscms/health.svg)](https://phpackages.com/packages/jbzoo-crosscms)
```

###  Alternatives

[johnpbloch/wordpress

WordPress is open source software you can use to create a beautiful website, blog, or app.

6079.5M471](/packages/johnpbloch-wordpress)[roots/wordpress

WordPress is open source software you can use to create a beautiful website, blog, or app.

19116.9M258](/packages/roots-wordpress)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
